0

我一直在寻找使用 resx 的教程,但我只发现了一些 resx 取决于本地化(和浏览器的语言)的地方。

当某个变量具有某个值时,我如何告诉我的应用程序使用某个 resx。例如,当 xyz=1 时,我想使用 default.aspx.de.resx。

提前感谢

编辑:我听说覆盖 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?

4

1 回答 1

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();
}

问候。

于 2012-04-23T10:57:20.773 回答