Difference between revisions of "Supporting GUI Translation"

From ScummVM :: Wiki
Jump to navigation Jump to search
(Add developer instructions for translation support)
 
Line 13: Line 13:
# You should then update the scummvm.pot template file by running "''make updatepot''". You need to have the gettext tool installed to run that command.
# You should then update the scummvm.pot template file by running "''make updatepot''". You need to have the gettext tool installed to run that command.


The translations are compiled in the executable, and the gettext tools are not needed for the compilation or executation of ScummVM. They are only needed to generate the scummvm.pot template file when translatable strings are added, removed or modified in the source code.
The translations are compiled in the executable, and the gettext tools are not needed for the compilation or executation of ScummVM. They are only needed to generate the scummvm.pot template file and the translations when translatable strings are added, removed or modified in the source code or a new translation is made available.


== TO DO ==
== TO DO ==

Revision as of 17:21, 19 June 2010

Mark translatable strings in the source code

In order to make a string translatable you have to use one of the following pseudofunctions in your code:

  •  _(char *) -  Main way to mark strings. You need it in majority of cases.
  • _s(char *) - Function used to mark static string constants. For instance, when you have static arrays which need to be translated. In this case you mark these strings with _s(), and then use _() at the place where you need to perform the substitution.
  •  _t(char *) - Function used for console messages. It applies charset conversion to the output. But this feature is available only on those platforms which have full blown -liconv)

<syntax type="C++"> static const char* foo = _s("Some translatable text"); StaticTextWidget* bar = new StaticTextWidget(this, "name", _(foo), _("Some other translatable text for the tooltip")); </syntax>

Update the translation template file

  1. All the files that contain translatable text should be listed in the po/POTFILES file. So if you are adding translatable text into a file, you should make sure that file is listed in POTFILES and otherwise add it to the list.
  2. You should then update the scummvm.pot template file by running "make updatepot". You need to have the gettext tool installed to run that command.

The translations are compiled in the executable, and the gettext tools are not needed for the compilation or executation of ScummVM. They are only needed to generate the scummvm.pot template file and the translations when translatable strings are added, removed or modified in the source code or a new translation is made available.

TO DO

  • Add support for locale-defined fonts.
  • Languages in GUI are represented by lang_country standard abbreviation, such as en_GB. It would probably be better to have a more human readable description in the GUI (e.g. English (GB)).
  • Updating interface without restart. This will require moving much code to reflowLayout() for all dialogs and is a big piece of work.
  • Situations with strings not fitting into widgets. No code around that. Suggestions are welcome.
  • Behaviour for non-ASCII hotkeys (surrounded by tildes) is undefined and was not even tested.