.resx 文件或 Redis 中的语言字符串?
我正在尝试为一个新网站建模(到目前为止仅在纸上),并且我开始思考什么可能是最好的方法。该网站需要是多语言的(至少两种语言)。由于我最近开始测试 Redis,我想也许我可以在 Redis 中而不是在 .resx 文件中存储语言库。
我知道这是可行的,但是值得吗?它是否有可能提高性能,或者 .resx 文件中的字符串是否已经缓存并且性能“足够”?我缺乏如何处理 .resx 文件的经验,因此您的所有输入都有帮助!
I am trying to model a new site (only on paper so far), and I started to think about what might be the best approach. The site needs to be multi-lingual (at least two languages). Since I recently began testing Redis, I figured that maybe I could store a library of languages in Redis instead of in .resx-files.
I know it's doable, but is it worth it? Is it possible it will increase performance, or are strings in .resx-files already cached and performant "enough"? I lack the experience of how .resx-files are processed, so all your input is of help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我最近在一个多语言网站上工作。
我使用了 Json 字符串。
我在数据库中存储每种语言一个字符串。
{
"HeaderWordWideShipping" : "全球运送/30 天全额退货",
"标头货币" : "货币" ,
"ComboSelectAll" : "选择全部..."
在 Page_Init 上,
我从数据库中选择正确的字符串,并将值分配给公共属性。这里有一些示例代码(我使用 Newtonsoft.Json.dll 来读取 Json):
然后您可以在页面中使用公共属性。
为了更加安全,我添加了一个合并运算符来用默认语言文本替换 null:
I have recently worked on a multilingual web site.
I used a Json string.
I'm storing in the database one string per language.
{
"HeaderWordWideShipping" : "Word Wide Shipping / 30 days Full Return",
"HeaderCurrency" : "Currency" ,
"ComboSelectAll" : "Select all..."
}
On Page_Init I select from database the correct string and I assign values to public properties. here some sample code (I used Newtonsoft.Json.dll to read Json):
then you can use public propertis in your page.
to be extra safe I added a coalesce operator to replace a null with a default language text: