是否可以在web.config文件中本地化appSettings信息? [英] Is it possible to localize the appSettings information in web.config file?

查看:209
本文介绍了是否可以在web.config文件中本地化appSettings信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的想法:

 < appSettings> 
< add key =ConfigNamevalue =configurationculture =1033/>
< add key =ConfigNamevalue =konfiguracjaculture =1045/>
< / appSettings>

add 元素只有2个属性 - key value ,因此我不支持它。



心灵是:

 < appSettings> 
< add key =ConfigName-1033value =configuration/>
< add key =ConfigName-1045value =konfiguracja/>
< / appSettings>

任何人都可以提出更好的解决方案?






UPDATE - 我实现的解决方案:



将此信息移动到资源文件 Oded的回答)是在开发人员和测试人员的机器上不能再轻易修改的事实。



然而,这里是我做的 - 我离开了设置在 web.config 文件(它们无法本地化,但可以修改而无需重新编译代码)将它们添加到资源文件它们可以被本地化;它们仅在生产环境中使用,其中 web.config 设置被设置为空字符串)。











$ b

使用卫星程序集和资源文件进行本地化。



如果你只有少量的项目,在 code>可以,但经验表明,项目数量会增加,直到这将是一个维护噩梦。



请参阅指南(全球化和本地化在ASP.NET 2.0中揭示)更多详细信息。


I have something like this in mind:

<appSettings>
 <add key="ConfigName" value="configuration" culture="1033" />
 <add key="ConfigName" value="konfiguracja" culture="1045" />
</appSettings>

but the add element has only 2 attributes - key and value, so I guess it's not supported.

Next thing that comes to my mind is:

<appSettings>
 <add key="ConfigName-1033" value="configuration" />
 <add key="ConfigName-1045" value="konfiguracja" />
</appSettings>

Can anybody suggest a better solution?


UPDATE - solution I implemented:

The downside of moving this information to resource files (Oded's answer) is the fact that it can no longer be easily modified on developers' and testers' machines.

However, here's what I did - I left the settings in the web.config file (they cannot be localized, but they can be modified with no need to recompile the code) and added them to resource files (they can be localized; they are be used in production environment only, where the web.config settings are set to empty strings).

解决方案

You should not store localization data in config files.

Use satellite assemblies and resource files for localization.

If all you have is a small number of items, holding things in config could be OK, but experience suggests that the number of items will grow until this will end up being a maintenance nightmare.

See this guide (Globalization and localization demystified in ASP.NET 2.0) for more details.

这篇关于是否可以在web.config文件中本地化appSettings信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