views:

52

answers:

1

Localization/Globalization is pretty easy in Visual Studio using RESX files. I just add a resource file, like MyTextSnippets.resx, add key/value pairs, and create copies for every language I'd like to support like MyTextSnippets.de.resx, MyTextSnippets.fr.resx etc.

Now think of longer texts, where the String resource editor grid doesn't work very well. No problem, just choose "Add Resource | Add New Text File" from the designer, and you can edit as many text files as you want. Example: I add MyTemplates.resx, and to this RESX I add a file called SomeEmailTemplate.txt. Works fine so far, however when a create a copy of the resx file, say MyTemplates.de.resx, and open SomeEmailTemplate.txt from there, it will open always the same file. If you look at the details, the text file will not be embedded in the resx container, but it is created in a global folder "Resources", and the resx files just hold a reference, all to the same file.

I can't figure out how to localize it. Any idea?

Of course, I could embed add a text file for every language, and at runtime, enumerate the available text files and try to find the best match for UI culture of the current thread. However this doesn't feel right, as all that magic is available out of the box for strings and designer properties.

+1  A: 

Create a folder for each localized language you want, place the respective txt file in the folder and reference that.

Read about globalization/localization best practices here.

Oded
Great, referencing previously created files instead of adding them via the resx designer did the trick. Now it seems obvious. Thank you!
markus