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