Runtime Globalization-Localization Support for Silverlight 3

by nickindarsingh 14. June 2009 19:48

1.)  Modify the Silverlight project file (I prefer to do this in a simple editor).  Modify the SupportedCultures element by adding the language-culture information as shown:

    1 <SilverlightApplication>true</SilverlightApplication>

    2 <SupportedCultures>en-US;en-CA;fr-FR;hi</SupportedCultures>

    3 <XapOutputs>true</XapOutputs>

In this example, we are going to support (in addition to the base language) en-US (US English), en-CA (Canadian English using Region instead of State and Postal Code instead of Zip Code), fr-FR (the french language in France) and finally, Hindi which is a Unicode font making our sample more illustrative of the challenges of globalization that can happen.  Notice too that it's not necessary to include the culture.  We need the culture information for en-US and en-CA since they both use English; however, we can simply use hi for Hindi (हिन्दी) support (across all countries) without the IN country code.

2.)  Add a single resource file - do not follow the temptation to add the additional language resource files.  Its FAR easier to copy the base language file when you are ready to implement multi-languages and rename it as needed (i.e. localization.en-US.resx).

3.)  Localize your app.  This means removing all hard-coded string references (i.e. ... = "Address") to localized equivalents.  This can be simply something like ... = localization.CON_Address where localization is the namespace representing my base localization.resx file and CON_Address is a property defined therein.  I generally prefer to support runtime M-V-VM approaches to large Silverlight projects, so I usually create a Model representing my language resource.  Since I am also VERY lazy when it comes to repetitive labor, I have created a spreadsheet in Excel where I simply copy everything from the Visual Studio resource editor of the localization.resx file into my spreadsheet which creates the properties and declarations that I can then use for binding (I use a three letter category designator, a single underscore and then a meaningful name - you can modify as you need). I have included it here [CreateDeclarationsAndProperties.xls (434.00 kb] if you like this approach, it is certainly NOT required.  But this approach means you can then use XAML binding instead of the hard-coded approach, i.e. ...="{Binding Address}" where the DataContext is the localization model.

NOTE:  As a best practice, I generally prefer when writing applications that I know will be localized to add a lower case z in front of all user-facing text, i.e. zAddress.  This forces me to remember to localize such text before general release.

4.)  Get translations.  Now if you are like me, you know that machine translations are a poor substitute and that you cannot release your application into the wild using such translations.  However, since true translations can take time, and you might like to get a sense of how the application appears in the language as you are designing it, using machine translation can make this very easy.  I thus wrote a quick utility to call Google translate to do the hard work for me.  Although it is NOT required, it can quickly illustrate how your application will appear in the specified language.

 

 

Tags: , ,

Comments

1/22/2010 2:04:17 PM #

what is dual diagnosis

Hey thanks for posting this article. I have been looking out for some intellligent & quality articles on this topic. I went through some posts which have the same theme but the conclusion is irrelevant. Keep posting such updates.

what is dual diagnosis United States |

2/19/2010 3:34:50 AM #

stock trading

I would like to use some of your content for my website. Please let me know if I can do so if I link back to this page.

stock trading United States |

2/19/2010 10:10:07 AM #

Daniel Millions

I wasn't sure where to ask this but I would like to include your website to one of my directories. Please drop me a line me at your convience because I will only list webistes with the owners consent - thank you.

Daniel Millions United States |

3/2/2010 6:38:25 AM #

payday loan

Do have some sort of email system where I can get your blog posts emailed to me?

payday loan United States |

3/3/2010 12:30:03 AM #

stock trading

Please let me know if you are looking for a writer for your blog. You have some good content and I think I would be a good asset.

stock trading United States |

3/3/2010 8:44:03 AM #

bad credit loans

Great blog it's not often that I comment but I felt you deserve it.

bad credit loans United States |

3/3/2010 7:08:02 PM #

watch movies online free

I love watching movies online, it is way cheaper than going to the theaters.

watch movies online free United States |

3/3/2010 8:13:32 PM #

acai berry review

Give yourself something to work toward - constantly.

acai berry review United States |

3/3/2010 9:32:34 PM #

Alfredo Mital

Amazing site, where did you come up with the info in this piece of writing? I'm pleased I found it though, ill be checking back soon to see what other articles you have.

