根据语言在文件夹中组织 ASP.NET 资源文件
在我的应用程序的根 App_LocalResources
中,我创建了多个资源文件 (.resx
) 来将我的应用程序本地化为多种语言。
对于西班牙语,我复制了默认资源文件,并在 .resx
之前添加了 .es
,以便全名为 myresource.es.resx
。当我更改 UI 文化时,语言更改效果很好。
但是,当我想将西班牙语资源文件组织在 下的一个文件夹中时(尝试过:
文件夹中,应用程序停止识别资源文件。es-Es
、es
和 Spanish
) >App_LocalResources
是否有关于如何组织每种语言的资源文件的约定,以便我没有一个包含所有资源文件的文件夹?
In my application's root App_LocalResources
I've created several resource files (.resx
) to localize my application for multiple languages.
For Spanish, I copied over the default resource files and added .es
before the .resx
so that the full name is myresource.es.resx
. When I change the UI culture, the language change works fine.
However, when I wanted to organize my Spanish resource files in one folder (tried: es-Es
, es
and Spanish
) under the App_LocalResources
folder, the application stopped recognizing the resource files.
Is there a convention of how to organize resources files for each language so that I don't have a single folder with all the resource files?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您不执行每页资源文件,请改用
App_GlobalResources
。您可以使用此方法将文件组织到文件夹结构中。 IIRC,您的文件名在整个树中必须是唯一的,而不仅仅是在每个分支中。我已经成功地按站点部分命名文件,但当然是YMMV。这里有一篇 MSDN 文章应该对您有帮助:
http://msdn.microsoft.com/en-us/library/ms227427.aspx
If you aren't doing resource-file-per-page, use
App_GlobalResources
instead. You can organize your files into a folder structure using this method. IIRC, your file names have to be unique in the whole tree, not just in each branch. I've had good success naming the files by site section, but YMMV of course.Here's an MSDN article that should help you:
http://msdn.microsoft.com/en-us/library/ms227427.aspx
资源文件夹中的资源 DLL 的名称是什么?它不应再包含区域设置 ID(因此 es\myresource.dll,而不是 es\myresource.es.dll)
What is the name of the resource DLL in the resource folder? It should not contain the locale id anymore (so es\myresource.dll, not es\myresource.es.dll)