我正在开发一个asp.net Website.I有Resource.resx文件来翻译网站的术语。当我使用Text ='<%#Resources.Resource。ارسال%>'时,我想将按钮文本翻译成英语和波斯语。对于文本它不起作用,并且不显示文本。
{{1}}
答案 0 :(得分:1)
像这样:
<asp:Button ID="Button1" runat="server" Text="<%$ Resources:Resource, Button1 %>" />
InitializeCulture()
方法,并根据查看Web应用程序的用户类型设置区域性。像这样:
public partial class GlobalizationExample : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected override void InitializeCulture()
{
//Get the language that the client prefers from the browser
string preferredLanguage = Request.UserLanguages[0];
//Set the language for the page
System.Threading.Thread.CurrentThread.CurrentUICulture =
new System.Globalization.CultureInfo(preferredLanguage);
System.Threading.Thread.CurrentThread.CurrentCulture =
System.Globalization.CultureInfo.CreateSpecificCulture(preferredLanguage);
}
}
如果上述内容无法帮助您here,那么这是一个关于在ASP.NET中应用全球化的不同方式的精彩视频。