open-vm-tools 12.5.0
Macros | Functions
Internationalization

Functions and macros to help with internationalization of applications. More...

Macros

#define MSG_MAGIC   "@&!*@*@"
 
#define MSG_MAGIC_LEN   7
 
#define MSGID(id)   MSG_MAGIC "(" #id ")"
 
#define SU_(msgid, en)   VMTools_GetString(VMW_TEXT_DOMAIN, MSGID(msgid) en)
 

Functions

G_BEGIN_DECLS void VMTools_BindTextDomain (const char *domain, const char *locale, const char *catdir)
 
const char * VMTools_GetString (const char *domain, const char *msgid)
 

Detailed Description

Functions and macros to help with internationalization of applications.

To create a localizable string, use the MSGID macro in the following manner:

VMTools_GetString("domain", MSGID(message.id) "Default English text.")
const char * VMTools_GetString(const char *domain, const char *msgid)
Definition: i18n.c:750

Or, in shorthand form:

SU_(message.id, "Default English text.")
#define SU_(msgid, en)
Definition: i18n.h:68

This will instruct the code to retrive the message under key "message.id" in the translation catalog for the configured locale.

The shorthand macros use the VMW_TEXT_DOMAIN macro to identify the domain from which translated messages will be loaded. Each domain should first be initialized by calling VMTools_BindTextDomain().

Macro Definition Documentation

◆ SU_

#define SU_ (   msgid,
  en 
)    VMTools_GetString(VMW_TEXT_DOMAIN, MSGID(msgid) en)

Shorthand macro to retrieve a localized message in UTF-8.

Parameters
[in]msgidThe message ID.
[in]enEnglish version of the message.
Returns
A localized message.

Function Documentation

◆ VMTools_BindTextDomain()

G_BEGIN_DECLS void VMTools_BindTextDomain ( const char *  domain,
const char *  lang,
const char *  catdir 
)

Loads the message catalog for a text domain. Each text domain contains a different set of messages loaded from a different catalog.

If a catalog has already been bound to the given name, it is replaced with the newly loaded data.

Parameters
[in]domainName of the text domain being loaded.
[in]langLanguage code for the text domain.
[in]catdirRoot directory of catalog files (NULL = default).

◆ VMTools_GetString()

const char * VMTools_GetString ( const char *  domain,
const char *  msgid 
)

Returns a localized version of the requested string in UTF-8.

Parameters
[in]domainText domain.
[in]msgidMessage id (including English translation).
Returns
The localized string.