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