Sign in to follow this  
mijapkos

[.net] .NET-software localization

Recommended Posts

I'm looking for a new way to localize .NET-software. Currently the method I use (which has inherited from VB-era) is to put a special character in front of every string I need to localize. Then I run a program which loops through the code, finds all the special characters, finds a counterpart from a text-file and then replaces the original text. This method works but it's not pretty. Requirements for the new method: a) I don't have to "code" the localization info, for example with properties. If I need to use MyProgram.LocalizeString("labelInMyMainForm"), it's too much. b) I can do the localization after completing program. No need to worry about it when I'm programming. See point a :) c) Is a good practice. Thanks for answers in advance.

Share this post


Link to post
Share on other sites
If you don't mind doing the localization in Visual Studio, you'll have a good resource table editor right there. A separate localization editor is also included, at least in Team System versions, that basically allows a non-programmer to translate a resource table without having Visual Studio installed. I don't remember if the license actually allows other people than the primary user to use the tools included, though.

Please ask for more info if needed - I've had my fair share of battles regarding localization, as my customers want both english and finnish user interfaces.

Do read up on MSDN about writing international software. They have great articles about the topics, with guidelines for best practices on the matter.

Share this post


Link to post
Share on other sites
Quote:
Original post by mijapkos
Requirements for the new method:

a) I don't have to "code" the localization info, for example with properties. If I need to use MyProgram.LocalizeString("labelInMyMainForm"), it's too much.

b) I can do the localization after completing program. No need to worry about it when I'm programming. See point a :)

c) Is a good practice.

Thanks for answers in advance.


a) What you don't want to do is what would be required for any localization method you use other than hard string replacement. The advantage of using a satellite assembly and loading the strings using MyProgram.LocalizeString(stringTag) is that you don't have to recompile your software in order to have the changed text take effect.

That said, it's use is usually along the lines of LocalizationAssemblyName.ResourceName. StringResources.ApplicationName, StringResources.ApplicationAuthor, etc. To me it's not much more burdensome than using string variables in place of constants, an activity I avoid when I can anyway.

(Localization resources can generally be thought of as implemented in a dictionary form, where the key is a language and identifier.)

b) Completing this requirement would be fairly easy if you decided to run with satellite assemblies, but you'd be in violation of (a). Visual Studio serves as a resource editor fairly well, and there are plenty of third party resource editors available if you don't want to pay the Visual Studio licensing fees.

c) I haven't done enough localization to know what works and doesn't work in the long run, with multiple people working on the same project and maintaining it, so I bow out of this one. :)

Share this post


Link to post
Share on other sites
Create a function called i18n that takes a string parameter and returns a localized string.
Wrap all strings that need to be localized with that function.

Inside that function dynamically load a hashtable by using a file of conversion dictionary of equivelant phrases from the enlish key that was passed in and provides the result in the localized language.

English to German
"Hello, how are you {0}", "Guten Tag {0}, Wie geht es ihnen?"
"Goodbye", "Auf Wiedersehen"

I find that this method is the most flexible, and will work for most scenarios.

Another caveat to keep in mind during localization is that words in different languages will take up different amounts of space.

I try to leave enough space for at least about 10 or 15 extra characters of text before overlapping visual elements occurs.

Also keep in mind that some langauges read from left to right.

Share this post


Link to post
Share on other sites
Quote:
Original post by BradSnobar
I find that this method is the most flexible, and will work for most scenarios.

Except possibly the one where you want the localized string to actually be correct. [lol]

Share this post


Link to post
Share on other sites
Quote:
Original post by BradSnobar
Create a function...

.NET already has a massive framework in place for doing globalization. "Educational purposes" is pretty much the only (and it's feeble) excuse you could have for reinventing the wheel here.

I'm with gwihlidal.

Share this post


Link to post
Share on other sites
I looked at the available methods (satelite assemblies and the like) and did not like the fact that they would be difficult to maintain in the long term. Though, it should be noted that there are some good products available to help manage the maintainance process. They however were not free, unlike my time spent coding up a solution, which is free for me.

Though, I also admit to having a curiosity into how it worked under the covers, so you are also partialy correct in assuming the educational motive.

I also admit that files of text definitions can be difficult to maintain too. I plan on creating a tool to help me do this too.

I guess it just came down to a matter of preference, and whether I have time enough to implement something like that.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this