vdr  2.2.0
i18n.h
Go to the documentation of this file.
1 /*
2  * i18n.h: Internationalization
3  *
4  * See the main source file 'vdr.c' for copyright information and
5  * how to reach the author.
6  *
7  * $Id: i18n.h 3.0 2012/03/11 14:07:45 kls Exp $
8  */
9 
10 #ifndef __I18N_H
11 #define __I18N_H
12 
13 #include <stdio.h>
14 #include "tools.h"
15 
16 #define I18N_DEFAULT_LOCALE "en_US"
17 #define I18N_MAX_LOCALE_LEN 16 // for buffers that hold en_US etc.
18 #define I18N_MAX_LANGUAGES 256 // for buffers that hold all available languages
19 
20 void I18nInitialize(const char *LocaleDir = NULL);
24 void I18nRegister(const char *Plugin);
26 void I18nSetLocale(const char *Locale);
30 int I18nCurrentLanguage(void);
36 void I18nSetLanguage(int Language);
42 const cStringList *I18nLanguages(void);
49 const char *I18nTranslate(const char *s, const char *Plugin = NULL) __attribute_format_arg__(1);
53 const char *I18nLocale(int Language);
57 const char *I18nLanguageCode(int Language);
63 int I18nLanguageIndex(const char *Code);
66 const char *I18nNormalizeLanguageCode(const char *Code);
70 bool I18nIsPreferredLanguage(int *PreferredLanguages, const char *LanguageCode, int &OldPreference, int *Position = NULL);
80 
81 #ifdef PLUGIN_NAME_I18N
82 #define tr(s) I18nTranslate(s, "vdr-" PLUGIN_NAME_I18N)
83 #define trVDR(s) I18nTranslate(s) // to use a text that's in the VDR core's translation file
84 #else
85 #define tr(s) I18nTranslate(s)
86 #endif
87 
88 #define trNOOP(s) (s)
89 
90 #endif //__I18N_H
int I18nLanguageIndex(const char *Code)
Returns the index of the language with the given three letter language Code.
Definition: i18n.c:228
int I18nCurrentLanguage(void)
Returns the index of the current language.
Definition: i18n.c:183
const char * I18nNormalizeLanguageCode(const char *Code)
Returns a 3 letter language code that may not be zero terminated.
Definition: i18n.c:238
void I18nRegister(const char *Plugin)
Registers the named plugin, so that it can use internationalized texts.
Definition: i18n.c:164
const char * LanguageCode
Definition: i18n.c:30
void I18nInitialize(const char *LocaleDir=NULL)
Detects all available locales and loads the language names and codes.
Definition: i18n.c:103
const char * I18nLocale(int Language)
Returns the locale code of the given Language (which is an index as returned by I18nCurrentLanguage()...
Definition: i18n.c:218
void I18nSetLocale(const char *Locale)
Sets the current locale to Locale.
Definition: i18n.c:170
const char * I18nLanguageCode(int Language)
Returns the three letter language code of the given Language (which is an index as returned by I18nCu...
Definition: i18n.c:223
bool I18nIsPreferredLanguage(int *PreferredLanguages, const char *LanguageCode, int &OldPreference, int *Position=NULL)
Checks the given LanguageCode (which may be something like "eng" or "eng+deu") against the PreferredL...
Definition: i18n.c:269
const char * I18nTranslate(const char *s, const char *Plugin=NULL) __attribute_format_arg__(1)
Translates the given string (with optional Plugin context) into the current language.
Definition: i18n.c:206
const cStringList * I18nLanguages(void)
Returns the list of available languages.
Definition: i18n.c:201
void I18nSetLanguage(int Language)
Sets the current language index to Language.
Definition: i18n.c:188
int I18nNumLanguagesWithLocale(void)
Returns the number of entries in the list returned by I18nLanguages() that actually have a locale...
Definition: i18n.c:196