![]() | ![]() | ![]() | libtranslate Reference Manual | ![]() |
---|
TranslatePair — language pair object and functions for handling pair lists
struct TranslatePair; enum TranslatePairFlags; TranslatePair* translate_pair_new (TranslatePairFlags flags, const char *from, const char *to); TranslatePairFlags translate_pair_get_flags (TranslatePair *pair); const char* translate_pair_get_from (TranslatePair *pair); const char* translate_pair_get_to (TranslatePair *pair); GSList* translate_pairs_sort_by_tag (GSList *pairs); GSList* translate_pairs_sort_by_name (GSList *pairs); TranslatePair* translate_pairs_find (const GSList *pairs, const char *from, const char *to);
"flags" TranslatePairFlags : Read / Write / Construct Only "from" gchararray : Read / Write / Construct Only "to" gchararray : Read / Write / Construct Only
A TranslatePair object defines the source and destination languages of a translation, as well as flags specifying the contexts of application of the pair.
You only need to create pairs if you are implementing a service (see the get_pairs method of TranslateServiceClass).
struct TranslatePair;
The TranslatePair struct contains private data only, and should be accessed using the functions below.
typedef enum { TRANSLATE_PAIR_TEXT = 1 << 0, TRANSLATE_PAIR_WEB_PAGE = 1 << 1 } TranslatePairFlags;
Specifies the features of a TranslatePair object.
TRANSLATE_PAIR_TEXT | the pair can be used to translate text |
TRANSLATE_PAIR_WEB_PAGE | the pair can be used to translate a web page |
TranslatePair* translate_pair_new (TranslatePairFlags flags, const char *from, const char *to);
Creates a new language pair.
flags : | the pair flags. |
from : | the source language RFC 3066 tag. |
to : | the destination language RFC 3066 tag. |
Returns : | a new language pair. |
TranslatePairFlags translate_pair_get_flags (TranslatePair *pair);
Gets the flags of pair.
pair : | a pair. |
Returns : | the pair flags. |
const char* translate_pair_get_from (TranslatePair *pair);
Gets the source language of pair.
pair : | a pair. |
Returns : | the RFC 3066 tag of the source language of pair. |
const char* translate_pair_get_to (TranslatePair *pair);
Gets the destination language of pair.
pair : | a pair. |
Returns : | the RFC 3066 tag of the destination language of pair. |
GSList* translate_pairs_sort_by_tag (GSList *pairs);
Sorts a pair list by source and destination RFC 3066 tag. Tag comparisons are performed using translate_ascii_strcasecoll().
pairs : | a list of TranslatePair objects. |
Returns : | pairs sorted. |
GSList* translate_pairs_sort_by_name (GSList *pairs);
Sorts a pair list by source and destination human-readable language name. Names are obtained using translate_get_language_name(), and are compared using translate_utf8_strcasecoll().
pairs : | a list of TranslatePair objects. |
Returns : | pairs sorted. |
TranslatePair* translate_pairs_find (const GSList *pairs, const char *from, const char *to);
Finds the first pair in pairs whose source and/or destination language match from and/or to.
pairs : | a list of TranslatePair objects. |
from : | a RFC 3066 tag, or NULL. |
to : | a RFC 3066 tag, or NULL. |
Returns : | a pair, or NULL if not found. The returned pair belongs to pairs, its reference count is not incremented. |
"flags" (TranslatePairFlags : Read / Write / Construct Only) | The pair flags. |
"from" (gchararray : Read / Write / Construct Only) | The source language RFC 3066 tag. |
"to" (gchararray : Read / Write / Construct Only) | The destination language RFC 3066 tag. |
<< translate-common | TranslateService >> |