Resource Files how to name them?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 04:36:37

问题


I am playing around with resource files and have run into a problem.

I have a folder called Languages. When I make a resource file and say call it "R.resx" I can call this resource file up in my classes.

If I rename this file(or delete and make a new resource file) and call it R.en.resx I cannot call this resource file up in my class anymore.

Does the first language need to be in R.resx where the rest would be R.language.resx?


回答1:


Step 6

To create resource files for additional languages, copy the file in Solution Explorer or in Windows Explorer, and then rename it using one of the following patterns:

For global resource files:

name.language.resx

name.language-culture.resx

For local resource files:

pageOrControlName.extension.language.resx

pageOrControlName.extension.language-culture.resx

So yes, you are correct in your assumption that the base resource file would be the first language.

EDIT:

var temp = Properties.Resources.ResourceManager.BaseName.Replace("YourNamespace.Properties.",""); 

You may have to also do this (to get rid of the language part after the name chunk):

 temp = temp.Replace(".thelanguagechunk","");

This code would get you the "name" chunk you are after by itself.



来源:https://stackoverflow.com/questions/7561755/resource-files-how-to-name-them

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!