Difference between revisions of "Supporting GUI Translation"

Jump to navigation Jump to search
m
→‎Mark translatable strings in the source code: Add two macros that define contexts.
m (→‎Translations file format: give nice name to link.)
m (→‎Mark translatable strings in the source code: Add two macros that define contexts.)
Line 6: Line 6:
* ''_c(char *, char *)'' - Another way to mark strings. It attaches the string to a context so that we can have different translations for the same string. The second argument is the context.
* ''_c(char *, char *)'' - Another way to mark strings. It attaches the string to a context so that we can have different translations for the same string. The second argument is the context.
* ''_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 ''_()'' or ''_c()'' at the place where you need to perform the substitution.
* ''_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 ''_()'' or ''_c()'' at the place where you need to perform the substitution.
* ''_sc(char *, char *)'' - Another way to mark static string constants. It attaches the string to a context so that we can have different translations for the same string. The second argument is the context.
* ''DECLARE_TRANSLATION_ADDITIONAL_CONTEXT(char *, char *)'' - Declare a string (first argument) to translate in a given context (second argument).
<syntax type="C++">
<syntax type="C++">
static const char *foo = _s("Some translatable text");
static const char *foo = _s("Some translatable text");
DECLARE_TRANSLATION_ADDITIONAL_CONTEXT("Some translatable text", "lowres")
StaticTextWidget *bar = new StaticTextWidget(this, "name", _(foo),  _("Some other translatable text for the tooltip"));
StaticTextWidget *bar = new StaticTextWidget(this, "name", _(foo),  _("Some other translatable text for the tooltip"));
StaticTextWidget *bar = new StaticTextWidget(this, "name", _c(foo, "lowres"),  _("Some other translatable text for the tooltip"));
StaticTextWidget *path = new StaticTextWidget(this, "name", _("None", "path"));
StaticTextWidget *path = new StaticTextWidget(this, "name", _("None", "path"));
StaticTextWidget *soundfont = new StaticTextWidget(this, "name", _("None", "soundfont"));
StaticTextWidget *soundfont = new StaticTextWidget(this, "name", _("None", "soundfont"));
</syntax>
</syntax>


In the above example "None" can be translated differently depending if it refers to a path or a soundfont.
In the above example foo can be translated differently depending if it is attached to the context "lowres" or not.
"None" can also be translated differently depending if it refers to a path or a soundfont.


== Update the translation template file ==
== Update the translation template file ==
TrustedUser
2,147

edits

Navigation menu