The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Localization Issue

I am running into a localization issue and was wondering if anybody had a solution.

I have a product that has several resource files - each one is localized for the specific languages that I support.  I am using Visual Studio 2005 and c/c++ with MFC.  My issue is trying to keep the resource files in sync.  When I make changes in one resource file, I have to make changes in all of them and this gets time consuming.  I was wondering if anybody knew of a tool or a better way to manage this.
CaliforniaCoder Send private email
Thursday, August 31, 2006
 
 
We don't use resource files.

We use a database.  If something isn't translated, it falls back to the default.  Seeing that, you go into the localization maintenance, add the translation, and re-open the affected form.  No resource file compilation, no source control issues.
Cade Roux Send private email
Friday, September 01, 2006
 
 
There are somethings in  MFC you have to use .rc files and string tables for.
There are 2 useful tools.
LocalizeRC = free, extracts the strings from the file, does a sort unique and gives you a textfile with one string per line. It can then put the translated strings back into the .rc.
 
RCLocalize - is a commercial ($50) .rc file editor that stores multiple languages for each resource, it can generate either a single multilanguage resource or separate .rc for eahc language. It can reload any changes to your native .rc and update chnaged controls.
It also does a good job of checking that static text fits and short cuts match in different languages.

(ps I might have got the names the wrong way round - not at my own computer)
Martin Send private email
Sunday, September 03, 2006
 
 
For the strings I use templates, like:

//Strings.h
template <class LANG>
class Strings
{
public:
  static LPCWSTR strYes() { return LANG::strYes(); }
};

//Strings_en.h
class Strings_en
{
public:
  static LPCWSTR strYes() { return L"Yes"; }
};

//Strings_de.h
class Strings_de
{
public:
  static LPCWSTR strYes() { return L"Ja"; }
};

//language.h
#if defined (__LANG_EN__)
#include "Strings_en.h"
typedef Strings<Strings_en> lang;
#elif defined (__LANG_DE__)
#include "Strings_de.h"
typedef Strings<Strings_de> lang;
#else
#error NO LANGUAGE DEFINED
#endif

//main.cpp
#include <iostream>
#include "language.h"

int main(int, char**)
{
  std::cout << lang::strYes();
  return 0;
}

This way I can't miss a string. It is not a very user-frendly way, but from many ways I've tried, I liked it most.
g Send private email
Sunday, September 03, 2006
 
 
This was just a small reproduction, I didn't test it at all, so I already see, I've made a mistake. Language.h should include also the Strings.h

//language.h
#include "Strings.h"
#if defined (__LANG_EN__)
#include "Strings_en.h"
typedef Strings<Strings_en> lang;
#elif defined (__LANG_DE__)
#include "Strings_de.h"
typedef Strings<Strings_de> lang;
#else
#error NO LANGUAGE DEFINED
#endif

Maybe there are other mistakes ...
g Send private email
Sunday, September 03, 2006
 
 
But this doesn't work with tooltips - which must be in the string table, or static text in menu/dialogs - unless you are creating all of the gui elements in code rather than the .rc file.
Martin Send private email
Monday, September 04, 2006
 
 
Yes, I am creating all of it in the code. Tooltips and status bar text is handeld in a class derived from CFrameWnd (Tooltips handle TTN_NEEDTEXTW notification in OnToolTipText, and status text in a virtual method GetMessageString; if we talk about MFC projects), and for the dialogs I call a function in the OnInitDialog. Menus I also create dynamicaly and exchange with original dummy menu in the RC. Partialy I decided to go this way because Unicode RC files can not be loaded with the RC editor in the VS.NET 2003 (as my other language is Macedonian-cyrilic, I have to use unicode).

Not a perfect way to go, but it works for me.
g Send private email
Monday, September 04, 2006
 
 
Thanks for all the great information.  I am going to look into all the options suggested.
CaliforniaCoder Send private email
Tuesday, September 05, 2006
 
 
At my old place, we used to have localiser specific files (just a csv from excel) and then we used Ant during our daily builds to copy the appropriate resource strings into the proper RC files (which are just text files).  We'd then compile and voila: instant localised version.

- James
James Birchall Send private email
Thursday, September 07, 2006
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz