以编程方式对字符串进行局部化
本文关键字:局部化 字符串 编程 方式 | 更新日期: 2023-09-27 18:06:12
Asp.net 4和c#。
我有一个string
在我的代码后面。我想根据用户的浏览器区域分配一个值。
我正在尝试使用此代码,没有错误,但不工作(没有为字符串分配值)。
你知道怎么解决吗?由于
string textPrevious = "<%$ Resources:Global, CategoryListSubCategories %>";
我自己找到了解决办法:就用Resources.Global
吧
string textPrevious = Resources.Global.CategoryListSubCategories;
有用的文章:http://shan-tech.blogspot.com/2007/02/aspnet-20-localization-of-string.html
你可以这样做…
string textPrevious = Resources.Global.CategoryListSubCategories;
您可以构建一个ExpressionBuilder来访问代码隐藏字符串。文章。net字符串资源包含了类StringExpressionBuilder和表达式Strings:
<asp:Label ID="AppTextLabel" runat="server"
Text="<%$ Strings:MyCompany.MyApp.MyStrings, AppText %>" />
<asp:Label ID="LibTextLabel" runat="server"
Text="<%$ Strings:MyCompany.MyLib.MyStrings, LibText %>" />