Language support and Translations for UI's.
More...
|
| typedef char *(* | oyjlTranslate_f) (oyjlTranslation_s *context, const char *string) |
| | custom translator, for switching the translation engine More...
|
| |
|
| char * | oyjlLanguage (const char *loc) |
| | obtain language part of i18n locale code More...
|
| |
| char * | oyjlCountry (const char *loc) |
| | obtain country part of i18n locale code More...
|
| |
| const char * | oyjlLang (const char *loc) |
| | change language More...
|
| |
| char * | oyjlTranslate (oyjlTranslation_s *context, const char *text) |
| | translate string More...
|
| |
| oyjlTranslation_s * | oyjlTranslation_New (const char *loc, const char *domain, oyjl_val *catalog, oyjlTranslate_f translator, void *user_data, void(*deAlloc)(void *), int flags) |
| | create i18n context More...
|
| |
| oyjlTranslate_f | oyjlTranslation_GetTranslator (oyjlTranslation_s *context) |
| | get function More...
|
| |
| const char * | oyjlTranslation_GetLang (oyjlTranslation_s *context) |
| | get catalog lang More...
|
| |
| const char * | oyjlTranslation_GetDomain (oyjlTranslation_s *context) |
| | get domain More...
|
| |
| oyjl_val | oyjlTranslation_GetCatalog (oyjlTranslation_s *context) |
| | get catalog More...
|
| |
| void * | oyjlTranslation_GetUserData (oyjlTranslation_s *context) |
| | get UserData More...
|
| |
| int | oyjlTranslation_GetFlags (oyjlTranslation_s *context) |
| | get flags More...
|
| |
| void | oyjlTranslation_SetFlags (oyjlTranslation_s *context, int flags) |
| | change flags More...
|
| |
| void | oyjlTranslation_SetLocale (oyjlTranslation_s *context, const char *loc) |
| | change language More...
|
| |
| void | oyjlTranslation_Release (oyjlTranslation_s **context_) |
| | get flags More...
|
| |
| oyjlTranslation_s * | oyjlTranslation_Get (const char *domain) |
| | get message translation context More...
|
| |
| int | oyjlTranslation_Set (oyjlTranslation_s **context) |
| | set message translation context More...
|
| |
| int | oyjlTranslation_Unset (const char *domain) |
| | unregister message translation context More...
|
| |
| void | oyjlTranslateJson (oyjl_val root, oyjlTranslation_s *context, const char *key_list) |
| | translate JSON More...
|
| |
| oyjl_val | oyjlTreeSerialise (oyjl_val v, int flags, int *size) |
| | write tree to data block More...
|
| |
| oyjl_val | oyjlTreeDeSerialise (oyjl_val v, int flags OYJL_UNUSED, int size OYJL_UNUSED) |
| | create tree from serialised data block More...
|
| |
Language support and Translations for UI's.
The oyjlTranslation_s object is created by oyjlTranslation_New() and holds the context for translations including a possibly own translation function and user provided data. It is needed for any translation call, like oyjlTranslate() or oyjlTranslateJson(). A CLI exist in the oyjltranslate tool. A typical single language catalog is usually set by the oyjlInitLanguageDebug() call during application setup. Multiple catalogs can be internally stored by oyjlTranslation_Set() and obtained by oyjlTranslation_Get() for advanced use. oyjlTreeSerialise() turnes a oyjl_val tree into a memory block, which could be written to file and later used as translation catalog. This memory block needs no JSON parser. The Oyranos JSON Library tool provides a command line interface for it by the following command:
oyjl json ${COLLECT_I18N_INPUT} -w oiJS -W lib${MY_PROJECT_DOWN_NAME}_i18n
◆ OYJL_GETTEXT
| #define OYJL_GETTEXT 0x400000 |
◆ OYJL_NO_OPTIMISE
| #define OYJL_NO_OPTIMISE 0x800000 |
◆ oyjlTranslate_f
| typedef char*(* oyjlTranslate_f) (oyjlTranslation_s *context, const char *string) |
custom translator, for switching the translation engine
◆ oyjlCountry()
| char * oyjlCountry |
( |
const char * |
loc | ) |
|
obtain country part of i18n locale code
- Parameters
-
| loc | locale name as from setlocale("") |
- Returns
- country part
- Version
- Oyjl: 1.0.0
- Date
- 2020/07/27
- Since
- 2020/07/27 (Oyjl: 1.0.0)
◆ oyjlLang()
| const char* oyjlLang |
( |
const char * |
loc | ) |
|
change language
Call after oyjlTr().
- Parameters
-
| loc | locale name as from setlocale("")
- NULL: reset
- "": get existing without change
- "something": set lang to "something"
|
- Returns
- current locale
- Version
- Oyjl: 1.0.0
- Date
- 2021/10/24
- Since
- 2020/07/28 (Oyjl: 1.0.0)
◆ oyjlLanguage()
| char* oyjlLanguage |
( |
const char * |
loc | ) |
|
obtain language part of i18n locale code
- Parameters
-
| loc | locale name as from setlocale("") |
- Returns
- language part
- Version
- Oyjl: 1.0.0
- Date
- 2020/07/27
- Since
- 2020/07/27 (Oyjl: 1.0.0)
◆ oyjlTranslate()
| char * oyjlTranslate |
( |
oyjlTranslation_s * |
context, |
|
|
const char * |
text |
|
) |
| |
translate string
- Parameters
-
| context | translation variables; optional, will try gettext without |
| text | the to be translated text; optional, will return without |
- Returns
- translated item; must not be freed
- Version
- Oyjl: 1.0.0
- Date
- 2021/10/24
- Since
- 2020/07/27 (Oyjl: 1.0.0)
◆ oyjlTranslateJson()
| void oyjlTranslateJson |
( |
oyjl_val |
root, |
|
|
oyjlTranslation_s * |
context, |
|
|
const char * |
key_list |
|
) |
| |
translate JSON
- See also
- oyjlUi_Translate() oyjlTranslation_New()
- Parameters
-
| [in,out] | root | the tree to translate strings inside |
| context | translation variables; optional, will try gettext without |
| [in] | key_list | comma separate list of keys to translate; optional, without the function will return |
- Version
- Oyjl: 1.0.0
- Date
- 2021/10/24
- Since
- 2021/07/09 (Oyjl: 1.0.0)
◆ oyjlTranslation_Get()
| oyjlTranslation_s* oyjlTranslation_Get |
( |
const char * |
domain | ) |
|
get message translation context
- Parameters
-
| domain | select domain of library or application |
- Returns
- context for domain
- Version
- Oyjl: 1.0.0
- Date
- 2021/10/26
- Since
- 2021/10/26 (Oyjl: 1.0.0)
◆ oyjlTranslation_GetCatalog()
| oyjl_val oyjlTranslation_GetCatalog |
( |
oyjlTranslation_s * |
context | ) |
|
get catalog
- Version
- Oyjl: 1.0.0
- Date
- 2021/10/24
- Since
- 2021/10/24 (Oyjl: 1.0.0)
◆ oyjlTranslation_GetDomain()
| const char* oyjlTranslation_GetDomain |
( |
oyjlTranslation_s * |
context | ) |
|
get domain
- Version
- Oyjl: 1.0.0
- Date
- 2021/10/26
- Since
- 2021/10/26 (Oyjl: 1.0.0)
◆ oyjlTranslation_GetFlags()
| int oyjlTranslation_GetFlags |
( |
oyjlTranslation_s * |
context | ) |
|
get flags
- Version
- Oyjl: 1.0.0
- Date
- 2021/10/24
- Since
- 2021/10/24 (Oyjl: 1.0.0)
◆ oyjlTranslation_GetLang()
| const char* oyjlTranslation_GetLang |
( |
oyjlTranslation_s * |
context | ) |
|
get catalog lang
Fall back to loc from oyjlTranslation_New() otherwise NULL.
- Version
- Oyjl: 1.0.0
- Date
- 2021/10/24
- Since
- 2021/10/24 (Oyjl: 1.0.0)
◆ oyjlTranslation_GetTranslator()
| oyjlTranslate_f oyjlTranslation_GetTranslator |
( |
oyjlTranslation_s * |
context | ) |
|
get function
Fall back to oyjlTranslate().
- Version
- Oyjl: 1.0.0
- Date
- 2021/10/24
- Since
- 2021/10/24 (Oyjl: 1.0.0)
◆ oyjlTranslation_GetUserData()
| void * oyjlTranslation_GetUserData |
( |
oyjlTranslation_s * |
context | ) |
|
get UserData
- Version
- Oyjl: 1.0.0
- Date
- 2021/10/24
- Since
- 2021/10/24 (Oyjl: 1.0.0)
◆ oyjlTranslation_New()
| oyjlTranslation_s* oyjlTranslation_New |
( |
const char * |
loc, |
|
|
const char * |
domain, |
|
|
oyjl_val * |
catalog, |
|
|
oyjlTranslate_f |
translator, |
|
|
void * |
user_data, |
|
|
void(*)(void *) |
deAlloc, |
|
|
int |
flags |
|
) |
| |
create i18n context
The passed in catalog shall contain its translations in the "org/freedesktop/oyjl/translations/loc" path.
- Parameters
-
| loc | locale name as from setlocale(0,""), the special locale "back" will inverse the translation; optional |
| translator | the function; optional |
| catalog | the parsed catalog as tree; optional |
| user_data | optional |
| deAlloc | free user_data on oyjlTranslation_Release(); optional |
| [in] | flags | supported:
|
- Returns
- context
- Version
- Oyjl: 1.0.0
- Date
- 2021/10/26
- Since
- 2021/10/24 (Oyjl: 1.0.0)
◆ oyjlTranslation_Release()
| void oyjlTranslation_Release |
( |
oyjlTranslation_s ** |
context_ | ) |
|
get flags
- Version
- Oyjl: 1.0.0
- Date
- 2021/10/24
- Since
- 2021/10/24 (Oyjl: 1.0.0)
◆ oyjlTranslation_Set()
| int oyjlTranslation_Set |
( |
oyjlTranslation_s ** |
context | ) |
|
set message translation context
- Parameters
-
| context | message context for oyjlTranslate()
- oyjlTranslation_s context: move in as new current
|
- Returns
- state
- -1: no domain
- 0: nothing found for erase
- 1: old context found
- 2: old context erased
- 3: context replaced
- 5: context kept
- Version
- Oyjl: 1.0.0
- Date
- 2021/11/01
- Since
- 2021/10/26 (Oyjl: 1.0.0)
◆ oyjlTranslation_SetFlags()
| void oyjlTranslation_SetFlags |
( |
oyjlTranslation_s * |
context, |
|
|
int |
flags |
|
) |
| |
change flags
- Parameters
-
| context | the translation context |
| flags | translation flags |
- Version
- Oyjl: 1.0.0
- Date
- 2021/10/24
- Since
- 2021/10/24 (Oyjl: 1.0.0)
◆ oyjlTranslation_SetLocale()
| void oyjlTranslation_SetLocale |
( |
oyjlTranslation_s * |
context, |
|
|
const char * |
loc |
|
) |
| |
change language
- Parameters
-
| context | the translation context |
| loc | locale name as from setlocale("")
- "something": set lang to "something"
|
- Version
- Oyjl: 1.0.0
- Date
- 2021/10/24
- Since
- 2021/10/24 (Oyjl: 1.0.0)
◆ oyjlTranslation_Unset()
| int oyjlTranslation_Unset |
( |
const char * |
domain | ) |
|
unregister message translation context
- Parameters
-
| domain | select domain of library or application |
- Returns
- state
- -1: no domain
- 0: nothing found for erase
- 1: old context found
- 2: old context erased
- 3: context replaced
- 5: context kept
- Version
- Oyjl: 1.0.0
- Date
- 2021/11/01
- Since
- 2021/10/26 (Oyjl: 1.0.0)
◆ oyjlTreeDeSerialise()
| oyjl_val oyjlTreeDeSerialise |
( |
oyjl_val |
v, |
|
|
int flags |
OYJL_UNUSED, |
|
|
int size |
OYJL_UNUSED |
|
) |
| |
create tree from serialised data block
- Parameters
-
| [in] | v | serialised tree |
| [in] | flags | unused: |
| [in] | size | the size of the data block v - not used |
- Returns
- serialised tree
- See also
- oyjlTreeSerialise()
- Version
- Oyjl: 1.0.0
- Date
- 2021/11/01
- Since
- 2021/11/01 (Oyjl: 1.0.0)
References oyjlBT(), oyjlOBJECT_JSON, and oyjl_val_s::type.
◆ oyjlTreeSerialise()
write tree to data block
- Parameters
-
| v | tree to serialise |
| [in] | flags | supported:
- OYJL_OBSERVE : to print verbose info message
|
| [out] | size | the size of the returned data block |
- Returns
- serialised tree
- See also
- oyjlTreeDeSerialise()
- Version
- Oyjl: 1.0.0
- Date
- 2021/11/01
- Since
- 2021/09/16 (Oyjl: 1.0.0)