服务器端分页、排序和搜索以及多语言支持
我很好奇是否有任何最佳实践、模式或建议来为支持多种语言的 Web 应用程序进行服务器端分页。
现在我们的应用程序通过数据库翻译支持多种语言,所以我们所有的实体看起来像:
ENTITY X TABLE
---------------------------------------------------------------------
idEntity | code | other attributes....
---------------------------------------------------------------------
1 entity1.name ....
2 entity2.name ....
然后是一个包含所有翻译的“翻译”表:
TRANSLATIONS TABLE
---------------------------------------------------------------------
idTranslation | code | idLanguage | translation
---------------------------------------------------------------------
1 entity1.name 1 myEntity_EN
2 entity1.name 2 myEntity_FR
到目前为止,这效果很好,但问题是我们有一个显示数据的 Web 应用程序,我们正在实现服务器端分页,并且我们所有的数据表都必须可以通过我们显示的所有列进行搜索和排序,当然搜索和排序必须基于翻译而不是代码列。
目前,我们遵循的路径是将查询中的排序、搜索和分页参数添加到数据库中,然后数据库执行表的联接,这似乎可行,但看起来仍然有点苛刻......并且我有点担心我们有很多翻译的性能。
那么,在这种(我认为)非常常见的情况下有什么建议可以遵循吗?
提前致谢!
I'm curious about if is there any best practice, pattern or recommendation for doing server side pagination for a web application that supports multiple languages.
Right now our application supports multiple languages through database translations, so all our entities look like:
ENTITY X TABLE
---------------------------------------------------------------------
idEntity | code | other attributes....
---------------------------------------------------------------------
1 entity1.name ....
2 entity2.name ....
And then a "translation" table with all the translations:
TRANSLATIONS TABLE
---------------------------------------------------------------------
idTranslation | code | idLanguage | translation
---------------------------------------------------------------------
1 entity1.name 1 myEntity_EN
2 entity1.name 2 myEntity_FR
So far, this works great, but the problem is that we have a webapp which displays data, and we are implementing server side pagination, and all our data tables must be searchable and sortable by all the columns we display, and of course the search and sort must be based on the translations not the code columns.
For now, the path we are following is adding the sort, search and pagination parameters in the query to the DB, and the DB performs the join of the tables, which seems to work, but it still looks a bit harsh... and I'm a bit worried about performance we have lots of translations.
So, is there any recommendation to follow in this (I think) quite common scenario??
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您有服务器端分页,那么让数据库对文本进行排序并没有什么坏处,它只是语句中的另一个联接,只要您的整体语句正确完成,您的 DBMS 应该能够快速处理这个问题。
There's nothing bad about having the DB to sort the text if you have server side pagination, it's just another join in your statement and your DBMS should be able to handle this quickly, as long as your overall statement is done properly.