10

I have an existing winforms application developed using VS 2005 and .net framework 2.0.

Now we need to globalize this application. The two locales are German and Japanese.

I know we can use form's localize property to create localized form resources and can have other resource files for strings used in message boxes, exceptions etc..

I want to know the best approach to globalize an existing application, should I set the localize property on each form or is there some tool which will extract the the label names and control names..what considerations to be taken for date formats, currency, etc.

Also we have used some composite strings in some places in code to concat the message strings, how these can be localized?

We will be migrating the application to VS 2008 and .net framework 3.5 before starting globalization activity.

MusiGenesis
  • 74,184
  • 40
  • 190
  • 334
ksa
  • 546
  • 1
  • 4
  • 20

4 Answers4

8

I've only worked with LTR languages, and I haven't touched Japanese. With that in mind, here are some of my best practices off the top of my head:

  • Put all language-specific programmatic strings and string fragments into a .resx file (I like to use one .resx file per dialog box), then call on the strings using the auto-generated classes and properties. There shouldn't be any language-specific strings remaining in your code (which means almost no strings in your code, period). A good pattern is to put formatting strings into the .resx as well, since the syntax of a language varies.
  • Set the Localizable property to True on all your forms and make language-specific changes on there directly (use the Language property).
  • Design your forms so that anything that displays language-specific strings will have extra space where needed (note: German is longer than English). IMO, forms should not have to be completely rearranged for a basic change in language -- it may have to be done with a language like Japanese, though.
  • For controls such as labels that need their text dynamically set, set the text on the form so that you know it's only a marker. I use "##" for this, which really stands out. Avoid setting the text to a "sample" of the dynamic text, because you'll never remember which controls get set dynamically by just looking at the form.
Jon Seigel
  • 12,251
  • 8
  • 58
  • 92
  • Thanks. I would like to know the maintainability and scalabity with this approach if some thing is changed or text needs to be modified in resource file.Or if I want to extend this to one more language, how it will be achieved if the application is already in production? Does it require re-compile and re-deployment. – ksa Oct 06 '09 at 11:47
  • With this approach, you would have to recompile and redeploy the main executable for both an addition and a change, yes. But you would have to redeploy _something_ with any simple multi-language implementation. I don't see this as a problem, because the language strings should be spelling/grammar checked far before it's released, and adding a new language that the client wants should be a relatively rare occurrence. – Jon Seigel Oct 06 '09 at 12:34
  • Addition of a new language support is required in our application. So if there is no change in application except the language, we can create a new .resx file , generate a satellite assembly and put it to the appropriate directory structure. This will not require re-compilation , Am I right? One more question is translation of user data entered , where and how to maintain this, if we have some data to be shared among users of different locales? – ksa Oct 07 '09 at 06:59
  • You'll have to do extra abstraction to retrieve strings from the satellite assemblies, but it should work the way you want. MSDN probably has some hints on this approach. You'll also need a mechanism to allow the user to select the language of choice from the ones available (or it would be in a config file). Translation of user data is a whole separate discussion, and you'll want to do some independent research based on your business needs. – Jon Seigel Oct 07 '09 at 12:48
2

It is better to set the localization property on each form -- that will extract not only the strings, but also the geometry of the various components, into the base .resx file. With the nominated languages, it is quite unlikely that the original sizes of the components will be a good fit for the translation.

It is generally not recommended to compose strings out of fragments because they in general will not map into the same pattern of fragments in a different language. Use of formatted strings (String.Format) to drop in values, yes, but anything that relies on the grammar and sentence order of the original language is unlikely to fit.

Steve Gilham
  • 11,237
  • 3
  • 31
  • 37
1

If you're using Visual Source Safe as your source control (hopefully you're not), whatever you do, do not add Japanese text inside your source code itself. Although Visual Studio can handle unicode source files, VSS does not handle them well.

I worked on an application that translated itself into Japanese, and the inclusion of Japanese within the source code itself (for calls to a MessageBox-like function) corrupted the files, and because VSS is diff-based, the files were corrupted all the way back to the original checked-in versions. This corruption took the form of most of the code files being turned into Japanese character-based gibberish, and occurred because VSS shifted portions of the unicode-based CS files (which used two bytes per character) off by one byte.

Fixing these files required a great deal of manual work, with my boss peering over my shoulder and screaming about how doomed we were, so just don't do this.

Also, here are a couple of other StackOverflow questions on this topic:

Best way to implement multi-language/globalization in large .NET project

Best practice to make a multi language application in C#/WinForms?

Personally, I prefer a simpler method. Create a list in Excel or something of every piece of English text in the application that you need to translate (control Text properties, strings to use in MessageBox functions etc.) and send the spreadsheets to your translators. In your application, call a method in the Load event of each of your forms that iterates through all the controls on the form and changes their Text properties to the translated values. Replace all calls to MessageBox with calls to an intermediate function that translates the text to be displayed, and then calls MessageBox with the translated text.

Using the built-in globalization methods is a lot of work, because you have to manually create each globalized form and then manually replace all the text with the translations, and this task pretty much requires the programmer to be fluent. The method I mention is done programatically, and doesn't require the programmer to be fluent in the translated languages.

Community
  • 1
  • 1
MusiGenesis
  • 74,184
  • 40
  • 190
  • 334
  • 1
    you should have screamed at your boss for not having a backup in place. scream at him in french even, with japanese subtitles. – Timmerz Sep 11 '12 at 20:24
  • We *did* have a backup in place - it was called "Visual Source Safe". I would never have expected anything like this to be able to corrupt a repository all the way back to the original checked-in file. – MusiGenesis Sep 11 '12 at 20:38
  • you obviously don't understand the concept of backup. – Timmerz Sep 12 '12 at 14:57
  • @Timmerz: do you really think it's sensible to conclude that a 17-year programming veteran doesn't "understand the concept of backup" based on a tossed-off comment? Or are you just practicing being a prick? Because I don't think you need the practice. – MusiGenesis Sep 12 '12 at 18:54
  • I would have you fired immediately. arrogant and not much sense. why don't you have a look at this link? http://support.microsoft.com/kb/244016 – Timmerz Sep 12 '12 at 19:49
  • As I said, you don't need the practice. – MusiGenesis Sep 12 '12 at 21:36
  • instead of dealing with the issue you sidestep it and simply attack me and fall back on your own resume. let me be real clear here...if you consider visual sourcesafe your backup and it gets corrupted like so, and you are unable to save it, you may have just completely destroyed a company. that's not a backup. I'm really trying to fathom how you can be so ignorant after 17 years. – Timmerz Sep 13 '12 at 15:08
  • I apologize for using "fancy italics", and for questioning your expertise about "the backup". Thank you for pointing out how much I still have to learn about this business. – MusiGenesis Sep 14 '12 at 12:38
  • lol. apology accepted! I saw you write something elsewhere about sql server backups, so I assume you do in fact know how to backup ;-) – Timmerz Sep 14 '12 at 15:09
0

If you want the community to localize for you use an external XML file. Look at http://www.codeplex.com/url2jpeg, this open source project is localized this way and uses Reflection for automatic form localization.

For string simply use hidden label.

Remi THOMAS
  • 854
  • 6
  • 11