Search code examples
.netlocalizationembedded-resourceresx

Changing application culture changes the capitalization of resource strings


I have an application which parses xml documents. I store the expected xml tag names in an RESX file. The first letter of the tag name is always lowercase. This works fine (and has done for several years) for my default culture of en-IE.

I've been building an application which will also run the pt-BR culture.

The code works in en-IE. But when I change the culture to pt-BR it is failing because when it retrieves the tag names using My.Resources.ParameterCollectionTag the first letter is now capitalized and thus the tag cannot be found in the xml document.

There is only one resource file, it is not localized itself. I've debugged into the Resources.Designer.vb file and resourceculture in the property

    Friend ReadOnly Property ParameterCollectionTag() As String
        Get
            Return ResourceManager.GetString("ParameterCollectionTag", resourceCulture)
        End Get
    End Property

is set to nothing. The CurrentThread.CurrentCulture though is set to pt-BR.

To be clear, My.Resources.ParameterCollectionTag returns 'paramters' in en-IE and 'Paramters' pt-BR.

I'm new to localization and am stuck at this point. Is there a way to turn off this behavior. I want the ResourceManager to return the strings exactly as theyare in the RESX file.

Any tips would be gratefully received.

Thanks for you time.


Solution

  • As a work around I am setting My.Resources.Culture = New CultureInfo("en") before I start to use My.Resources.