Blender V5.3
BLT_translation.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#include "BLI_string_ref.hh"
12
13#define TEXT_DOMAIN_NAME "blender"
14
15namespace blender {
16
17bool BLT_is_default_context(StringRef msgctxt);
18const char *BLT_pgettext(const char *msgctxt, const char *msgid);
19StringRef BLT_pgettext(StringRef msgctxt, StringRef msgid);
20
21/* Translation */
22/* - iface includes buttons in the user interface: short labels displayed in windows, panels,
23 * menus.
24 * - tooltips only include the popup tooltips when hovering a button.
25 * - report is for longer, additional information displayed in the UI, such as error messages.
26 * - new_dataname is the actual user-created data such as objects, meshes, etc. */
27bool BLT_translate();
32const char *BLT_translate_do(const char *msgctxt, const char *msgid);
33StringRef BLT_translate_do(StringRef msgctxt, StringRef msgid);
34const char *BLT_translate_do_iface(const char *msgctxt, const char *msgid);
35StringRef BLT_translate_do_iface(StringRef msgctxt, StringRef msgid);
36const char *BLT_translate_do_tooltip(const char *msgctxt, const char *msgid);
37StringRef BLT_translate_do_tooltip(StringRef msgctxt, StringRef msgid);
38const char *BLT_translate_do_report(const char *msgctxt, const char *msgid);
39StringRef BLT_translate_do_report(StringRef msgctxt, StringRef msgid);
40const char *BLT_translate_do_new_dataname(const char *msgctxt, const char *msgid);
41StringRef BLT_translate_do_new_dataname(StringRef msgctxt, StringRef msgid);
42
43/* The "translation-marker" macro. */
44#define N_(msgid) msgid
45#define CTX_N_(context, msgid) msgid
46
47/* These macros should be used everywhere in UI code. */
48// #define _(msgid) BLT_gettext(msgid)
49#define IFACE_(msgid) BLT_translate_do_iface(NULL, msgid)
50#define TIP_(msgid) BLT_translate_do_tooltip(NULL, msgid)
51#define RPT_(msgid) BLT_translate_do_report(NULL, msgid)
52#define DATA_(msgid) BLT_translate_do_new_dataname(NULL, msgid)
53#define CTX_IFACE_(context, msgid) BLT_translate_do_iface(context, msgid)
54#define CTX_TIP_(context, msgid) BLT_translate_do_tooltip(context, msgid)
55#define CTX_RPT_(context, msgid) BLT_translate_do_report(context, msgid)
56#define CTX_DATA_(context, msgid) BLT_translate_do_new_dataname(context, msgid)
57
58/* Helper macro, when we want to define a same msgid for multiple msgctxt...
59 * Does nothing in C, but is "parsed" by our i18n py tools.
60 * XXX Currently limited to at most 16 contexts at once
61 * (but you can call it several times with the same msgid, should you need more contexts!).
62 */
63#define BLT_I18N_MSGID_MULTI_CTXT(msgid, ...)
64
65/******************************************************************************
66 * All i18n contexts must be defined here.
67 * This is a nice way to be sure not to use a context twice for different
68 * things, and limit the number of existing contexts!
69 * WARNING! Contexts should not be longer than BKE_ST_MAXNAME - 1!
70 */
71
72/* Default, void context.
73 * WARNING! The "" context is not the same as no (NULL) context at mo/boost::locale level!
74 * NOTE: We translate BLT_I18NCONTEXT_DEFAULT as BLT_I18NCONTEXT_DEFAULT_BPY in Python,
75 * as we can't use "natural" None value in rna string properties... :/
76 * The void string "" is also interpreted as BLT_I18NCONTEXT_DEFAULT.
77 * For performance reason, we only use the first char to detect this context,
78 * so other contexts should never start with the same char!
79 */
80#define BLT_I18NCONTEXT_DEFAULT NULL
81#define BLT_I18NCONTEXT_DEFAULT_BPYRNA "*"
82
83/* Default context for operator names/labels. */
84#define BLT_I18NCONTEXT_OPERATOR_DEFAULT "Operator"
85
86/* Context for events/keymaps (necessary, since those often use one or two letters,
87 * easy to get collisions with other areas...). */
88#define BLT_I18NCONTEXT_UI_EVENTS "UI_Events_KeyMaps"
89
90/* Mark the msgid applies to several elements
91 * (needed in some cases, as English adjectives have no plural mark :( ). */
92#define BLT_I18NCONTEXT_PLURAL "Plural"
93
94/* Some words can be either countable or uncountable in English, but translate to different words
95 * in other languages. An example is "Amount", which can refer to "a number of things", countable,
96 * or "a quantity or volume", uncountable. */
97#define BLT_I18NCONTEXT_COUNTABLE "Countable"
98
99/* Special cases when translation cannot be avoided, for example in an interface where some props
100 * are built-in (translatable) and others are user-defined (non-translatable), but we don't know
101 * which ones in advance.
102 * It allows specifying explicitly that translation should not occur for user data when building
103 * the UI. */
104#define BLT_I18NCONTEXT_NO_TRANSLATION "Do not translate"
105
106/* ID-types contexts. */
107/* WARNING! Keep it in sync with ID-types in `blenkernel/intern/idtype.cc`. */
108#define BLT_I18NCONTEXT_ID_ACTION "Action"
109#define BLT_I18NCONTEXT_ID_ANIMATION "Animation"
110#define BLT_I18NCONTEXT_ID_ARMATURE "Armature"
111#define BLT_I18NCONTEXT_ID_BRUSH "Brush"
112#define BLT_I18NCONTEXT_ID_CACHEFILE "CacheFile"
113#define BLT_I18NCONTEXT_ID_CAMERA "Camera"
114#define BLT_I18NCONTEXT_ID_COLLECTION "Collection"
115#define BLT_I18NCONTEXT_ID_CURVES "Curves"
116#define BLT_I18NCONTEXT_ID_CURVE_LEGACY "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_LATTICE "Lattice"
123#define BLT_I18NCONTEXT_ID_LIBRARY "Library"
124#define BLT_I18NCONTEXT_ID_LIGHT "Light"
125#define BLT_I18NCONTEXT_ID_LIGHTPROBE "LightProbe"
126#define BLT_I18NCONTEXT_ID_MASK "Mask"
127#define BLT_I18NCONTEXT_ID_MATERIAL "Material"
128#define BLT_I18NCONTEXT_ID_MESH "Mesh"
129#define BLT_I18NCONTEXT_ID_METABALL "Metaball"
130#define BLT_I18NCONTEXT_ID_MOVIECLIP "MovieClip"
131#define BLT_I18NCONTEXT_ID_NODETREE "NodeTree"
132#define BLT_I18NCONTEXT_ID_OBJECT "Object"
133#define BLT_I18NCONTEXT_ID_PAINTCURVE "PaintCurve"
134#define BLT_I18NCONTEXT_ID_PALETTE "Palette"
135#define BLT_I18NCONTEXT_ID_PARTICLESETTINGS "ParticleSettings"
136#define BLT_I18NCONTEXT_ID_POINTCLOUD "PointCloud"
137#define BLT_I18NCONTEXT_ID_SCENE "Scene"
138#define BLT_I18NCONTEXT_ID_SCREEN "Screen"
139#define BLT_I18NCONTEXT_ID_SEQUENCE "Sequence"
140#define BLT_I18NCONTEXT_ID_SHAPEKEY "Key"
141#define BLT_I18NCONTEXT_ID_SIMULATION "Simulation"
142#define BLT_I18NCONTEXT_ID_SOUND "Sound"
143#define BLT_I18NCONTEXT_ID_SPEAKER "Speaker"
144#define BLT_I18NCONTEXT_ID_TEXT "Text"
145#define BLT_I18NCONTEXT_ID_TEXTURE "Texture"
146#define BLT_I18NCONTEXT_ID_VFONT "VFont"
147#define BLT_I18NCONTEXT_ID_VOLUME "Volume"
148#define BLT_I18NCONTEXT_ID_WINDOWMANAGER "WindowManager"
149#define BLT_I18NCONTEXT_ID_WORKSPACE "WorkSpace"
150#define BLT_I18NCONTEXT_ID_WORLD "World"
151
152/* Editors-types contexts. */
153#define BLT_I18NCONTEXT_EDITOR_FILEBROWSER "File browser"
154#define BLT_I18NCONTEXT_EDITOR_PREFERENCES "Preferences"
155#define BLT_I18NCONTEXT_EDITOR_PYTHON_CONSOLE "Python console"
156#define BLT_I18NCONTEXT_EDITOR_VIEW3D "View3D"
157
158/* Generic contexts. */
159#define BLT_I18NCONTEXT_AMOUNT "Amount"
160#define BLT_I18NCONTEXT_COLOR "Color"
161#define BLT_I18NCONTEXT_COLOR_MANAGEMENT "Color Management"
162#define BLT_I18NCONTEXT_CONSTRAINT "Constraint"
163#define BLT_I18NCONTEXT_MODIFIER "Modifier"
164#define BLT_I18NCONTEXT_NAVIGATION "Navigation"
165#define BLT_I18NCONTEXT_RENDER_LAYER "Render Layer"
166#define BLT_I18NCONTEXT_TIME "Time"
167#define BLT_I18NCONTEXT_UNIT "Unit"
168
169/* Helper for bpy.app.i18n object... */
171 const char *c_id;
172 const char *py_id;
173 const char *value;
174};
175
176#define BLT_I18NCONTEXTS_ITEM(ctxt_id, py_id) {#ctxt_id, py_id, ctxt_id}
177
178#define BLT_I18NCONTEXTS_DESC \
179 { \
180 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_DEFAULT, "default_real"), \
181 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_DEFAULT_BPYRNA, "default"), \
182 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "operator_default"), \
183 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_UI_EVENTS, "ui_events_keymaps"), \
184 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_PLURAL, "plural"), \
185 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_COUNTABLE, "countable"), \
186 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_ACTION, "id_action"), \
187 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_ARMATURE, "id_armature"), \
188 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_NO_TRANSLATION, "no_translation"), \
189 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_BRUSH, "id_brush"), \
190 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_CACHEFILE, "id_cachefile"), \
191 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_CAMERA, "id_camera"), \
192 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_COLLECTION, "id_collection"), \
193 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_CURVES, "id_curves"), \
194 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_CURVE_LEGACY, "id_curve"), \
195 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_FREESTYLELINESTYLE, "id_fs_linestyle"), \
196 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_GPENCIL, "id_gpencil"), \
197 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_ID, "id_id"), \
198 BLT_I18NCONTEXTS_ITEM( \
199 BLT_I18NCONTEXT_ID_IMAGE, \
200 "id_image"), /* BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_IPO, "id_ipo"), */ \
201 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_LATTICE, "id_lattice"), \
202 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_LIBRARY, "id_library"), \
203 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_LIGHT, "id_light"), \
204 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_LIGHTPROBE, "id_lightprobe"), \
205 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_MASK, "id_mask"), \
206 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_MATERIAL, "id_material"), \
207 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_MESH, "id_mesh"), \
208 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_METABALL, "id_metaball"), \
209 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_MOVIECLIP, "id_movieclip"), \
210 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_NODETREE, "id_nodetree"), \
211 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_OBJECT, "id_object"), \
212 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_PAINTCURVE, "id_paintcurve"), \
213 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_PALETTE, "id_palette"), \
214 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_PARTICLESETTINGS, "id_particlesettings"), \
215 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_POINTCLOUD, "id_pointcloud"), \
216 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_SCENE, "id_scene"), \
217 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_SCREEN, "id_screen"), \
218 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_SEQUENCE, "id_sequence"), \
219 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_SHAPEKEY, "id_shapekey"), \
220 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_SIMULATION, "id_simulation"), \
221 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_SOUND, "id_sound"), \
222 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_SPEAKER, "id_speaker"), \
223 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_TEXT, "id_text"), \
224 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_TEXTURE, "id_texture"), \
225 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_VFONT, "id_vfont"), \
226 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_VOLUME, "id_volume"), \
227 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_WINDOWMANAGER, "id_windowmanager"), \
228 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_WORKSPACE, "id_workspace"), \
229 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_WORLD, "id_world"), \
230 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_EDITOR_FILEBROWSER, "editor_filebrowser"), \
231 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_EDITOR_PYTHON_CONSOLE, "editor_python_console"), \
232 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_EDITOR_PREFERENCES, "editor_preferences"), \
233 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_EDITOR_VIEW3D, "editor_view3d"), \
234 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_AMOUNT, "amount"), \
235 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_COLOR, "color"), \
236 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_COLOR_MANAGEMENT, "color_management"), \
237 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_CONSTRAINT, "constraint"), \
238 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_MODIFIER, "modifier"), \
239 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_NAVIGATION, "navigation"), \
240 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_RENDER_LAYER, "render_layer"), \
241 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_TIME, "time"), \
242 BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_UNIT, "unit"), \
243 { \
244 NULL, NULL, NULL \
245 } \
246 }
247
248} // namespace blender
BMesh Iterators.
bool BLT_translate_tooltips()
bool BLT_is_default_context(StringRef msgctxt)
bool BLT_translate_new_dataname()
const char * BLT_pgettext(const char *msgctxt, const char *msgid)
const char * BLT_translate_do(const char *msgctxt, const char *msgid)
const char * BLT_translate_do_report(const char *msgctxt, const char *msgid)
bool BLT_translate()
const char * BLT_translate_do_iface(const char *msgctxt, const char *msgid)
bool BLT_translate_reports()
bool BLT_translate_iface()
const char * BLT_translate_do_new_dataname(const char *msgctxt, const char *msgid)
const char * BLT_translate_do_tooltip(const char *msgctxt, const char *msgid)