Skip to content

Commit

Permalink
ui: Translate displayed block and category strings
Browse files Browse the repository at this point in the history
We want the strings in the BlockDefinition to stay untranslated and only
translate them when being displayed in the UI.
  • Loading branch information
dbnicholson committed Nov 1, 2024
1 parent 531cbbf commit 3e208d7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
7 changes: 4 additions & 3 deletions addons/block_code/ui/blocks/block/block.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ var _blocks: Dictionary # String, Block


func _ready():
_label.text = title # category.name if category != null else ""
_update_label()
_update_blocks()

Expand All @@ -40,7 +39,7 @@ func _update_label():
if not _label:
return

_label.text = title
_label.text = tr(title)


func _update_blocks():
Expand Down

0 comments on commit 3e208d7

Please sign in to comment.