Difference between revisions of "GTRANS"
(Created page with "The GTRANS module allows to manage language translations. The language of an application can be changed dynamically during run-time using the GTRANS module. == API reference...") |
(→Intended usage) |
||
Line 15: | Line 15: | ||
A translatable application needs to have a base language. All translations happen relative to that base language. The base language is specified using <code>gtransSetBaseLanguage()</code>. The current language of the application is set using <code>gtransSetLanguage()</code>. | A translatable application needs to have a base language. All translations happen relative to that base language. The base language is specified using <code>gtransSetBaseLanguage()</code>. The current language of the application is set using <code>gtransSetLanguage()</code>. | ||
The actual translations take place by calling <code>gtransString()</code>. A string contained in the translation table of the base language is passed to <code>gtransString()</code>. The function returns the corresponding string of the current language that was set using <code>gtransSetLanguage()</code> or the passed string if none was found. | The actual translations take place by calling <code>gtransString()</code>. A string contained in the translation table of the base language is passed to <code>gtransString()</code>. The function returns the corresponding string of the current language that was set using <code>gtransSetLanguage()</code> or the passed string if none was found. | ||
+ | |||
+ | A wrapper macro named <code>gt()</code> around <code>gtransString()</code> is available to make writing and reading translatable applications easier: | ||
+ | <source lang="c"> | ||
+ | #define gt(str) gtransString(str) | ||
+ | </source> |
Revision as of 23:42, 7 February 2016
The GTRANS module allows to manage language translations. The language of an application can be changed dynamically during run-time using the GTRANS module.
API reference
The API reference of the GTRANS module can be found here.
Intended usage
Each translation is specified by a transTable
struct which is essentially a table of strings:
typedef struct transTable { unsigned numEntries; // The number of strings that this table contains const char** strings; // The translated strings } transTable;
A translatable application needs to have a base language. All translations happen relative to that base language. The base language is specified using gtransSetBaseLanguage()
. The current language of the application is set using gtransSetLanguage()
.
The actual translations take place by calling gtransString()
. A string contained in the translation table of the base language is passed to gtransString()
. The function returns the corresponding string of the current language that was set using gtransSetLanguage()
or the passed string if none was found.
A wrapper macro named gt()
around gtransString()
is available to make writing and reading translatable applications easier:
#define gt(str) gtransString(str)