我正在尝试在 asp.net 中学习本地化。我正在尝试在从下拉列表中选择语言时更改标签文本和按钮标题。我搜索了示例代码并使用它们。但它不起作用。不使用下拉菜单并使用语句设置语言Thread.CurrentThread.CurrentCulture = new CultureInfo("hi-IN");
。我已经为英语和印地语生成了资源文件。
给出了代码和屏幕图像
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
listvalue = DropDownList1.SelectedValue;
InitializeCulture();
}
protected override void InitializeCulture()
{
if (listvalue != null)
{
String selectedLanguage = listvalue;
UICulture = selectedLanguage;
Culture = selectedLanguage;
Thread.CurrentThread.CurrentCulture = new CultureInfo(listvalue);
/*Thread.CurrentThread.CurrentCulture =
CultureInfo.CreateSpecificCulture(selectedLanguage);
Thread.CurrentThread.CurrentUICulture = new
CultureInfo(selectedLanguage);*/
}
base.InitializeCulture();
}