From 45ae33a9524153376d1df66a69d7a162c28e336c Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 6 Aug 2019 12:18:42 +0200 Subject: Fix T66731: Part 3: Labels translations when tools are in 'compact' mode. Very annoying that this whole UI thingy uses its own cooking... This is more a quick-slap fix than a proper solution, would expect it to work in nearly all cases though... --- .../blender/editors/interface/interface_region_tooltip.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c index 5dd8b74aceb..6aad9e41e7d 100644 --- a/source/blender/editors/interface/interface_region_tooltip.c +++ b/source/blender/editors/interface/interface_region_tooltip.c @@ -396,11 +396,23 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is else { /* Note, this is an exceptional case, we could even remove it * however there have been reports of tooltips failing, so keep it for now. */ - expr_result = BLI_strdup("Internal error!"); + expr_result = BLI_strdup(IFACE_("Internal error!")); is_error = true; } if (expr_result != NULL) { + /* NOTE: This is a very weak hack to get a valid translation most of the time... + * Proper way to do would be to get i18n context from the item, somehow. */ + const char *label_str = CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, expr_result); + if (label_str == expr_result) { + label_str = IFACE_(expr_result); + } + + if (label_str != expr_result) { + MEM_freeN(expr_result); + expr_result = BLI_strdup(label_str); + } + uiTooltipField *field = text_field_add(data, &(uiTooltipFormat){ .style = UI_TIP_STYLE_NORMAL, @@ -437,7 +449,7 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is else { /* Note, this is an exceptional case, we could even remove it * however there have been reports of tooltips failing, so keep it for now. */ - expr_result = BLI_strdup("Internal error!"); + expr_result = BLI_strdup(TIP_("Internal error!")); is_error = true; } -- cgit v1.2.3