DNN的多语言支持 - Enabled multi language in DNN

一般情况下,我们如果需要支持多语言,就需要在安装多个语言包,这个是必须的。

同时,使用LanguageToken来切换不同的语言。

不过某些时候,我们需要自动切换语言。

 

比如有这样的菜单结构:

Home_EN

  About US_EN

  Contact US_EN

Home_CN

 About US_CN

 Contact US_CN

 

当我们点击Home_CN或者Home_EN的时候,就需要实现自动切换语言,要实现这个,可以在Default.aspx文件里面

方法:Page_Init

  
    
Dim ps As PortalSettings = PortalController.GetCurrentPortalSettings()
Dim Language As String = " en-US "
If ps.ActiveTab.TabName.ToLower().EndsWith( " cn " ) Then
Language
= " zh-CN "
' app.Request.QueryString["language"] = "zh-CN";
' Localization.SetLanguage("zh-CN");
' System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo(Language);
Threading.Thread.CurrentThread.CurrentUICulture = New CultureInfo(Language)
Threading.Thread.CurrentThread.CurrentCulture
= New CultureInfo(Language)

' System.Globalization.CultureInfo.CurrentCulture = new CultureInfo(Language);
' Localization.SetLanguage(Language)
Else
' Localization.SetLanguage("en-US");
' app.Request.QueryString["language"] = "en-US";

Threading.Thread.CurrentThread.CurrentUICulture
= New CultureInfo(Language)
Threading.Thread.CurrentThread.CurrentCulture
= New CultureInfo(Language)
' System.Globalization.CultureInfo.CurrentCulture = new CultureInfo(Language);
' Localization.SetLanguage(Language)
End If

 

enjoy it.

你可能感兴趣的:(language)