Fix [#34005] blender will close immediately in debug mode on deleting objects
[blender.git] / source / blender / blenfont / BLF_translation.h
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version. 
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * The Original Code is Copyright (C) 2011 Blender Foundation.
19  * All rights reserved.
20  *
21  *
22  * Contributor(s): Blender Foundation,
23  *                 Sergey Sharybin
24  *
25  * ***** END GPL LICENSE BLOCK *****
26  */
27
28 /** \file blender/blenfont/BLF_translation.h
29  *  \ingroup blf
30  */
31
32
33 #ifndef __BLF_TRANSLATION_H__
34 #define __BLF_TRANSLATION_H__
35
36 #include "BLI_utildefines.h"  /* for bool type */
37
38 #define TEXT_DOMAIN_NAME "blender"
39
40 /* blf_lang.c */
41
42 /* Search the path directory to the locale files, this try all
43  * the case for Linux, Win and Mac.
44  * Also dynamically builds locales and locales' menu from "languages" text file.
45  */
46 void BLF_lang_init(void);
47
48 /* Free languages and locales_menu arrays created by BLF_lang_init. */
49 void BLF_lang_free(void);
50
51 /* Set the current locale. */
52 void BLF_lang_set(const char *);
53 /* Get the current locale ([partial] ISO code, e.g. es_ES). */
54 const char *BLF_lang_get(void);
55
56 /* Get locale's elements (if relevant pointer is not NULL and element actually exists, e.g. if there is no variant,
57  * *variant and *language_variant will always be NULL).
58  * Non-null elements are always MEM_mallocN'ed, it's the caller's responsibility to free them.
59  * NOTE: Always available, even in non-WITH_INTERNATIONAL builds.
60  */
61 void BLF_locale_explode(const char *locale, char **language, char **country, char **variant,
62                         char **language_country, char **language_variant);
63
64 /* Get EnumPropertyItem's for translations menu. */
65 struct EnumPropertyItem *BLF_RNA_lang_enum_properties(void);
66
67 /* blf_translation.c  */
68
69 unsigned char *BLF_get_unifont(int *unifont_size);
70 void BLF_free_unifont(void);
71
72 const char *BLF_pgettext(const char *msgctxt, const char *msgid);
73
74 /* translation */
75 bool BLF_translate_iface(void);
76 bool BLF_translate_tooltips(void);
77 const char *BLF_translate_do_iface(const char *msgctxt, const char *msgid);
78 const char *BLF_translate_do_tooltip(const char *msgctxt, const char *msgid);
79
80
81 /* The "translation-marker" macro. */
82 #define N_(msgid) msgid
83 #define CTX_N_(context, msgid) msgid
84
85 /* Those macros should be used everywhere in UI code. */
86 #ifdef WITH_INTERNATIONAL
87 /*#  define _(msgid) BLF_gettext(msgid) */
88 #  define IFACE_(msgid) BLF_translate_do_iface(NULL, msgid)
89 #  define TIP_(msgid) BLF_translate_do_tooltip(NULL, msgid)
90 #  define CTX_IFACE_(context, msgid) BLF_translate_do_iface(context, msgid)
91 #  define CTX_TIP_(context, msgid) BLF_translate_do_tooltip(context, msgid)
92 #else
93 /*#  define _(msgid) msgid */
94 #  define IFACE_(msgid) msgid
95 #  define TIP_(msgid)   msgid
96 #  define CTX_IFACE_(context, msgid) msgid
97 #  define CTX_TIP_(context, msgid)   msgid
98 #endif
99
100 /* Helper macro, when we want to define a same msgid for multiple msgctxt...
101  * Does nothing in C, but is "parsed" by our i18n py tools.
102  * XXX Currently limited to at most 16 contexts at most
103  *     (but you can call it several times with the same msgid, should you need more contexts!).
104  */
105 #define BLF_I18N_MSGID_MULTI_CTXT(msgid, ...)
106
107 /******************************************************************************
108  * All i18n contexts must be defined here.
109  * This is a nice way to be sure not to use a context twice for different
110  * things, and limit the number of existing contexts!
111  */
112
113 /* Default, void context.
114  * WARNING! The "" context is not the same as no (NULL) context at mo/boost::locale level!
115  */
116 #define BLF_I18NCONTEXT_DEFAULT NULL  /* Translated as None in Python. */
117 #define BLF_I18NCONTEXT_DEFAULT_BPY_INTERN ""  /* Only used in code, never exposed to user! */
118
119 /* Default context for operator names/labels. */
120 #define BLF_I18NCONTEXT_OPERATOR_DEFAULT "Operator"
121
122 /* ID-types contexts. */
123 /* WARNING! Keep it in sync with idtypes in blenkernel/intern/idcode.c */
124 #define BLF_I18NCONTEXT_ID_ACTION               "Action"
125 #define BLF_I18NCONTEXT_ID_ARMATURE             "Armature"
126 #define BLF_I18NCONTEXT_ID_BRUSH                "Brush"
127 #define BLF_I18NCONTEXT_ID_CAMERA               "Camera"
128 #define BLF_I18NCONTEXT_ID_CURVE                "Curve"
129 #define BLF_I18NCONTEXT_ID_GPENCIL              "GPencil"
130 #define BLF_I18NCONTEXT_ID_GROUP                "Group"
131 #define BLF_I18NCONTEXT_ID_ID                   "ID"
132 #define BLF_I18NCONTEXT_ID_IMAGE                "Image"
133 /*#define BLF_I18NCONTEXT_ID_IPO                  "Ipo"*/ /* Deprecated */
134 #define BLF_I18NCONTEXT_ID_SHAPEKEY             "Key"
135 #define BLF_I18NCONTEXT_ID_LAMP                 "Lamp"
136 #define BLF_I18NCONTEXT_ID_LIBRARY              "Library"
137 #define BLF_I18NCONTEXT_ID_LATTICE              "Lattice"
138 #define BLF_I18NCONTEXT_ID_MATERIAL             "Material"
139 #define BLF_I18NCONTEXT_ID_METABALL             "Metaball"
140 #define BLF_I18NCONTEXT_ID_MESH                 "Mesh"
141 #define BLF_I18NCONTEXT_ID_NODETREE             "NodeTree"
142 #define BLF_I18NCONTEXT_ID_OBJECT               "Object"
143 #define BLF_I18NCONTEXT_ID_PARTICLESETTINGS     "ParticleSettings"
144 #define BLF_I18NCONTEXT_ID_SCENE                "Scene"
145 #define BLF_I18NCONTEXT_ID_SCREEN               "Screen"
146 #define BLF_I18NCONTEXT_ID_SEQUENCE             "Sequence"
147 #define BLF_I18NCONTEXT_ID_SPEAKER              "Speaker"
148 #define BLF_I18NCONTEXT_ID_SOUND                "Sound"
149 #define BLF_I18NCONTEXT_ID_TEXTURE              "Texture"
150 #define BLF_I18NCONTEXT_ID_TEXT                 "Text"
151 #define BLF_I18NCONTEXT_ID_VFONT                "VFont"
152 #define BLF_I18NCONTEXT_ID_WORLD                "World"
153 #define BLF_I18NCONTEXT_ID_WINDOWMANAGER        "WindowManager"
154 #define BLF_I18NCONTEXT_ID_MOVIECLIP            "MovieClip"
155 #define BLF_I18NCONTEXT_ID_MASK                 "Mask"
156
157 /* Helper for bpy.app.i18n object... */
158 typedef struct
159 {
160         const char *c_id;
161         const char *py_id;
162         const char *value;
163 } BLF_i18n_contexts_descriptor;
164
165 #define BLF_I18NCONTEXTS_ITEM(ctxt_id, py_id) {#ctxt_id, py_id, ctxt_id}
166
167 #define BLF_I18NCONTEXTS_DESC {                                                                                        \
168         BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_DEFAULT, "default"),                                                         \
169         BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "operator_default"),                                       \
170         BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_ACTION, "id_action"),                                                     \
171         BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_ARMATURE, "id_armature"),                                                 \
172         BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_BRUSH, "id_brush"),                                                       \
173         BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_CAMERA, "id_camera"),                                                     \
174         BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_CURVE, "id_curve"),                                                       \
175         BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_GPENCIL, "id_gpencil"),                                                   \
176         BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_GROUP, "id_group"),                                                       \
177         BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_ID, "id_id"),                                                             \
178         BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_IMAGE, "id_image"),                                                       \
179         /*BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_IPO, "id_ipo"),*/                                                       \
180         BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_SHAPEKEY, "id_shapekey"),                                                 \
181         BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_LAMP, "id_lamp"),                                                         \
182         BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_LIBRARY, "id_library"),                                                   \
183         BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_LATTICE, "id_lattice"),                                                   \
184         BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_MATERIAL, "id_material"),                                                 \
185         BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_METABALL, "id_metaball"),                                                 \
186         BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_MESH, "id_mesh"),                                                         \
187         BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_NODETREE, "id_nodetree"),                                                 \
188         BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_OBJECT, "id_object"),                                                     \
189         BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_PARTICLESETTINGS, "id_particlesettings"),                                 \
190         BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_SCENE, "id_scene"),                                                       \
191         BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_SCREEN, "id_screen"),                                                     \
192         BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_SEQUENCE, "id_sequence"),                                                 \
193         BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_SPEAKER, "id_speaker"),                                                   \
194         BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_SOUND, "id_sound"),                                                       \
195         BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_TEXTURE, "id_texture"),                                                   \
196         BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_TEXT, "id_text"),                                                         \
197         BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_VFONT, "id_vfont"),                                                       \
198         BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_WORLD, "id_world"),                                                       \
199         BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_WINDOWMANAGER, "id_windowmanager"),                                       \
200         BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_MOVIECLIP, "id_movieclip"),                                               \
201         BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_MASK, "id_mask"),                                                         \
202         {NULL, NULL, NULL}                                                                                                 \
203 }
204
205 #endif /* __BLF_TRANSLATION_H__ */