Friday, October 10, 2014

How to do modern day globalization/localization/internationalization with .resx files.

I was wrong here where I suggest it is some really hard problem that you might as well not think about. Today my superior found this which explains:

 G11N  globalization (supporting different cultures)
 L10N  localization (customization to a specific culture)
 I18N  internationalization (both of the above)

Following the advice in the blog posting my superior shared, I made, in an existing ASP.NET solution, a new "Class Library" type project called "Resources" and added four .resx files to it named like so:

  1. Copy.de.resx
  2. Copy.es.resx
  3. Copy.fr.resx
  4. Copy.resx

The accessibility modifier needs to become "Public" for each of these. If you open up one of these files in Visual Studio you will see a dropdown menu labeled "Access Modifier" for changing the setting running across the top of the pane holding the opened file. Clearly, Copy.resx is the catch-all which will catch almost all and the other three files are for German, Spanish, and French language support. I made another project inheirt the "Resources" project and in the other project (ASP.NET MVC) I was able to summon copy out of the resources like so:

string whatever = Resources.Copy.Whatever;

 
 

Moreover, I was able to experiment with retrieving the result for a specific culture like so:

Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr");
string whatever = Resources.Copy.Whatever;

 
 

While we are talking about reading and accessibility, this is my first blog posting since Malala Yousafzai has won the Nobel Peace Prize overnight. Kudos to her.

There is something pessimistic in me that is waiting for her to fall over dead from the bullet to the head that she has supposedly fully recovered from. Perhaps she'll have trouble later in life. Then again, perhaps she'll upstage all of my cynicism too and be a smiling face with us for another sixty or seventy years. I am grateful for the "day in the sun" she is having today. She's the youngest person ever to win the Nobel Peace Prize! She does share it this year with a Mr. Kailash Satyarthi who has been working to stop child labor abuses in India. I recall that there was an upset last year when the Organisation (British spelling, not Americanized "organization") for the Prohibition of Chemical Weapons or OPCW won the award instead of Malala... but the Nobel Prizes are not the Academy Awards where one has to impress in the most immediate year to be a nominee, so... it's her day ladies and gentlemen.

No comments:

Post a Comment