WIP: I18n: add per-label translation contexts for nodes #105690
|
@ -251,6 +251,14 @@ PYGETTEXT_KEYWORDS = (() +
|
|||
tuple(("{}\\((?:[^\"',]+,){{2}}\\s*" + _msg_re + r"\s*(?:\)|,)").format(it)
|
||||
for it in ("BKE_modifier_set_error",)) +
|
||||
|
||||
# Extract messages specific to node sockets declaring labels.
|
||||
tuple(("{}\\((?:[^\"',]+,)\\s*" + _msg_re + r"\s*\)").format(it)
|
||||
for it in ("node_sock_label",)) +
|
||||
|
||||
# Same as above, but variant with a context.
|
||||
tuple(("{}\\((?:[^\"',]+,)\\s*" + _msg_re + r"\s*,\s*" + _ctxt_re + r"\s*\)").format(it)
|
||||
for it in ("node_sock_label",)) +
|
||||
|
||||
# This one is a tad more risky, but in practice would not expect a name/uid string parameter
|
||||
# (the second one in those functions) to ever have a comma in it, so think this is fine.
|
||||
tuple(("{}\\((?:[^,]+,){{2}}\\s*" + _msg_re + r"\s*(?:\)|,)").format(it)
|
||||
|
|
|
@ -201,6 +201,7 @@ class bNodeSocketRuntime : NonCopyable, NonMovable {
|
|||
int index_in_node = -1;
|
||||
int index_in_all_sockets = -1;
|
||||
int index_in_inout_sockets = -1;
|
||||
std::string label_translation_context;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -191,6 +191,11 @@ namespace blender::ed::space_node {
|
|||
|
||||
static const char *node_socket_get_translation_context(const bNodeSocket &socket)
|
||||
{
|
||||
/* Get the context from the label if it is defined. */
|
||||
if (socket.runtime->label_translation_context[0] != '\0') {
|
||||
return socket.runtime->label_translation_context.c_str();
|
||||
}
|
||||
|
||||
/* The node is not explicitly defined. */
|
||||
if (socket.runtime->declaration == nullptr) {
|
||||
return nullptr;
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include "BLI_assert.h"
|
||||
|
||||
#include "BLT_translation.h"
|
||||
|
||||
#include "GPU_material.h"
|
||||
|
||||
#include "COM_shader_node.hh"
|
||||
|
@ -35,7 +37,7 @@ static void node_cmp_combsep_color_label(const ListBase *sockets, CMPNodeCombSep
|
|||
case CMP_NODE_COMBSEP_COLOR_HSV:
|
||||
node_sock_label(sock1, "Hue");
|
||||
node_sock_label(sock2, "Saturation");
|
||||
node_sock_label(sock3, "Value");
|
||||
node_sock_label(sock3, "Value", BLT_I18NCONTEXT_COLOR);
|
||||
break;
|
||||
case CMP_NODE_COMBSEP_COLOR_HSL:
|
||||
node_sock_label(sock1, "Hue");
|
||||
|
|
|
@ -73,9 +73,12 @@ void *node_initexec_curves(bNodeExecContext * /*context*/, bNode *node, bNodeIns
|
|||
/** \name Updates
|
||||
* \{ */
|
||||
|
||||
void node_sock_label(bNodeSocket *sock, const char *name)
|
||||
void node_sock_label(bNodeSocket *sock, const char *name, const char *translation_context)
|
||||
{
|
||||
STRNCPY(sock->label, name);
|
||||
if (translation_context) {
|
||||
sock->runtime->label_translation_context = translation_context;
|
||||
}
|
||||
}
|
||||
|
||||
void node_sock_label_clear(bNodeSocket *sock)
|
||||
|
@ -83,6 +86,9 @@ void node_sock_label_clear(bNodeSocket *sock)
|
|||
if (sock->label[0] != '\0') {
|
||||
sock->label[0] = '\0';
|
||||
}
|
||||
if (sock->runtime->label_translation_context[0] != '\0') {
|
||||
sock->runtime->label_translation_context[0] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
void node_math_update(bNodeTree *ntree, bNode *node)
|
||||
|
@ -262,7 +268,7 @@ void node_combsep_color_label(const ListBase *sockets, NodeCombSepColorMode mode
|
|||
case NODE_COMBSEP_COLOR_HSV:
|
||||
node_sock_label(sock1, "Hue");
|
||||
node_sock_label(sock2, "Saturation");
|
||||
node_sock_label(sock3, "Value");
|
||||
node_sock_label(sock3, "Value", BLT_I18NCONTEXT_COLOR);
|
||||
break;
|
||||
default: {
|
||||
BLI_assert_unreachable();
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "BLT_translation.h"
|
||||
|
||||
struct bNode;
|
||||
struct bNodeTree;
|
||||
|
||||
|
@ -30,7 +32,9 @@ void node_copy_standard_storage(bNodeTree *dest_ntree, bNode *dest_node, const b
|
|||
void *node_initexec_curves(bNodeExecContext *context, bNode *node, bNodeInstanceKey key);
|
||||
|
||||
pioverfour marked this conversation as resolved
Outdated
|
||||
/**** Updates ****/
|
||||
void node_sock_label(bNodeSocket *sock, const char *name);
|
||||
void node_sock_label(bNodeSocket *sock,
|
||||
const char *name,
|
||||
const char *translation_context = BLT_I18NCONTEXT_DEFAULT);
|
||||
void node_sock_label_clear(bNodeSocket *sock);
|
||||
void node_math_update(bNodeTree *ntree, bNode *node);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Would rather have default value be
BLT_I18NCONTEXT_DEFAULT
(akanullptr
). Also meansnode_sock_label
code changes need an update.