Welcome to mirror list, hosted at ThFree Co, Russian Federation.

BLF_translation.h « blenfont « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b42e6f800229dda7d49efc14fa474ec630304f05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
/*
 * ***** BEGIN GPL LICENSE BLOCK *****
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version. 
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * The Original Code is Copyright (C) 2011 Blender Foundation.
 * All rights reserved.
 *
 *
 * Contributor(s): Blender Foundation,
 *                 Sergey Sharybin
 *
 * ***** END GPL LICENSE BLOCK *****
 */

/** \file blender/blenfont/BLF_translation.h
 *  \ingroup blf
 */


#ifndef __BLF_TRANSLATION_H__
#define __BLF_TRANSLATION_H__

#include "BLI_utildefines.h"  /* for bool type */

#define TEXT_DOMAIN_NAME "blender"

#ifdef __cplusplus
extern "C" {
#endif

/* blf_lang.c */

/* Search the path directory to the locale files, this try all
 * the case for Linux, Win and Mac.
 * Also dynamically builds locales and locales' menu from "languages" text file.
 */
void BLF_lang_init(void);

/* Free languages and locales_menu arrays created by BLF_lang_init. */
void BLF_lang_free(void);

/* Set the current locale. */
void BLF_lang_set(const char *);
/* 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  */

unsigned char *BLF_get_unifont(int *unifont_size);
void BLF_free_unifont(void);
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 */
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. */
#define N_(msgid) msgid
#define CTX_N_(context, msgid) 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 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 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 once
 *     (but you can call it several times with the same msgid, should you need more contexts!).
 */
#define BLF_I18N_MSGID_MULTI_CTXT(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.
 * 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"

/* Mark the msgid applies to several elements (needed in some cases, as english adjectives have no plural mark. :( */
#define BLF_I18NCONTEXT_PLURAL "Plural"

/* ID-types contexts. */
/* WARNING! Keep it in sync with idtypes in blenkernel/intern/idcode.c */
#define BLF_I18NCONTEXT_ID_ACTION               "Action"
#define BLF_I18NCONTEXT_ID_ARMATURE             "Armature"
#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"
#define BLF_I18NCONTEXT_ID_IMAGE                "Image"
/*#define BLF_I18NCONTEXT_ID_IPO                  "Ipo"*/ /* Deprecated */
#define BLF_I18NCONTEXT_ID_SHAPEKEY             "Key"
#define BLF_I18NCONTEXT_ID_LAMP                 "Lamp"
#define BLF_I18NCONTEXT_ID_LIBRARY              "Library"
#define BLF_I18NCONTEXT_ID_LATTICE              "Lattice"
#define BLF_I18NCONTEXT_ID_MATERIAL             "Material"
#define BLF_I18NCONTEXT_ID_METABALL             "Metaball"
#define BLF_I18NCONTEXT_ID_MESH                 "Mesh"
#define BLF_I18NCONTEXT_ID_NODETREE             "NodeTree"
#define BLF_I18NCONTEXT_ID_OBJECT               "Object"
#define BLF_I18NCONTEXT_ID_PAINTCURVE           "PaintCurve"
#define BLF_I18NCONTEXT_ID_PALETTE              "Palette"
#define BLF_I18NCONTEXT_ID_PARTICLESETTINGS     "ParticleSettings"
#define BLF_I18NCONTEXT_ID_SCENE                "Scene"
#define BLF_I18NCONTEXT_ID_SCREEN               "Screen"
#define BLF_I18NCONTEXT_ID_SEQUENCE             "Sequence"
#define BLF_I18NCONTEXT_ID_SPEAKER              "Speaker"
#define BLF_I18NCONTEXT_ID_SOUND                "Sound"
#define BLF_I18NCONTEXT_ID_TEXTURE              "Texture"
#define BLF_I18NCONTEXT_ID_TEXT                 "Text"
#define BLF_I18NCONTEXT_ID_VFONT                "VFont"
#define BLF_I18NCONTEXT_ID_WORLD                "World"
#define BLF_I18NCONTEXT_ID_WINDOWMANAGER        "WindowManager"
#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_PLURAL, "plural"),                                                           \
	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_FREESTYLELINESTYLE, "id_fs_linestyle"),                                   \
	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_MASK, "id_mask"),                                                         \
	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_MOVIECLIP, "id_movieclip"),                                               \
	BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_NODETREE, "id_nodetree"),                                                 \
	BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_OBJECT, "id_object"),                                                     \
	BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_PAINTCURVE, "id_paintcurve"),                                             \
	BLF_I18NCONTEXTS_ITEM(BLF_I18NCONTEXT_ID_PALETTE, "id_palette"),                                                   \
	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"),                                       \
	{NULL, NULL, NULL}                                                                                                 \
}

#ifdef __cplusplus
};
#endif

#endif /* __BLF_TRANSLATION_H__ */