From 7bc693d1075a72b2f6c7abb1239432b4c442a92f Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sat, 17 Mar 2012 14:42:44 +0000 Subject: Big step forward nodes UI translation: *Add menu is now translated. *Nodes' title is now translated. *Nodes' sockets' labels are now translated. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit However, about the last point, and unless I’m mistaking, we’ll have to add the "i18n tag" N_() to all sockets' names, in the input/ouput templates declaration, in all nodes' files, as those sockets are collections created at runtime, I think po-generating script has no way to access that from bpy.types... Quite a piece of (borring) work. :/ --- source/blender/blenkernel/intern/node.c | 6 ++--- source/blender/editors/space_node/node_draw.c | 26 +++++++++++++--------- source/blender/editors/space_node/node_header.c | 10 ++++----- .../nodes/node_composite_moviedistortion.c | 6 +++-- source/blender/nodes/intern/node_common.c | 4 +++- source/blender/nodes/intern/node_util.c | 10 +++++---- 6 files changed, 36 insertions(+), 26 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 8b9955dd378..f3320a0b31d 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -55,6 +55,8 @@ #include "BLI_path_util.h" #include "BLI_utildefines.h" +#include "BLF_translation.h" + #include "BKE_animsys.h" #include "BKE_action.h" #include "BKE_fcurve.h" @@ -66,8 +68,6 @@ #include "BKE_utildefines.h" #include "BKE_utildefines.h" -#include "BLI_listbase.h" - #include "RNA_access.h" #include "NOD_socket.h" @@ -1658,7 +1658,7 @@ const char* nodeLabel(bNode *node) else if (node->typeinfo->labelfunc) return node->typeinfo->labelfunc(node); else - return node->typeinfo->name; + return IFACE_(node->typeinfo->name); } struct bNodeTree *nodeGroupEditGet(struct bNode *node) diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index a2775832c1d..46850d4ff60 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -49,6 +49,8 @@ #include "BLI_threads.h" #include "BLI_utildefines.h" +#include "BLF_translation.h" + #include "BKE_context.h" #include "BKE_depsgraph.h" #include "BKE_main.h" @@ -717,14 +719,12 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN node_socket_circle_draw(ntree, sock, NODE_SOCKSIZE); if (stype->buttonfunc) - stype->buttonfunc(C, node->block, ntree, node, sock, sock->name, sock->locx+NODE_DYS, sock->locy-NODE_DYS, node->width-NODE_DY); + stype->buttonfunc(C, node->block, ntree, node, sock, IFACE_(sock->name), sock->locx+NODE_DYS, sock->locy-NODE_DYS, node->width-NODE_DY); } /* socket outputs */ for(sock= node->outputs.first; sock; sock= sock->next) { PointerRNA sockptr; - float slen; - int ofs; RNA_pointer_create((ID*)ntree, &RNA_NodeSocket, sock, &sockptr); @@ -733,15 +733,19 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN node_socket_circle_draw(ntree, sock, NODE_SOCKSIZE); - ofs= 0; - UI_ThemeColor(TH_TEXT); - slen= snode->aspect*UI_GetStringWidth(sock->name); - while(slen > node->width) { - ofs++; - slen= snode->aspect*UI_GetStringWidth(sock->name+ofs); + { + const char *name = IFACE_(sock->name); + float slen; + int ofs = 0; + UI_ThemeColor(TH_TEXT); + slen= snode->aspect*UI_GetStringWidth(name); + while(slen > node->width) { + ofs++; + slen= snode->aspect*UI_GetStringWidth(name+ofs); + } + uiDefBut(node->block, LABEL, 0, name+ofs, (short)(sock->locx-15.0f-slen), (short)(sock->locy-9.0f), + (short)(node->width-NODE_DY), NODE_DY, NULL, 0, 0, 0, 0, ""); } - uiDefBut(node->block, LABEL, 0, sock->name+ofs, (short)(sock->locx-15.0f-slen), (short)(sock->locy-9.0f), - (short)(node->width-NODE_DY), NODE_DY, NULL, 0, 0, 0, 0, ""); } /* preview */ diff --git a/source/blender/editors/space_node/node_header.c b/source/blender/editors/space_node/node_header.c index df83afc143e..f450356b288 100644 --- a/source/blender/editors/space_node/node_header.c +++ b/source/blender/editors/space_node/node_header.c @@ -214,11 +214,11 @@ static void node_add_menu(bContext *C, uiLayout *layout, void *arg_nodeclass) /* XXX hack: negative numbers used for empty group types */ if (node_tree_has_type(ntree->type, NODE_GROUP)) - uiItemV(layout, "New Group", 0, -NODE_GROUP); + uiItemV(layout, IFACE_("New Group"), 0, -NODE_GROUP); if (node_tree_has_type(ntree->type, NODE_FORLOOP)) - uiItemV(layout, "New For Loop", 0, -NODE_FORLOOP); + uiItemV(layout, IFACE_("New For Loop"), 0, -NODE_FORLOOP); if (node_tree_has_type(ntree->type, NODE_WHILELOOP)) - uiItemV(layout, "New While Loop", 0, -NODE_WHILELOOP); + uiItemV(layout, IFACE_("New While Loop"), 0, -NODE_WHILELOOP); uiItemS(layout); for(ngroup=bmain->nodetree.first, event=0; ngroup; ngroup= ngroup->id.next, ++event) { @@ -239,7 +239,7 @@ static void node_add_menu(bContext *C, uiLayout *layout, void *arg_nodeclass) for (ntype=ntreeGetType(ntree->type)->node_types.first; ntype; ntype=ntype->next) { if (ntype->nclass==nodeclass && ntype->name) if (!compatibility || (ntype->compatibility & compatibility)) - uiItemV(layout, ntype->name, 0, ntype->type); + uiItemV(layout, IFACE_(ntype->name), 0, ntype->type); } } } @@ -247,7 +247,7 @@ static void node_add_menu(bContext *C, uiLayout *layout, void *arg_nodeclass) static void node_menu_add_foreach_cb(void *calldata, int nclass, const char *name) { uiLayout *layout= calldata; - uiItemMenuF(layout, name, 0, node_add_menu, SET_INT_IN_POINTER(nclass)); + uiItemMenuF(layout, IFACE_(name), 0, node_add_menu, SET_INT_IN_POINTER(nclass)); } static void node_menu_add(const bContext *C, Menu *menu) diff --git a/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c b/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c index bc3f648a374..a0b7e62e644 100644 --- a/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c +++ b/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c @@ -30,6 +30,8 @@ * \ingroup cmpnodes */ +#include "BLF_translation.h" + #include "node_composite_util.h" @@ -105,9 +107,9 @@ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) static const char *label(bNode *node) { if(node->custom1==0) - return "Undistortion"; + return IFACE_("Undistortion"); else - return "Distortion"; + return IFACE_("Distortion"); } static void storage_free(bNode *node) diff --git a/source/blender/nodes/intern/node_common.c b/source/blender/nodes/intern/node_common.c index e5571b19614..c039365ec69 100644 --- a/source/blender/nodes/intern/node_common.c +++ b/source/blender/nodes/intern/node_common.c @@ -40,6 +40,8 @@ #include "BLI_string.h" #include "BLI_utildefines.h" +#include "BLF_translation.h" + #include "BKE_action.h" #include "BKE_animsys.h" #include "BKE_global.h" @@ -487,7 +489,7 @@ void node_group_remove_socket(bNodeTree *ngroup, bNodeSocket *gsock, int in_out) /* groups display their internal tree name as label */ const char *node_group_label(bNode *node) { - return (node->id)? node->id->name+2: "Missing Datablock"; + return (node->id)? node->id->name+2: IFACE_("Missing Datablock"); } int node_group_valid(bNodeTree *ntree, bNodeTemplate *ntemp) diff --git a/source/blender/nodes/intern/node_util.c b/source/blender/nodes/intern/node_util.c index 19b3ba63f9a..7626a3aaa7b 100644 --- a/source/blender/nodes/intern/node_util.c +++ b/source/blender/nodes/intern/node_util.c @@ -36,6 +36,8 @@ #include "BLI_listbase.h" #include "BLI_utildefines.h" +#include "BLF_translation.h" + #include "BKE_colortools.h" #include "BKE_node.h" @@ -74,28 +76,28 @@ const char *node_blend_label(bNode *node) { const char *name; RNA_enum_name(ramp_blend_items, node->custom1, &name); - return name; + return IFACE_(name); } const char *node_math_label(bNode *node) { const char *name; RNA_enum_name(node_math_items, node->custom1, &name); - return name; + return IFACE_(name); } const char *node_vect_math_label(bNode *node) { const char *name; RNA_enum_name(node_vec_math_items, node->custom1, &name); - return name; + return IFACE_(name); } const char *node_filter_label(bNode *node) { const char *name; RNA_enum_name(node_filter_items, node->custom1, &name); - return name; + return IFACE_(name); } ListBase node_internal_connect_default(bNodeTree *ntree, bNode *node) -- cgit v1.2.3