[haiku-development] Re: Coding Guidelines need update for localization

  • From: Alex Wilson <yourpalal2@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Thu, 21 Oct 2010 20:13:42 -0600

Maybe there is something I'm missing here, but why not define a new
macro like so:

B_TRANSLATABLE_STRING(keyValue, string)

Which would make a const char* const keyValue = string variable.
keyValue becomes a handle for translators, but they can still see the
english text as well. When you need the string in question, you simply
pass keyValue to B_TRANSLATE(). It would work like this:

B_TRANSLATABLE_STRING(trWelcomeText, "Welcome ...\n");

// later on
stringView->SetText(B_TRANSLATE(trWelcomeText));

or, if that will cause problems with collectcatkeys, just create a new
macro, like B_FETCH_TRANSLATED_STRING(trWelcomeText), or something to
that effect.

This way, the english strings are still embedded into the application,
but changing them won't totally invalidate the translations. This is
also, imho more readable than passing a string as the handle to your
text, and in some case, more readable than embedding the string
directly, and splitting it over many lines (in the middle of your
code).

--Alex

Other related posts: