Difference between revisions of "GTRANS"
(→Intended usage) |
(→Intended usage) |
||
Line 8: | Line 8: | ||
<source lang="c"> | <source lang="c"> | ||
typedef struct transTable { | typedef struct transTable { | ||
− | + | unsigned numEntries; // The number of strings that this table contains | |
− | + | const char** strings; // The translated strings | |
} transTable; | } transTable; | ||
</source> | </source> |
Revision as of 23:45, 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)
Example
ToDo