Big step forward nodes UI translation:
authorBastien Montagne <montagne29@wanadoo.fr>
Sat, 17 Mar 2012 14:42:44 +0000 (14:42 +0000)
committerBastien Montagne <montagne29@wanadoo.fr>
Sat, 17 Mar 2012 14:42:44 +0000 (14:42 +0000)
*Add menu is now translated.
*Nodes' title is now translated.
*Nodes' sockets' labels are now translated.

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
source/blender/editors/space_node/node_draw.c
source/blender/editors/space_node/node_header.c
source/blender/nodes/composite/nodes/node_composite_moviedistortion.c
source/blender/nodes/intern/node_common.c
source/blender/nodes/intern/node_util.c

index 8b9955dd37866aa1da21886993b09dfb65a04c0d..f3320a0b31dd21f03b8a778c4861cec13eee4860 100644 (file)
@@ -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)
index a2775832c1d368eeb8f013aeae6c2a760f9585bf..46850d4ff601702a7e85d3403e0a5c0391065759 100644 (file)
@@ -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 */
index df83afc143e0d1ea5c5699e0aa6110400c066089..f450356b288eed12941a7737ba4c8dc3ea9754d9 100644 (file)
@@ -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)
index bc3f648a3747706d8008e0597b0a1d6a4cce78ee..a0b7e62e64442d77d00253b214f1865bd1b113ad 100644 (file)
@@ -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)
index e5571b1961474c073c07a784acee8cf2b5f8a808..c039365ec695daab4bcd930d352daeaf732f6085 100644 (file)
@@ -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)
index 19b3ba63f9ad61e0f446c0f4acc6bc05136ba8a3..7626a3aaa7bfdbc5af21d0d3327a081bc5454ab7 100644 (file)
@@ -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)