Every new platform, every not mature platform has common set of problems and one of this problems are probably will be Internationalization (I18N) and Localization support. For big part of development world it's not problem - if you are write solely for your country or you speak in English - and so you may be never think about it. But if you speak in different language and think of broader market for your product - or just want to create UI in the same terms as domain model - I18N is your headache.
So if you think that Visual Studio is mature product - you are wrong - every mature development product must know of Localization problems and give you full set of tools to do it.
Localize Forms
Ok, Visual Studio Forms Designer give your ability to localize forms - it's good enough.
Just
- Set Form's (or Control) Localizable property to True
- Choose your language in Language property
- And in the form's design view translate all that your need.
And that's all - good.
But designed controls are not all strings in UI interactions. When you show messages to user or create control dynamic you also need localize UI.
How? By extract strings to resource (the same as Form Designer do for forms).
For instance - all major java IDE has ability for this:
IntelliJ IDEA: http://www.jetbrains.com/idea/features/i18n_support.html
But not Visual Studio!
With visual studio you don't have way to externalize your string to resources without many manual work... to present day.
Now we have two very good add-ins for it.
Resource Refactoring Tool
Resource Refactoring Tool is a free add-in for Visual Studio that gives your ability to extract hard-coded strings to resource.
Select text, from context menu select Refactor->Extract to Resource (or use Ctrl-R, Ctrl-X shortcut):
Than select resource file where you want to extract and refactor parameters:
So then you must copy your resource file to resource file for localization - for instance if you have Resources.resx you need to make copy with name Resources.ru.resx (where ru - is your language postfix - de, pl n etc.).
And then in Resources.ru.resx translate parameters to needed parameters.
Good enough.
One problem is that when you extract string to resource and you already have localized version of that resource - you must manually create new variable in localized file. For example with IDEA you don't need to do this:
safedevelop's RGreatEx
Another tool for that is Commercial plugin for other great development tool - Resharper (plugin for VS) - RGreatEx (30 Euros per license).
Why You need to buy commercial tool (and moreover - plugin for plugin) instead using free? I can't answer clearly - if you use Resharper or something like IDEA and understand how it sometimes differs (in a good sense) from other tools - you must try it. The bad thing about that for today it don't support latest Resharper and Visual Studio 2008 - I expect to update this post when it will be released.
The RGreatEx supports ReShareper 3.1 from the 1.0.3 version. For
ReplyDeleteinstalling RGreatEx under ReShareper 3.1 and VS2008 you should use
next command line:
msiexec /i RGreatExSetup.msi RESHARPERVERSION=3.1 VSVERSION=9.0
You can read about it in the Readme.txt in the setup package.
Thanks, Alexander, although from my point of view provide different download packages for appropriate version of host application is better.
ReplyDeleteAnd the problem is that RGreatEx didn't appear in resharper's plugin list. I have 3.1.584.3 build - don't remember - may be it's EAP version - I'll try again later.