In general, if you need to support multiple languages, you need to install multiple language packs. This is required.
At the same time, use LanguageToken to switch between different languages.
However, in some cases, we need to switch the language automatically.
For example, the menu structure is as follows:
Home_EN
About US_EN
Contact US_EN
Home_CN
About US_CN
Contact US_CN
When you click Home_CN or Home_EN, You need to implement automatic language switching. To achieve this, you can go to the Default. aspx file.
Method: 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.