Alfredo Mital United States |

3/5/2010 7:28:02 PM #

WoW Mobiles

Is tethering against the Terms of Service of mobile phone companies? Which ones allow it?

WoW Mobiles United States |

3/8/2010 12:25:16 AM #

how to fix a slow computer

Hi, Thanks. I was going through the same issue. Solved now Regards.

how to fix a slow computer People's Republic of China |

3/9/2010 9:16:39 PM #

Tom McEnery

yo mama is so fat you could use her bellybutton as a wishing well......

Tom McEnery United States |

3/10/2010 8:21:45 PM #

Billie Ganer

I have read a few of the articles on your website now, and I really like your style of blogging. I added it to my favorites blog list and will be checking back soon. Please check out my site as well and let me know what you think.

Billie Ganer United States |

3/14/2010 4:54:44 PM #

Private Loan Consolidation

Look forward to studying additional from you inside the future.

Private Loan Consolidation Austria |

3/14/2010 5:31:22 PM #

Galan

I've heard that placing advertisements on a person's website earns them revenue. In other words money for the owner. Is this true for you and every other site that display advertisements?

Galan United States |

3/15/2010 7:41:23 AM #

modern beds

Thanks for sharing this kind of informative post. Definite a lot of web devveloper are really happy with this post.

modern beds United States |

3/16/2010 9:31:26 AM #

free wow card

Amazing! Thanks a ton! I always desired to generate in my web page something similar to that. Can I quote portion of your post to my blog?

free wow card United States |

3/16/2010 11:54:37 AM #

reverse cell phone look up

Interesting post Smile However, some of the comments people have made above are questionable, will think  more in depth and get back later

reverse cell phone look up India |

3/16/2010 10:27:45 PM #

Emil Quaranto

This is a outstanding post, but I was wondering how do I suscribe to the RSS feed?

Emil Quaranto United States |

3/17/2010 2:46:22 AM #

tips of acne

I just couldnt leave your web site prior to saying that I really liked the quality info you provide to your visitors. Would be back usually to check up on new information in you post!

tips of acne People's Republic of China |

3/18/2010 3:28:35 PM #

Jamorama

hopefully this post doesn't appear several times (it seems to freeze once i try to post my comment.. not sure if it's actually posting), but all I really wanted to say was great post and thanks for sharing.

Jamorama United States |

3/19/2010 1:09:44 PM #

Chelsey Chuyangher

Hi I just wanted to find out on what is the difference between blogenenigne and wordpress blogs? Is it easier to use or more efficient? I amseeing a lot of blogs powered by this software popping up lately and wondering if it is better or not? Thanks...

Chelsey Chuyangher United States |

3/19/2010 6:29:33 PM #

penny stocks

I didn't see a link anywhere but do you offer advertising? I have a few in related niche and I would like to add my banner somwhere on your webiste.

penny stocks United States |

3/20/2010 2:38:06 AM #

personal loans for people with bad credit

Just wanted to say that you have some awesome content on your blog. If it's allowed I would like to use some of the information you provided on my blog. If I link back to your website do I have your permission to do so?

personal loans for people with bad credit United States |

3/20/2010 1:27:09 PM #

Daniel Millions

Do you mind if I quote you on my website if I link back to your website?

Daniel Millions United States |

3/22/2010 11:22:55 AM #

Jackeline Saran

Very good piece, this is very similar to a site that I have. Please check it out sometime and feel free to leave me a comenet on it and tell me what you think. I'm always looking for feedback.

Jackeline Saran United States |

Comments are closed

Powered by BlogEngine.NET 1.5.0.7
Theme by Mads Kristensen

About Nickindar Singh

A software developer since the pyramids were built, I have had the good fortune of working with many wonderful people over the years at such companies as Microsoft, Coca-Cola, American Electric Power and British Airways among several others.  Having worked with .Net since its inception, I have more recently been involved with the development of numerous applications using Silverlight and XBAP with a strong focus on enterprise functionality. 

I am currently working with Motorola here in sunny northwest Florida developing and porting their 311 citizen software using a whole slew of web technologies while additionally creating new Android and iPhone applications for the same.

Month List

Page List