TrustedUser
2,147
edits
m (Add link to file format description) |
(→Mark translatable strings in the source code: Remove _t() and add _c().) |
||
Line 3: | Line 3: | ||
== Mark translatable strings in the source code == | == 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: | 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. | * ''_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. | |||
<syntax type="C++"> | <syntax type="C++"> | ||
static const char* foo = _s("Some translatable text"); | static const char *foo = _s("Some translatable text"); | ||
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 *path = new StaticTextWidget(this, "name", _("None", "path")); | |||
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. | |||
== Update the translation template file == | == Update the translation template file == |