Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a better way of managing localized strings?

I work on a product where we have to worry a bit about localization. Currently, this is the workflow for when I have to use(or add) a localized string:

  1. Search resources.resx file(which has hundreds of items)
  2. If found, then copy the name. Otherwise, add a new string and copy the name
  3. Then, use ResourceFactory.ResourceMgr.GetString("MY_MAGIC_STRING") (where ResourceMgr is just a static field to a ResourceManager)

This 3 step process for any strings is a real pain. Are there any patterns or ways to make this process easier?

like image 414
Earlz Avatar asked Jan 14 '13 17:01

Earlz


1 Answers

Auto-generated files with access to each individual string are much easier to use - set "Custom tool" for RESX file to PublicResXFileCodeGenerator.

Code would look like:

using MyProject.Resources;
...
localizedText = Resources.SomeReasonableName;

Side notes:

  • having multiple RESX files along with auto-generated IDs have additional benefit of intellisense giving you reasonable number of choices.
  • depending on how translation is handled you may be better not worrying about duplicated text in RESX file (except maybe OK/cancel kind of strings). It may be easier to deal with duplicated strings at translation time.
like image 53
Alexei Levenkov Avatar answered Sep 20 '22 05:09

Alexei Levenkov