diff options
Diffstat (limited to 'source/blender/blenfont/BLF_translation.h')
-rw-r--r-- | source/blender/blenfont/BLF_translation.h | 112 |
1 files changed, 94 insertions, 18 deletions
diff --git a/source/blender/blenfont/BLF_translation.h b/source/blender/blenfont/BLF_translation.h index 159d4b067b6..dc72c77b3bf 100644 --- a/source/blender/blenfont/BLF_translation.h +++ b/source/blender/blenfont/BLF_translation.h @@ -33,6 +33,8 @@ #ifndef __BLF_TRANSLATION_H__ #define __BLF_TRANSLATION_H__ +#include "BLI_utildefines.h" /* for bool type */ + #define TEXT_DOMAIN_NAME "blender" /* blf_lang.c */ @@ -48,26 +50,37 @@ void BLF_lang_free(void); /* Set the current locale. */ void BLF_lang_set(const char *); -/* Get the current locale (short code, e.g. es_ES). */ +/* Get the current locale ([partial] ISO code, e.g. es_ES). */ const char *BLF_lang_get(void); +/* Get locale's elements (if relevant pointer is not NULL and element actually exists, e.g. if there is no variant, + * *variant and *language_variant will always be NULL). + * Non-null elements are always MEM_mallocN'ed, it's the caller's responsibility to free them. + * NOTE: Always available, even in non-WITH_INTERNATIONAL builds. + */ +void BLF_locale_explode(const char *locale, char **language, char **country, char **variant, + char **language_country, char **language_variant); + /* Get EnumPropertyItem's for translations menu. */ struct EnumPropertyItem *BLF_RNA_lang_enum_properties(void); /* blf_translation.c */ -#ifdef WITH_INTERNATIONAL unsigned char *BLF_get_unifont(int *unifont_size); void BLF_free_unifont(void); -#endif +unsigned char *BLF_get_unifont_mono(int *unifont_size); +void BLF_free_unifont_mono(void); +bool BLF_is_default_context(const char *msgctxt); const char *BLF_pgettext(const char *msgctxt, const char *msgid); /* translation */ -int BLF_translate_iface(void); -int BLF_translate_tooltips(void); +bool BLF_translate_iface(void); +bool BLF_translate_tooltips(void); +bool BLF_translate_new_dataname(void); const char *BLF_translate_do_iface(const char *msgctxt, const char *msgid); const char *BLF_translate_do_tooltip(const char *msgctxt, const char *msgid); +const char *BLF_translate_do_new_dataname(const char *msgctxt, const char *msgid); /* The "translation-marker" macro. */ @@ -76,22 +89,26 @@ const char *BLF_translate_do_tooltip(const char *msgctxt, const char *msgid); /* Those macros should be used everywhere in UI code. */ #ifdef WITH_INTERNATIONAL -/* #define _(msgid) BLF_gettext(msgid) */ - #define IFACE_(msgid) BLF_translate_do_iface(NULL, msgid) - #define TIP_(msgid) BLF_translate_do_tooltip(NULL, msgid) - #define CTX_IFACE_(context, msgid) BLF_translate_do_iface(context, msgid) - #define CTX_TIP_(context, msgid) BLF_translate_do_tooltip(context, msgid) +/*# define _(msgid) BLF_gettext(msgid) */ +# define IFACE_(msgid) BLF_translate_do_iface(NULL, msgid) +# define TIP_(msgid) BLF_translate_do_tooltip(NULL, msgid) +# define DATA_(msgid) BLF_translate_do_new_dataname(NULL, msgid) +# define CTX_IFACE_(context, msgid) BLF_translate_do_iface(context, msgid) +# define CTX_TIP_(context, msgid) BLF_translate_do_tooltip(context, msgid) +# define CTX_DATA_(context, msgid) BLF_translate_do_new_dataname(context, msgid) #else -/* #define _(msgid) msgid */ - #define IFACE_(msgid) msgid - #define TIP_(msgid) msgid - #define CTX_IFACE_(context, msgid) ((void)context, msgid) - #define CTX_TIP_(context, msgid) ((void)context, msgid) +/*# define _(msgid) msgid */ +# define IFACE_(msgid) msgid +# define TIP_(msgid) msgid +# define DATA_(msgid) msgid +# define CTX_IFACE_(context, msgid) msgid +# define CTX_TIP_(context, msgid) msgid +# define CTX_DATA_(context, msgid) msgid #endif /* Helper macro, when we want to define a same msgid for multiple msgctxt... * Does nothing in C, but is "parsed" by our i18n py tools. - * XXX Currently limited to at most 16 contexts at most + * XXX Currently limited to at most 16 contexts at once * (but you can call it several times with the same msgid, should you need more contexts!). */ #define BLF_I18N_MSGID_MULTI_CTXT(msgid, ...) @@ -100,10 +117,19 @@ const char *BLF_translate_do_tooltip(const char *msgctxt, const char *msgid); * All i18n contexts must be defined here. * This is a nice way to be sure not to use a context twice for different * things, and limit the number of existing contexts! + * WARNING! Contexts should not be longer than BKE_ST_MAXNAME - 1! */ -/* Default, void context. Just in case... */ -#define BLF_I18NCONTEXT_DEFAULT "" +/* Default, void context. + * WARNING! The "" context is not the same as no (NULL) context at mo/boost::locale level! + * NOTE: We translate BLF_I18NCONTEXT_DEFAULT as BLF_I18NCONTEXT_DEFAULT_BPY in Python, as we can't use "natural" + * None value in rna string properties... :/ + * The void string "" is also interpreted as BLF_I18NCONTEXT_DEFAULT. + * For perf reason, we only use the first char to detect this context, so other contexts should never start + * with the same char! + */ +#define BLF_I18NCONTEXT_DEFAULT NULL +#define BLF_I18NCONTEXT_DEFAULT_BPYRNA "*" /* Default context for operator names/labels. */ #define BLF_I18NCONTEXT_OPERATOR_DEFAULT "Operator" @@ -115,6 +141,7 @@ const char *BLF_translate_do_tooltip(const char *msgctxt, const char *msgid); #define BLF_I18NCONTEXT_ID_BRUSH "Brush" #define BLF_I18NCONTEXT_ID_CAMERA "Camera" #define BLF_I18NCONTEXT_ID_CURVE "Curve" +#define BLF_I18NCONTEXT_ID_FREESTYLELINESTYLE "FreestyleLineStyle" #define BLF_I18NCONTEXT_ID_GPENCIL "GPencil" #define BLF_I18NCONTEXT_ID_GROUP "Group" #define BLF_I18NCONTEXT_ID_ID "ID" @@ -143,4 +170,53 @@ const char *BLF_translate_do_tooltip(const char *msgctxt, const char *msgid); #define BLF_I18NCONTEXT_ID_MOVIECLIP "MovieClip" #define BLF_I18NCONTEXT_ID_MASK "Mask" +/* Helper for bpy.app.i18n object... */ +typedef struct +{ + const char *c_id; + const char *py_id; + const char *value; +} BLF_i18n_contexts_descriptor; + +#define BLF_I18NCONTEXTS_ITEM(ctxt_id, py_id) {#ctxt_id, py_id, ctxt_id} + +#define BLF_I18NCONTEXTS_DESC { \ + BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_DEFAULT, "default_real"), \ + BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_DEFAULT_BPYRNA, "default"), \ + BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "operator_default"), \ + BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_ACTION, "id_action"), \ + BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_ARMATURE, "id_armature"), \ + BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_BRUSH, "id_brush"), \ + BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_CAMERA, "id_camera"), \ + BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_CURVE, "id_curve"), \ + BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_GPENCIL, "id_gpencil"), \ + BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_GROUP, "id_group"), \ + BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_ID, "id_id"), \ + BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_IMAGE, "id_image"), \ + /*BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_IPO, "id_ipo"),*/ \ + BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_SHAPEKEY, "id_shapekey"), \ + BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_LAMP, "id_lamp"), \ + BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_LIBRARY, "id_library"), \ + BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_LATTICE, "id_lattice"), \ + BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_MATERIAL, "id_material"), \ + BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_METABALL, "id_metaball"), \ + BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_MESH, "id_mesh"), \ + BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_NODETREE, "id_nodetree"), \ + BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_OBJECT, "id_object"), \ + BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_PARTICLESETTINGS, "id_particlesettings"), \ + BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_SCENE, "id_scene"), \ + BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_SCREEN, "id_screen"), \ + BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_SEQUENCE, "id_sequence"), \ + BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_SPEAKER, "id_speaker"), \ + BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_SOUND, "id_sound"), \ + BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_TEXTURE, "id_texture"), \ + BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_TEXT, "id_text"), \ + BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_VFONT, "id_vfont"), \ + BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_WORLD, "id_world"), \ + BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_WINDOWMANAGER, "id_windowmanager"), \ + BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_MOVIECLIP, "id_movieclip"), \ + BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_MASK, "id_mask"), \ + {NULL, NULL, NULL} \ +} + #endif /* __BLF_TRANSLATION_H__ */ |