Merge branch 'blender2.7'
[blender.git] / source / blender / blentranslation / BLT_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/blentranslation/BLT_translation.h
29  *  \ingroup blt
30  */
31
32
33 #ifndef __BLT_TRANSLATION_H__
34 #define __BLT_TRANSLATION_H__
35
36 #include "BLI_utildefines.h"  /* for bool type */
37
38 #define TEXT_DOMAIN_NAME "blender"
39
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43
44 bool BLT_is_default_context(const char *msgctxt);
45 const char *BLT_pgettext(const char *msgctxt, const char *msgid);
46
47 /* translation */
48 bool BLT_translate(void);
49 bool BLT_translate_iface(void);
50 bool BLT_translate_tooltips(void);
51 bool BLT_translate_new_dataname(void);
52 const char *BLT_translate_do(const char *msgctxt, const char *msgid);
53 const char *BLT_translate_do_iface(const char *msgctxt, const char *msgid);
54 const char *BLT_translate_do_tooltip(const char *msgctxt, const char *msgid);
55 const char *BLT_translate_do_new_dataname(const char *msgctxt, const char *msgid);
56
57 bool BLT_lang_is_ime_supported(void);
58
59 /* The "translation-marker" macro. */
60 #define N_(msgid) msgid
61 #define CTX_N_(context, msgid) msgid
62
63 /* Those macros should be used everywhere in UI code. */
64 #ifdef WITH_INTERNATIONAL
65 /*#  define _(msgid) BLT_gettext(msgid) */
66 #  define IFACE_(msgid) BLT_translate_do_iface(NULL, msgid)
67 #  define TIP_(msgid) BLT_translate_do_tooltip(NULL, msgid)
68 #  define DATA_(msgid) BLT_translate_do_new_dataname(NULL, msgid)
69 #  define CTX_IFACE_(context, msgid) BLT_translate_do_iface(context, msgid)
70 #  define CTX_TIP_(context, msgid) BLT_translate_do_tooltip(context, msgid)
71 #  define CTX_DATA_(context, msgid) BLT_translate_do_new_dataname(context, msgid)
72 #else
73 /*#  define _(msgid) msgid */
74 #  define IFACE_(msgid) msgid
75 #  define TIP_(msgid)   msgid
76 #  define DATA_(msgid)  msgid
77 #  define CTX_IFACE_(context, msgid) msgid
78 #  define CTX_TIP_(context, msgid)   msgid
79 #  define CTX_DATA_(context, msgid)  msgid
80 #endif
81
82 /* Helper macro, when we want to define a same msgid for multiple msgctxt...
83  * Does nothing in C, but is "parsed" by our i18n py tools.
84  * XXX Currently limited to at most 16 contexts at once
85  *     (but you can call it several times with the same msgid, should you need more contexts!).
86  */
87 #define BLT_I18N_MSGID_MULTI_CTXT(msgid, ...)
88
89 /******************************************************************************
90  * All i18n contexts must be defined here.
91  * This is a nice way to be sure not to use a context twice for different
92  * things, and limit the number of existing contexts!
93  * WARNING! Contexts should not be longer than BKE_ST_MAXNAME - 1!
94  */
95
96 /* Default, void context.
97  * WARNING! The "" context is not the same as no (NULL) context at mo/boost::locale level!
98  * NOTE: We translate BLT_I18NCONTEXT_DEFAULT as BLT_I18NCONTEXT_DEFAULT_BPY in Python, as we can't use "natural"
99  *       None value in rna string properties... :/
100  *       The void string "" is also interpreted as BLT_I18NCONTEXT_DEFAULT.
101  *       For perf reason, we only use the first char to detect this context, so other contexts should never start
102  *       with the same char!
103  */
104 #define BLT_I18NCONTEXT_DEFAULT NULL
105 #define BLT_I18NCONTEXT_DEFAULT_BPYRNA "*"
106
107 /* Default context for operator names/labels. */
108 #define BLT_I18NCONTEXT_OPERATOR_DEFAULT "Operator"
109
110 /* Context for events/keymaps (necessary, since those often use one or two letters,
111  * easy to get collisions with other areas...). */
112 #define BLT_I18NCONTEXT_UI_EVENTS "UI_Events_KeyMaps"
113
114 /* Mark the msgid applies to several elements (needed in some cases, as english adjectives have no plural mark :( ). */
115 #define BLT_I18NCONTEXT_PLURAL "Plural"
116
117 /* ID-types contexts. */
118 /* WARNING! Keep it in sync with idtypes in blenkernel/intern/idcode.c */
119 #define BLT_I18NCONTEXT_ID_ACTION               "Action"
120 #define BLT_I18NCONTEXT_ID_ARMATURE             "Armature"
121 #define BLT_I18NCONTEXT_ID_BRUSH                "Brush"
122 #define BLT_I18NCONTEXT_ID_CAMERA               "Camera"
123 #define BLT_I18NCONTEXT_ID_CACHEFILE            "CacheFile"
124 #define BLT_I18NCONTEXT_ID_COLLECTION           "Collection"
125 #define BLT_I18NCONTEXT_ID_CURVE                "Curve"
126 #define BLT_I18NCONTEXT_ID_FREESTYLELINESTYLE   "FreestyleLineStyle"
127 #define BLT_I18NCONTEXT_ID_GPENCIL              "GPencil"
128 #define BLT_I18NCONTEXT_ID_ID                   "ID"
129 #define BLT_I18NCONTEXT_ID_IMAGE                "Image"
130 /*#define BLT_I18NCONTEXT_ID_IPO                  "Ipo"*/ /* Deprecated */
131 #define BLT_I18NCONTEXT_ID_SHAPEKEY             "Key"
132 #define BLT_I18NCONTEXT_ID_LAMP                 "Lamp"
133 #define BLT_I18NCONTEXT_ID_LIBRARY              "Library"
134 #define BLT_I18NCONTEXT_ID_LATTICE              "Lattice"
135 #define BLT_I18NCONTEXT_ID_MATERIAL             "Material"
136 #define BLT_I18NCONTEXT_ID_METABALL             "Metaball"
137 #define BLT_I18NCONTEXT_ID_MESH                 "Mesh"
138 #define BLT_I18NCONTEXT_ID_NODETREE             "NodeTree"
139 #define BLT_I18NCONTEXT_ID_OBJECT               "Object"
140 #define BLT_I18NCONTEXT_ID_PAINTCURVE           "PaintCurve"
141 #define BLT_I18NCONTEXT_ID_PALETTE              "Palette"
142 #define BLT_I18NCONTEXT_ID_PARTICLESETTINGS     "ParticleSettings"
143 #define BLT_I18NCONTEXT_ID_LIGHTPROBE           "LightProbe"
144 #define BLT_I18NCONTEXT_ID_SCENE                "Scene"
145 #define BLT_I18NCONTEXT_ID_SCREEN               "Screen"
146 #define BLT_I18NCONTEXT_ID_SEQUENCE             "Sequence"
147 #define BLT_I18NCONTEXT_ID_SPEAKER              "Speaker"
148 #define BLT_I18NCONTEXT_ID_SOUND                "Sound"
149 #define BLT_I18NCONTEXT_ID_TEXTURE              "Texture"
150 #define BLT_I18NCONTEXT_ID_TEXT                 "Text"
151 #define BLT_I18NCONTEXT_ID_VFONT                "VFont"
152 #define BLT_I18NCONTEXT_ID_WORLD                "World"
153 #define BLT_I18NCONTEXT_ID_WORKSPACE            "WorkSpace"
154 #define BLT_I18NCONTEXT_ID_WINDOWMANAGER        "WindowManager"
155 #define BLT_I18NCONTEXT_ID_MOVIECLIP            "MovieClip"
156 #define BLT_I18NCONTEXT_ID_MASK                 "Mask"
157
158 /* Helper for bpy.app.i18n object... */
159 typedef struct {
160         const char *c_id;
161         const char *py_id;
162         const char *value;
163 } BLT_i18n_contexts_descriptor;
164
165 #define BLT_I18NCONTEXTS_ITEM(ctxt_id, py_id) {#ctxt_id, py_id, ctxt_id}
166
167 #define BLT_I18NCONTEXTS_DESC {                                                                                        \
168         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_DEFAULT, "default_real"),                                                    \
169         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_DEFAULT_BPYRNA, "default"),                                                  \
170         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "operator_default"),                                       \
171         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_UI_EVENTS, "ui_events_keymaps"),                                             \
172         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_PLURAL, "plural"),                                                           \
173         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_ACTION, "id_action"),                                                     \
174         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_ARMATURE, "id_armature"),                                                 \
175         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_BRUSH, "id_brush"),                                                       \
176         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_CAMERA, "id_camera"),                                                     \
177         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_CACHEFILE, "id_cachefile"),                                               \
178         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_COLLECTION, "id_collection"),                                             \
179         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_CURVE, "id_curve"),                                                       \
180         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_FREESTYLELINESTYLE, "id_fs_linestyle"),                                   \
181         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_GPENCIL, "id_gpencil"),                                                   \
182         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_ID, "id_id"),                                                             \
183         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_IMAGE, "id_image"),                                                       \
184         /*BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_IPO, "id_ipo"),*/                                                       \
185         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_SHAPEKEY, "id_shapekey"),                                                 \
186         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_LAMP, "id_lamp"),                                                         \
187         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_LIBRARY, "id_library"),                                                   \
188         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_LATTICE, "id_lattice"),                                                   \
189         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_MASK, "id_mask"),                                                         \
190         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_MATERIAL, "id_material"),                                                 \
191         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_METABALL, "id_metaball"),                                                 \
192         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_MESH, "id_mesh"),                                                         \
193         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_MOVIECLIP, "id_movieclip"),                                               \
194         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_NODETREE, "id_nodetree"),                                                 \
195         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_OBJECT, "id_object"),                                                     \
196         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_PAINTCURVE, "id_paintcurve"),                                             \
197         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_PALETTE, "id_palette"),                                                   \
198         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_PARTICLESETTINGS, "id_particlesettings"),                                 \
199         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_LIGHTPROBE, "id_lightprobe"),                                             \
200         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_SCENE, "id_scene"),                                                       \
201         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_SCREEN, "id_screen"),                                                     \
202         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_SEQUENCE, "id_sequence"),                                                 \
203         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_SPEAKER, "id_speaker"),                                                   \
204         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_SOUND, "id_sound"),                                                       \
205         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_TEXTURE, "id_texture"),                                                   \
206         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_TEXT, "id_text"),                                                         \
207         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_VFONT, "id_vfont"),                                                       \
208         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_WORLD, "id_world"),                                                       \
209         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_WORKSPACE, "id_workspace"),                                               \
210         BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_WINDOWMANAGER, "id_windowmanager"),                                       \
211         {NULL, NULL, NULL}                                                                                                 \
212 }
213
214 #ifdef __cplusplus
215 };
216 #endif
217
218 #endif /* __BLT_TRANSLATION_H__ */