在我的项目中,我需要插入多语言选项 但是我不知道为什么我的项目默认文化是en-US 我添加了3种语言资源文件,但它只知道Default.aspx.resx和Default.aspx.en.resx 但是我还有2个其他资源文件,分别是Default.aspx.tr.resx和Default.aspx.fa.resx 并在Global.asax文件中将默认区域性设置为FA,但是当我启动我的项目时,它将使用EN区域性语言加载
这是我的课程
public class BasePage : Page
{
protected override void InitializeCulture()
{
//retrieve culture information from session
string culture = Convert.ToString(Session[Global.SESSION_KEY_CULTURE]);
//check whether a culture is stored in the session
if (culture.Length > 0) Culture = culture;
//set culture to current thread
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(culture);
Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture);
//call base class
base.InitializeCulture();
}
}
和
public struct Culture
{
//Iran - definition
public const string FA = "fa-IR";
//English - definition
public const string EN = "en-US";
//Russian - definition
public const string TR = "tr-TR";
}
和
public struct Global
{
public const string SESSION_KEY_CULTURE = "culture";
}
我比使用此功能来更改文化语言还低3个标志
protected void RequestLanguageChange_Click(object sender, ImageClickEventArgs e)
{
ImageButton senderLink = sender as ImageButton;
//store requested language as new culture in the session
Session[Global.SESSION_KEY_CULTURE] = senderLink.CommandArgument;
//reload last requested page with new culture
Server.Transfer(Request.Path);
}