locked
Custom Culture Not Working RRS feed

  • Question

  • User223078540 posted

    I have a web forms bilingual application. 

    users can switch between English and Spanish languages using a combo box.

    I have files Strings.resx and Strings.es.resx to provide the English and Spanish texts.

    Now I need to add support for a local native tongue: Miskitu.

    I created and registered a custom culture as per http://msdn.microsoft.com/en-us/library/ms172469.aspx. I loaded my custom culture data from Region "NI" (Nicaragua) and then changed values for:

    TwoLetterISOLanguageName = "mu"
    ThreeLetterISOLanguageName = "mku"
    CultureEnglishName = "Miskitu"
    CultureNativeName = "Miskitu"

    I chose "mu" and "mku" for the ISO names because they are not used anywhere in the ISO definition and it has no values defined for the Miskitu tongue.

    I called my custom culture mu and after registering it, a "mu.nlp" file appeared under C:\Windows\Globalization

    I added to my solution a Strings.mu.resx file

    When I select Miskitu in the combo box:

    CurrentUICulture is set to "mu".

    If I query Thread.CurrentThread.CurrentUICulture after selecting miskitu in the combo box, I get:
    {mu}
        Calendar: {System.Globalization.GregorianCalendar}
        calendar: {System.Globalization.GregorianCalendar}
        CompareInfo: {CompareInfo - es-NI}
        compareInfo: {CompareInfo - es-NI}
        CreatedDomainID: 2
        cultureID: 127
        CultureTypes: SpecificCultures Or UserCustomCulture {10}
        CurrentCulture: {es-NI}
        CurrentUICulture: {mu}
        DateTimeFormat: {System.Globalization.DateTimeFormatInfo}
        dateTimeInfo: {System.Globalization.DateTimeFormatInfo}
        DisplayName: "Miskitu"
        EnglishName: "Miskitu"
        HasInvariantCultureName: False
        IetfLanguageTag: "mu"
        InstalledUICulture: {en-US}
        InvariantCulture: {}
        IsNeutralCulture: False
        IsReadOnly: False
        IsSafeCrossDomain: True
        IsTaiwanSku: False
        KeyboardLayoutId: 1033
        LCID: 4096
        LOCALE_CUSTOM_DEFAULT: 3072
        LOCALE_CUSTOM_UNSPECIFIED: 4096
        LOCALE_INVARIANT: 127
        LOCALE_NEUTRAL: 0
        m_cultureData: {System.Globalization.CultureData}
        m_dataItem: 0
        m_isInherited: False
        m_isReadOnly: False
        m_name: "mu"
        Name: "mu"
        NativeName: "Miskitu"
        NumberFormat: {System.Globalization.NumberFormatInfo}
        numInfo: {System.Globalization.NumberFormatInfo}
        OptionalCalendars: {Length=1}
        Parent: {es}
        regionInfo: Nothing
        SortName: "es-NI"
        TextInfo: {TextInfo - mu}
        textInfo: {TextInfo - mu}
        ThreeLetterISOLanguageName: "mku"
        ThreeLetterWindowsLanguageName: "ESI"
        TwoLetterISOLanguageName: "mu"
        UserDefaultCulture: {en-US}
        UserDefaultUICulture: {en-US}
        UseUserOverride: True

    My problem is that the texts appear in English (the User Default UI Culture) and not in Miskitu. My Strings.mu.resx file is ignored.

    Can anyone tell me what my mistake is?

    Thank you very much.

    Friday, December 3, 2010 7:26 PM

Answers

  • User2130758966 posted

    Its possible that because your browser is set to english it is overriding your settings.

    You can force asp.net to ignore this by setting enableClientBasedCulture to false in the <globalization> tag.

    • http://msdn.microsoft.com/en-us/library/hy4kkhe0.aspx


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, December 4, 2010 8:11 AM
  • User223078540 posted

    Thank you again rtpHarry,

    My bad. It is working now. I had a bug in my code.

    So, to add a custom culture to a web forms application you have to:

    Create and register a custom culture as per http://msdn.microsoft.com/en-us/library/ms172469.aspx.

    Load the custom culture data from an existing Region ( for example "NI", Nicaragua) and then change values for:

    TwoLetterISOLanguageName = "xx"
    ThreeLetterISOLanguageName = "xxx"
    CultureEnglishName = "CustomTongue"
    CultureNativeName = "CustomTongue"

    If the ISO definition has no values defined for your custom culture tongue, choose a TwoLetterISOLanguageName (xx in my example) and ThreeLetterISOLanguageName (xxx in my example) that are not used anywhere in the ISO definition.

    Call your custom culture as the TwoLetterISOLanguageName (to use the same code naming as the standard cultures) and register it, a "xx.nlp" file will appear under C:\Windows\Globalization

    Add to your solution a Strings.xx.resx file containing the texts translated into your custom culture tongue.

    And you're done!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, December 4, 2010 11:17 AM

All replies

  • User2130758966 posted

    Its possible that because your browser is set to english it is overriding your settings.

    You can force asp.net to ignore this by setting enableClientBasedCulture to false in the <globalization> tag.

    • http://msdn.microsoft.com/en-us/library/hy4kkhe0.aspx


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, December 4, 2010 8:11 AM
  • User223078540 posted

    Thank you for your post rtpHarry,

    The fact that switching between English and Spanish works fine makes me think this will not be the answer.

    It's the custom culture the one not working.

    I'll try your suggestion and let you know.

    Saturday, December 4, 2010 8:29 AM
  • User223078540 posted

    Thank you again rtpHarry,

    My bad. It is working now. I had a bug in my code.

    So, to add a custom culture to a web forms application you have to:

    Create and register a custom culture as per http://msdn.microsoft.com/en-us/library/ms172469.aspx.

    Load the custom culture data from an existing Region ( for example "NI", Nicaragua) and then change values for:

    TwoLetterISOLanguageName = "xx"
    ThreeLetterISOLanguageName = "xxx"
    CultureEnglishName = "CustomTongue"
    CultureNativeName = "CustomTongue"

    If the ISO definition has no values defined for your custom culture tongue, choose a TwoLetterISOLanguageName (xx in my example) and ThreeLetterISOLanguageName (xxx in my example) that are not used anywhere in the ISO definition.

    Call your custom culture as the TwoLetterISOLanguageName (to use the same code naming as the standard cultures) and register it, a "xx.nlp" file will appear under C:\Windows\Globalization

    Add to your solution a Strings.xx.resx file containing the texts translated into your custom culture tongue.

    And you're done!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, December 4, 2010 11:17 AM