Difference between revisions of "Supporting GUI Translation"

Jump to navigation Jump to search
Removed the extra code fragments for _() and _s() and updated the text describing their usage
m (Layout)
(Removed the extra code fragments for _() and _s() and updated the text describing their usage)
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.
* ''_(char *)'' -  Main way to mark strings. It's a function, and is used for strings within code. For the majority of translatable strings, this is the function to be used.
* ''_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 *)'' - A wrapper used to mark static string constants, like for example 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.
* ''_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).
* ''DECLARE_TRANSLATION_ADDITIONAL_CONTEXT(char *, char *)'' - Declare a string (first argument) to translate in a given context (second argument).
An example to illustrate the difference between _() and _s():
* _() is a function, and is used within code. So it's used in cases like this:
<syntax type="C++">
foo(_("Bar"));
</syntax>
* _s() is a wrapper, used with static string constants. So it's used in cases like this:
<syntax type="C++">
char *foo {
  _s("bar"),
  _s("baz")
};
</syntax>


If you want to give some additional explanations to the translators, or your string could be understood in a different ways, it is recommended to precede it with a comment tagged I18N.
If you want to give some additional explanations to the translators, or your string could be understood in a different ways, it is recommended to precede it with a comment tagged I18N.
1,489

edits

Navigation menu