Localizing a LightSwitch Application (Heinrich Wendel)

Localizing a LightSwitch Application (Heinrich Wendel)

Rate This
  • Comments 13

With Visual Studio Update 2 we finally added a functionality a lot of you (especially outside the US) have been waiting for, the localization of LightSwitch applications into multiple languages. Until then you had to hardcode a single language into your application. Finally, international companies and companies that are located in countries that use multiple official languages, can provide users with an application in their preferred language.

The concept is simple. For each DisplayName or Description property that you want to localize, you specify a $(ResourceString) instead of the actual string. For each translation, you create a resource file which contains the actual values in the target language. At runtime, we will automatically detect the preferred language based on the user’s browser or operating system setting. In addition to that, strings that you specify on the server, e.g. names for entities or properties, are also propagated to the client, no need to translate them twice. And, you can also localize messages that are created while running business logic on the server or validation rules on the client.

We already published a walkthrough on MSDN which gives you a detailed step by step description. But, there is only one language that everybody in the world understands. It is the language of pictures. I tried to create a visual walkthrough for you guys. Click the picture bellow to start your localization experience (it might take a while to load, there are quite a few pictures in it).


For some reason it doesn’t work as expected, your see strings like “/client/ErrorMessage” or “$(ContactPhone)” in the UI? As so often, the devil lies in the details. In the last part of this blog post I’ll try to summarize the questions and problems that came up most often in our forums:

  • What are valid keys for resource identifiers? You should only use letters and numbers for resource identifiers. Don’t use spaces and to be absolutely safe stay away from any special characters.
  • What is the naming convention for Server resource files? The server project uses “Service.resx” (Service, not Server Smile) for the neutral translations and “Service.LocaleID.resx” for individual languages. Those files live in the root folder of the server project.
  • What is the naming convention for Silverlight resource files? The Silverlight client uses “Client.resx” for the neutral translations and “Client.LocaleID.resx” for individual languages. Those files live in the root folder of your Silverlight client project.
  • What is the naming convention for HTML resource files? For the HTML client use “client.lang-LocaleID.resjson” for all languages. Simply use the appropriate locale id for the neutral language. Those files live in the “Content/Resources” folder of your HTML client project.
  • Where do I specify the neutral language? You can specify the neutral language in your project properties. It defaults to your Visual Studio language when creating a new project.
  • Why are the naming conventions for HTML and Silverlight/Server different? We tried to follow the conventions of the technologies the individual projects are based on. For the Server and Silverlight we use the .NET conventions and resx files, for HTML we are following the WinJS naming conventions using resjson files.
  • How does the language detection mechanism work? If you run a Silverlight application we will use the user’s Windows language as preferred language. If you run an HTML app we will use the browser setting.
  • Can I present users with a choice of languages? Not at the moment, sorry. Usually it is pretty easy to change the language of your browser though and you can also change the language of Windows on a per user basis.
  • How does the server know about the client’s language? With every HTTP request your browser sends the client language as part of the ACCEPT_LANGUAGES header. ASP.NET will run the thread that is processing the request using the culture specified by the header.
  • My client shows the raw resource strings, what is wrong? Did you translate both your client and server into the specific language? We will only pick up a language if both projects actually provide translations, otherwise users could end up with a mix of languages in their UI.

That’s it

I tried to keep it a bit shorter this time. As always, use the comments section and our forums for feedback and questions.

- Heinrich Wendel, Program Manager LightSwitch

Leave a Comment
  • Please add 7 and 3 and type the answer here:
  • Post
  • Heinrich,

    Vielen dank !

  • ich bin zwar Engländer, wohne aber im Markgraeflerland. Bin auch 60 Jahre alt !... keep up the great work.

  • I really like the Parallax Scrolling. It really helped me quickly grasp your message. I will try to start doing that too!

  • This is a major step. Thanks!

  • Yes, LightSwitch Team, you all make it again, BRAVO and  Cheers!

    This is what I have been wait for... Thank You, 谢谢(Chinese), Terima Kasih(Malay),...

  • How can I localize the OOB validation messages that LS gives?

  • Hello,

    Thanks for the LightSwitch Develop Team.   The Localizing feature is Good but would it also possible to localize the navagator group?  I have tried $(Task) but failed :<

  • Wonderful , but I have a question , is it valid for desktop version -not html based- ? because i have a desktop project that run as web application can I apply this solution on my project?

  • Hi Amhed,

    Yes the same techniques apply to localize the Silverlight client.




  • I have developed a light switch html client application in Visual Studio 2013 and tried to localize it using the walkthrough (Currently I am in  stage where I can see Arabic when the language is changed in the browser settings). I want the app to support English and Arabic. I have two questions.

    1> Is it possible for the User to select a language  (not from the browser settings) but from a button in the application and we do it programmatically?.

    2>If yes, How do I change also the direction from LTR to RTL on the fly , when the user selects Arabic.


  • @samit - No, I'm sorry but this is not possible. The language of the application is read from the browser.

  • Hi!

    It's a pity but above heiwen.azurewebsites.net/loc reply

    Error 403 - This site is stopped.

    The web site you have attempted to reach is currently stopped and does not accept any requests. Please try to reload the page or visit it again soon.

    If you are the Administrator of this web site, please visit the Azure Portal to check why the site is stopped.

  • It is worth noting that when naming resjson files for the Russian language LocaleID "ru" should be used instead of "ru-RU" (client.lang-ru.resjson), otherwise you'll have something like $(client/add) on HTML screen.

Page 1 of 1 (13 items)