From 3e208d75ccb761d936b3126082407632dc09d7ec Mon Sep 17 00:00:00 2001 From: Dan Nicholson Date: Wed, 30 Oct 2024 14:54:43 -0600 Subject: [PATCH] ui: Translate displayed block and category strings We want the strings in the BlockDefinition to stay untranslated and only translate them when being displayed in the UI. --- addons/block_code/ui/blocks/block/block.gd | 7 ++++--- .../ui/picker/categories/block_category_button.gd | 2 +- .../ui/picker/categories/block_category_display.gd | 3 +-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/addons/block_code/ui/blocks/block/block.gd b/addons/block_code/ui/blocks/block/block.gd index 38123c5c..198df289 100644 --- a/addons/block_code/ui/blocks/block/block.gd +++ b/addons/block_code/ui/blocks/block/block.gd @@ -118,7 +118,7 @@ func _get_format_string() -> String: if not definition: return "" - return definition.display_template + return tr(definition.display_template) func _get_parameter_defaults() -> Dictionary: @@ -217,10 +217,11 @@ func _get_tooltip(at_position: Vector2) -> String: if not definition: return "" + var description_tx := tr(definition.description) if definition.variant_type == Variant.Type.TYPE_NIL: - return definition.description + return description_tx - return "{description}\n\nType: [b]{type}[/b]".format({"description": definition.description, "type": type_string(definition.variant_type)}) + return "{description}\n\n{type_field}: [b]{type}[/b]".format({"description": description_tx, "type_field": tr("Type:"), "type": type_string(definition.variant_type)}) func _make_custom_tooltip(for_text) -> Control: diff --git a/addons/block_code/ui/picker/categories/block_category_button.gd b/addons/block_code/ui/picker/categories/block_category_button.gd index 8c82209f..4edb3123 100644 --- a/addons/block_code/ui/picker/categories/block_category_button.gd +++ b/addons/block_code/ui/picker/categories/block_category_button.gd @@ -21,7 +21,7 @@ func _ready(): new_stylebox.bg_color = category.color _panel.add_theme_stylebox_override("panel", new_stylebox) - _label.text = category.name + _label.text = tr(category.name) func _on_button_pressed(): diff --git a/addons/block_code/ui/picker/categories/block_category_display.gd b/addons/block_code/ui/picker/categories/block_category_display.gd index beac0648..c534ea9d 100644 --- a/addons/block_code/ui/picker/categories/block_category_display.gd +++ b/addons/block_code/ui/picker/categories/block_category_display.gd @@ -21,7 +21,6 @@ var _blocks: Dictionary # String, Block func _ready(): - _label.text = title # category.name if category != null else "" _update_label() _update_blocks() @@ -40,7 +39,7 @@ func _update_label(): if not _label: return - _label.text = title + _label.text = tr(title) func _update_blocks():