2012-04-23 51 views
0

我一直在尋找一個政黨成員使用RESX但我只發現了一些在RESX取決於本地化(和瀏覽器的語言)。如何使用RESX與可變測試

如何告訴我的應用程序在特定變量具有特定值時使用某個resx。 例如,我想在xyz = 1時使用default.aspx.de.resx。

Thanx提前

編輯: 我聽說過有覆蓋InitializeCulture的問題。 該解決方案將是:

Public Class FormBase 
Inherits Page 

Protected Overrides Sub InitializeCulture() 
    Dim selectedLanguage As String 

    Select Case Master.LanguageID 
     Case 1 
      selectedLanguage = "fr-BE" 
     Case 4 
      selectedLanguage = "nl-BE" 
     Case 5 
      selectedLanguage = "en-GB" 
     Case 6 
      selectedLanguage = "de-DE" 
     Case Else 
      selectedLanguage = "fr-BE" 
    End Select 

    UICulture = selectedLanguage 
    Culture = selectedLanguage 
    Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(selectedLanguage) 
    Threading.Thread.CurrentThread.CurrentUICulture = New CultureInfo(selectedLanguage) 

    MyBase.InitializeCulture() 
End Sub 

末級

然後在aspx.vb:

部分類默認 繼承FormBase

我怎麼能訪問Master.LanguageID在這個班?

回答

1

嘗試在代碼重寫InitializeCulture頁的後面。

protected override void InitializeCulture() 
{ 
    if (Request.QueryString["xyz"] == "1") 
    { 
     String selectedLanguage = "de-DE" 
     UICulture = selectedLanguage ; 
     Culture = selectedLanguage ; 

     Thread.CurrentThread.CurrentCulture = 
      CultureInfo.CreateSpecificCulture(selectedLanguage); 
     Thread.CurrentThread.CurrentUICulture = new 
      CultureInfo(selectedLanguage); 
    } 
    base.InitializeCulture(); 
} 

問候。

+0

你必須將代碼轉換爲vb.net – 2012-04-23 10:58:16

+0

感謝名單!我會嘗試的! – blop 2012-04-23 11:20:34