Romain BECAN / Mbed 2 deprecated Mallette_RB10G1_V40

Dependencies:   TS_DISCO_F746NG mbed LCD_DISCO_F746NG BSP_DISCO_F746NG lvgl_RB FastPWM millis

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers lv_i18n.h Source File

lv_i18n.h

00001 #ifndef LV_I18N_H
00002 #define LV_I18N_H
00003 
00004 #ifdef __cplusplus
00005 extern "C" {
00006 #endif
00007 
00008 #include <stdint.h>
00009 #include <string.h>
00010 
00011 typedef enum {
00012     LV_I18N_PLURAL_TYPE_ZERO,
00013     LV_I18N_PLURAL_TYPE_ONE,
00014     LV_I18N_PLURAL_TYPE_TWO,
00015     LV_I18N_PLURAL_TYPE_FEW,
00016     LV_I18N_PLURAL_TYPE_MANY,
00017     LV_I18N_PLURAL_TYPE_OTHER,
00018     _LV_I18N_PLURAL_TYPE_NUM,
00019 } lv_i18n_plural_type_t;
00020 
00021 typedef struct {
00022     const char * msg_id;
00023     const char * translation;
00024 } lv_i18n_phrase_t;
00025 
00026 typedef struct {
00027     const char * locale_name;
00028     lv_i18n_phrase_t * singulars;
00029     lv_i18n_phrase_t * plurals[_LV_I18N_PLURAL_TYPE_NUM];
00030     uint8_t (*locale_plural_fn)(int32_t num);
00031 } lv_i18n_lang_t;
00032 
00033 // Null-terminated list of languages. First one used as default.
00034 typedef const lv_i18n_lang_t * lv_i18n_language_pack_t;
00035 
00036 
00037 extern const lv_i18n_language_pack_t lv_i18n_language_pack[];
00038 
00039 
00040 /**
00041  * Set the languages for internationalization
00042  * @param langs pointer to the array of languages. (Last element has to be `NULL`)
00043  */
00044 int lv_i18n_init(const lv_i18n_language_pack_t * langs);
00045 
00046 /**
00047  * Change the localization (language)
00048  * @param l_name name of the translation locale to use. E.g. "en_GB"
00049  */
00050 int lv_i18n_set_locale(const char * l_name);
00051 
00052 /**
00053  * Get the translation from a message ID
00054  * @param msg_id message ID
00055  * @return the translation of `msg_id` on the set local
00056  */
00057 const char * lv_i18n_get_text(const char * msg_id);
00058 
00059 /**
00060  * Get the translation from a message ID and apply the language's plural rule to get correct form
00061  * @param msg_id message ID
00062  * @param num an integer to select the correct plural form
00063  * @return the translation of `msg_id` on the set local
00064  */
00065 const char * lv_i18n_get_text_plural(const char * msg_id, int32_t num);
00066 
00067 /**
00068  * Get the name of the currently used localization.
00069  * @return name of the currently used localization. E.g. "en_GB"
00070  */
00071 const char * lv_i18n_get_current_locale(void);
00072 
00073 
00074 void __lv_i18n_reset(void);
00075 
00076 
00077 #define _(text) lv_i18n_get_text(text)
00078 #define _p(text, num) lv_i18n_get_text_plural(text, num)
00079 
00080 
00081 #ifdef __cplusplus
00082 } /* extern "C" */
00083 #endif
00084 
00085 #endif /*LV_LANG_H*/