locked
Welsh - almost there, but not quite RRS feed

  • Question

  • User1826275489 posted

    I think I have almost cracked the addition of the Welsh culture, but I am missing something (probably obvious).

    I have added the culture like this:  

            Dim culture As String = "cy"
            Dim name As String = "Welsh"
    
            Dim cultureInfo As CultureInfo = New CultureInfo("en-GB")
            Dim regionInfo As RegionInfo = New RegionInfo(cultureInfo.Name)
            Dim cultureAndRegionInfoBuilder As CultureAndRegionInfoBuilder = New CultureAndRegionInfoBuilder(culture, CultureAndRegionModifiers.None)
    
            cultureAndRegionInfoBuilder.LoadDataFromCultureInfo(cultureInfo)
            cultureAndRegionInfoBuilder.LoadDataFromRegionInfo(regionInfo)
    
            ' Custom Changes 
            cultureAndRegionInfoBuilder.CultureEnglishName = name
            cultureAndRegionInfoBuilder.CultureNativeName = name
    
            cultureAndRegionInfoBuilder.Register()

    I have three resources files:

    • xxxxx.resx
    • xxxxx.cy.resx
    • xxxxx.hi.resx

     

    With my browser (IE) set to en-GB, I see values from xxxxx.resx, exactly as I'd expect.  If I set my browser to hi-IN then I see values from xxxxx.hi.resx, again as expected.  If I set the browser to cy-GB then I see values from xxxx.resx - which is not what I want.  However, if I change the Welsh filename to xxxxx.cy-GB.resx then everything works as expected.

    So, in short, hi-IN is doing what I'd expect and falling back to the neutral hi culture.  cy-GB does not seem to be falling back to cy in the same way.

    I'm guessing that I have missed something when I was creating the Welsh culture, and would welcome a pointer.

    Thanks,

    Nick


     

     

    Monday, June 28, 2010 4:56 PM

Answers

  • User-1265901611 posted

    Hi Nick,

    If I understand the problem correctly you are running the web application on an operating system which does not support the cy-GB culture. You are trying to create a cy culture and were expecting that cy-GB would fallback to your cy custom culture. If this is correct then the problem lies in the fact that your operating system does not have a cy-GB culture. The fallback mechanism in ResourceManager simply asks the culture what its parent culture is. The problem is that there is no cy-GB culture on your operating system so it never gets as far as asking it what the parent of cy-GB is. You feel that the parent should by cy but this is only a naming convention - the CultureInfo hierarchy can have any number of arbitrary levels of parents and it is only related to the naming convention by, well, convention.

    The solution to your problem is either to use an operating system that does support cy-GB (preferably) or else call your culture cy-GB instead of cy or else create two custom cultures: cy and cy-GB where cy-GB's parent is cy.

    If you really cannot use an operating system that supports cy-GB then I recommend exporting it from one that does (e.g. Windows XP Professional SP 2 and above) as opposed to building one using the code you have shown. The code to export a culture from an operating system is available at http://www.dotneti18n.com/downloads.aspx but it is fairly easily written anyway. Note that if you do this you must change the sortName and the textInfoName in the resulting LDML file from "cy-GB" to something like "en-GB" (using, say, notepad) because the target operating system will obviously not recognise cy-GB.

    Good luck.

    Guy

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, July 4, 2010 5:47 PM

All replies

  • User-319574463 posted

    I suggest that you look up Guy Smith-Ferrier see http://guysmithferrier.com/

    He is the expert on Internationalisation.

    Saturday, July 3, 2010 1:45 AM
  • User-1265901611 posted

    Hi Nick,

    If I understand the problem correctly you are running the web application on an operating system which does not support the cy-GB culture. You are trying to create a cy culture and were expecting that cy-GB would fallback to your cy custom culture. If this is correct then the problem lies in the fact that your operating system does not have a cy-GB culture. The fallback mechanism in ResourceManager simply asks the culture what its parent culture is. The problem is that there is no cy-GB culture on your operating system so it never gets as far as asking it what the parent of cy-GB is. You feel that the parent should by cy but this is only a naming convention - the CultureInfo hierarchy can have any number of arbitrary levels of parents and it is only related to the naming convention by, well, convention.

    The solution to your problem is either to use an operating system that does support cy-GB (preferably) or else call your culture cy-GB instead of cy or else create two custom cultures: cy and cy-GB where cy-GB's parent is cy.

    If you really cannot use an operating system that supports cy-GB then I recommend exporting it from one that does (e.g. Windows XP Professional SP 2 and above) as opposed to building one using the code you have shown. The code to export a culture from an operating system is available at http://www.dotneti18n.com/downloads.aspx but it is fairly easily written anyway. Note that if you do this you must change the sortName and the textInfoName in the resulting LDML file from "cy-GB" to something like "en-GB" (using, say, notepad) because the target operating system will obviously not recognise cy-GB.

    Good luck.

    Guy

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, July 4, 2010 5:47 PM
  • User1826275489 posted

    Guy,

    Thanks for the comprehensive reply - it has helped me and will no doubt help others in the future.

    My mistake was the simple and obvious (now) one of assuming that the relationship between cy-GB and cy was implicit in the name.

    Oddly, I am developing on XP Professional SP3 which, from what you have said, should already have the Welsh cultures - so a bit odd that ASP .NET was falling over at compilation time as soon as I included an xxxxx.cy-GB.resx file.  However, it does explain why my target box running W2003 didn't have any issues.  Hence, I had a problem in development which was not an issue in live (it's not usually that way round!).

    I have also persuaded .NET to display Bengali screens with the rather odd culture of bn-GB - Bengali language, but everything else in standard  UK formats.

    I think I'm getting the hang of it now!

    Thanks again for the help, Guy.

    Nick

    Tuesday, July 6, 2010 12:09 PM
  • User-1265901611 posted

    Hi Nick,

    No problem - glad I could help.

    A thought occurs to me. I'm assuming that the Bengali (United Kingdom) culture is a custom culture that you have created. It isn't always quite as straight forwards as you would like to create custom cultures by combining regions and languages. You might like to compare your code for creating this custom culture with my code in CultureAndRegionInfoBuilderHelper.CreateCultureAndRegionInfoBuilder() (from http://www.dotneti18n.com/downloads.aspx). I only mention this because it can be tough to identify all of the properties that should come from the original RegionInfo and CultureInfo.

    Guy

    Tuesday, July 6, 2010 1:01 PM
  • User1826275489 posted

    Guy,

    Thanks for the further information - much appreciated.

    I have now found the sample chapters of your book and, suffice to say, a pristine copy of the real thing is now on its way to me courtesy of Waterstones.com.

    Thanks, again.

    Nick

    Sunday, July 11, 2010 3:50 PM
  • User-1265901611 posted

    You're very welcome, Nick.

    Guy 

    Wednesday, July 14, 2010 9:31 AM