forked from bartvdbraak/blender
Big step forward nodes UI translation:
*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. :/
This commit is contained in:
parent
1f6ae5e4fb
commit
7bc693d107
@ -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)
|
||||
|
@ -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 */
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user