I18n: improve geometry nodes field tooltips #107257

Merged
Bastien Montagne merged 1 commits from pioverfour/blender:dp_fix_geo_nodes_field_tooltips into main 2023-04-28 21:37:40 +02:00
7 changed files with 61 additions and 53 deletions

View File

@ -19,6 +19,8 @@
#include "BLI_math_vector_types.hh"
#include "BLI_span.hh"
#include "BLT_translation.h"
#include "FN_field.hh"
#include "BLT_translation.h"
@ -49,8 +51,8 @@ std::ostream &operator<<(std::ostream &stream, const AttributeIDRef &attribute_i
return stream;
}
const char *no_procedural_access_message =
"This attribute can not be accessed in a procedural context";
const char *no_procedural_access_message = N_(
"This attribute can not be accessed in a procedural context");
bool allow_procedural_attribute_access(StringRef attribute_name)
{

View File

@ -847,7 +847,7 @@ static void create_inspection_string_for_generic_value(const bNodeSocket &socket
return;
}
if (value_type.is<std::string>()) {
ss << *static_cast<const std::string *>(buffer) << TIP_(" (String)");
ss << *static_cast<const std::string *>(buffer) << " " << TIP_("(String)");
return;
}
@ -864,22 +864,22 @@ static void create_inspection_string_for_generic_value(const bNodeSocket &socket
BLI_SCOPED_DEFER([&]() { socket_type.destruct(socket_value); });
if (socket_type.is<int>()) {
ss << *static_cast<int *>(socket_value) << TIP_(" (Integer)");
ss << *static_cast<int *>(socket_value) << " " << TIP_("(Integer)");
}
else if (socket_type.is<float>()) {
ss << *static_cast<float *>(socket_value) << TIP_(" (Float)");
ss << *static_cast<float *>(socket_value) << " " << TIP_("(Float)");
}
else if (socket_type.is<blender::float3>()) {
ss << *static_cast<blender::float3 *>(socket_value) << TIP_(" (Vector)");
ss << *static_cast<blender::float3 *>(socket_value) << " " << TIP_("(Vector)");
}
else if (socket_type.is<blender::ColorGeometry4f>()) {
const blender::ColorGeometry4f &color = *static_cast<blender::ColorGeometry4f *>(socket_value);
ss << "(" << color.r << ", " << color.g << ", " << color.b << ", " << color.a << ")"
<< TIP_(" (Color)");
ss << "(" << color.r << ", " << color.g << ", " << color.b << ", " << color.a << ") "
<< TIP_("(Color)");
}
else if (socket_type.is<bool>()) {
ss << ((*static_cast<bool *>(socket_value)) ? TIP_("True") : TIP_("False"))
<< TIP_(" (Boolean)");
ss << ((*static_cast<bool *>(socket_value)) ? TIP_("True") : TIP_("False")) << " "
<< TIP_("(Boolean)");
}
}
@ -893,32 +893,32 @@ static void create_inspection_string_for_field_info(const bNodeSocket &socket,
if (input_tooltips.is_empty()) {
/* Should have been logged as constant value. */
BLI_assert_unreachable();
ss << "Value has not been logged";
ss << TIP_("Value has not been logged");
}
else {
if (socket_type.is<int>()) {
ss << TIP_("Integer field");
ss << TIP_("Integer field based on:");
}
else if (socket_type.is<float>()) {
ss << TIP_("Float field");
ss << TIP_("Float field based on:");
}
else if (socket_type.is<blender::float3>()) {
ss << TIP_("Vector field");
ss << TIP_("Vector field based on:");
}
else if (socket_type.is<bool>()) {
ss << TIP_("Boolean field");
ss << TIP_("Boolean field based on:");
}
else if (socket_type.is<std::string>()) {
ss << TIP_("String field");
ss << TIP_("String field based on:");
}
else if (socket_type.is<blender::ColorGeometry4f>()) {
ss << TIP_("Color field");
ss << TIP_("Color field based on:");
}
ss << TIP_(" based on:\n");
ss << "\n";
for (const int i : input_tooltips.index_range()) {
const blender::StringRef tooltip = input_tooltips[i];
ss << "\u2022 " << tooltip;
ss << "\u2022 " << TIP_(tooltip.data());
if (i < input_tooltips.size() - 1) {
ss << ".\n";
}
@ -941,7 +941,7 @@ static void create_inspection_string_for_geometry_info(const geo_log::GeometryIn
return std::string(str);
};
ss << TIP_("Geometry:\n");
ss << TIP_("Geometry:") << "\n";
for (GeometryComponentType type : component_types) {
switch (type) {
case GEO_COMPONENT_TYPE_MESH: {
@ -1865,7 +1865,7 @@ static char *named_attribute_tooltip(bContext * /*C*/, void *argN, const char *
NamedAttributeTooltipArg &arg = *static_cast<NamedAttributeTooltipArg *>(argN);
std::stringstream ss;
ss << TIP_("Accessed named attributes:\n");
ss << TIP_("Accessed named attributes:") << "\n";
struct NameWithUsage {
StringRefNull name;
@ -1917,7 +1917,7 @@ static NodeExtraInfoRow row_from_used_named_attribute(
NodeExtraInfoRow row;
row.text = std::to_string(attributes_num) +
TIP_(attributes_num == 1 ? " Named Attribute" : " Named Attributes");
(attributes_num == 1 ? TIP_(" Named Attribute") : TIP_(" Named Attributes"));
row.icon = ICON_SPREADSHEET;
row.tooltip_fn = named_attribute_tooltip;
row.tooltip_fn_arg = new NamedAttributeTooltipArg{usage_by_attribute_name};

View File

@ -568,7 +568,7 @@ static void spreadsheet_footer_region_draw(const bContext *C, ARegion *region)
SpaceSpreadsheet *sspreadsheet = CTX_wm_space_spreadsheet(C);
SpaceSpreadsheet_Runtime *runtime = sspreadsheet->runtime;
std::stringstream ss;
ss << "Rows: ";
ss << IFACE_("Rows:") << " ";
if (runtime->visible_rows != runtime->tot_rows) {
char visible_rows_str[BLI_STR_FORMAT_INT32_GROUPED_SIZE];
BLI_str_format_int_grouped(visible_rows_str, runtime->visible_rows);
@ -576,7 +576,7 @@ static void spreadsheet_footer_region_draw(const bContext *C, ARegion *region)
}
char tot_rows_str[BLI_STR_FORMAT_INT32_GROUPED_SIZE];
BLI_str_format_int_grouped(tot_rows_str, runtime->tot_rows);
ss << tot_rows_str << " | Columns: " << runtime->tot_columns;
ss << tot_rows_str << " | " << IFACE_("Columns:") << " " << runtime->tot_columns;
std::string stats_str = ss.str();
UI_ThemeClearColor(TH_BACK);

View File

@ -15,25 +15,26 @@ NODE_STORAGE_FUNCS(NodeAccumulateField)
static void node_declare(NodeDeclarationBuilder &b)
{
std::string value_in_description = "The values to be accumulated";
std::string leading_out_description =
"The running total of values in the corresponding group, starting at the first value";
std::string trailing_out_description =
"The running total of values in the corresponding group, starting at zero";
std::string total_out_description = "The total of all of the values in the corresponding group";
std::string value_in_description = N_("The values to be accumulated");
std::string leading_out_description = N_(
"The running total of values in the corresponding group, starting at the first value");
std::string trailing_out_description = N_(
"The running total of values in the corresponding group, starting at zero");
std::string total_out_description = N_(
"The total of all of the values in the corresponding group");
b.add_input<decl::Vector>(N_("Value"), "Value Vector")
.default_value({1.0f, 1.0f, 1.0f})
.supports_field()
.description(N_(value_in_description));
.description(value_in_description);
b.add_input<decl::Float>(N_("Value"), "Value Float")
.default_value(1.0f)
.supports_field()
.description(N_(value_in_description));
.description(value_in_description);
b.add_input<decl::Int>(N_("Value"), "Value Int")
.default_value(1)
.supports_field()
.description(N_(value_in_description));
.description(value_in_description);
b.add_input<decl::Int>(N_("Group ID"), "Group Index")
.supports_field()
.description(
@ -41,33 +42,33 @@ static void node_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Vector>(N_("Leading"), "Leading Vector")
.field_source_reference_all()
.description(N_(leading_out_description));
.description(leading_out_description);
b.add_output<decl::Float>(N_("Leading"), "Leading Float")
.field_source_reference_all()
.description(N_(leading_out_description));
.description(leading_out_description);
b.add_output<decl::Int>(N_("Leading"), "Leading Int")
.field_source_reference_all()
.description(N_(leading_out_description));
.description(leading_out_description);
b.add_output<decl::Vector>(N_("Trailing"), "Trailing Vector")
.field_source_reference_all()
.description(N_(trailing_out_description));
.description(trailing_out_description);
b.add_output<decl::Float>(N_("Trailing"), "Trailing Float")
.field_source_reference_all()
.description(N_(trailing_out_description));
.description(trailing_out_description);
b.add_output<decl::Int>(N_("Trailing"), "Trailing Int")
.field_source_reference_all()
.description(N_(trailing_out_description));
.description(trailing_out_description);
b.add_output<decl::Vector>(N_("Total"), "Total Vector")
.field_source_reference_all()
.description(N_(total_out_description));
.description(total_out_description);
b.add_output<decl::Float>(N_("Total"), "Total Float")
.field_source_reference_all()
.description(N_(total_out_description));
.description(total_out_description);
b.add_output<decl::Int>(N_("Total"), "Total Int")
.field_source_reference_all()
.description(N_(total_out_description));
.description(total_out_description);
}
static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)

View File

@ -3,6 +3,8 @@
#include "UI_interface.h"
#include "UI_resources.h"
#include "BLT_translation.h"
#include "node_geometry_util.hh"
namespace blender::nodes::node_geo_attribute_domain_size_cc {
@ -10,22 +12,22 @@ namespace blender::nodes::node_geo_attribute_domain_size_cc {
static void node_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Geometry>("Geometry");
b.add_output<decl::Int>("Point Count").make_available([](bNode &node) {
b.add_output<decl::Int>(N_("Point Count")).make_available([](bNode &node) {
node.custom1 = GEO_COMPONENT_TYPE_MESH;
});
b.add_output<decl::Int>("Edge Count").make_available([](bNode &node) {
b.add_output<decl::Int>(N_("Edge Count")).make_available([](bNode &node) {
node.custom1 = GEO_COMPONENT_TYPE_MESH;
});
b.add_output<decl::Int>("Face Count").make_available([](bNode &node) {
b.add_output<decl::Int>(N_("Face Count")).make_available([](bNode &node) {
node.custom1 = GEO_COMPONENT_TYPE_MESH;
});
b.add_output<decl::Int>("Face Corner Count").make_available([](bNode &node) {
b.add_output<decl::Int>(N_("Face Corner Count")).make_available([](bNode &node) {
node.custom1 = GEO_COMPONENT_TYPE_MESH;
});
b.add_output<decl::Int>("Spline Count").make_available([](bNode &node) {
b.add_output<decl::Int>(N_("Spline Count")).make_available([](bNode &node) {
node.custom1 = GEO_COMPONENT_TYPE_CURVE;
});
b.add_output<decl::Int>("Instance Count").make_available([](bNode &node) {
b.add_output<decl::Int>(N_("Instance Count")).make_available([](bNode &node) {
node.custom1 = GEO_COMPONENT_TYPE_INSTANCES;
});
}

View File

@ -61,7 +61,7 @@ static void node_geo_exec(GeoNodeExecParams params)
const bool is_recursive = BKE_collection_has_object_recursive_instanced(
collection, const_cast<Object *>(self_object));
if (is_recursive) {
params.error_message_add(NodeWarningType::Error, "Collection contains current object");
params.error_message_add(NodeWarningType::Error, TIP_("Collection contains current object"));
params.set_default_remaining_outputs();
return;
}

View File

@ -59,12 +59,15 @@ static void node_geo_exec(GeoNodeExecParams params)
}
if (!attribute_exists) {
params.error_message_add(NodeWarningType::Info,
TIP_("Attribute does not exist: \"") + name + "\"");
char *message = BLI_sprintfN(TIP_("Attribute does not exist: \"%s\""), name.c_str());
params.error_message_add(NodeWarningType::Warning, message);
MEM_freeN(message);
}
if (cannot_delete) {
params.error_message_add(NodeWarningType::Warning,
TIP_("Cannot delete built-in attribute with name \"") + name + "\"");
char *message = BLI_sprintfN(TIP_("Cannot delete built-in attribute with name \"%s\""),
name.c_str());
params.error_message_add(NodeWarningType::Warning, message);
MEM_freeN(message);
}
params.set_output("Geometry", std::move(geometry_set));