是否有可能在本地化Web.config文件中的appSettings的信息?有可能、文件、信息、config

2023-09-03 05:22:07 作者:绝戀ㄨ

我有这样的事情记:

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

但的添加元素只有2个属性 - ,所以我想这是不支持的。

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?

更新 - 解决方案,我实现:

动信息资源文件的缺点(Oded's答案)的事实是,它不再能很容易地修改对开发者和测试者的机器。

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.

不过,这里就是我所做的 - 我在的web.config 文件留下的设置(它们不能被本地化,但他们可以无需重新编译修改code)和补充他们的资源文件(它们可以被本地化,它们在生产环境中使用只,其中的web.config 设置被设置为空字符串)。

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.

请参阅。 NET 2.0),了解更多信息。

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