From 91969956978339fb90efce96a4aa20ec8e1fe609 Mon Sep 17 00:00:00 2001 From: nicejammer <158223817+nicejammer@users.noreply.github.com> Date: Fri, 26 Jul 2024 10:10:56 -0300 Subject: [PATCH] Fix certain strings not updating when language changes (#1043) A few buttons and labels in Pixelorama weren't getting updated when changing languages, they'd just remain at the language the program started up with or only update when changing projects. This fixes that and ensures they get updated as soon as the user changes languages. --- src/Palette/EditPaletteDialog.gd | 6 +++--- src/Preferences/ExtensionsPreferences.gd | 2 +- src/UI/Timeline/CelButton.gd | 7 +++++++ src/UI/TopMenuContainer/TopMenuContainer.gd | 17 +++++++++++++---- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/Palette/EditPaletteDialog.gd b/src/Palette/EditPaletteDialog.gd index d0a209ed7..fa765bcb2 100644 --- a/src/Palette/EditPaletteDialog.gd +++ b/src/Palette/EditPaletteDialog.gd @@ -32,9 +32,9 @@ var old_name := "" func _ready() -> void: export_file_dialog.use_native_dialog = Global.use_native_file_dialogs # Add delete and export buttons to edit palette dialog - add_button(tr("Delete"), false, DELETE_ACTION) - add_button(tr("Export"), false, EXPORT_ACTION) - delete_confirmation.add_button(tr("Move to Trash"), false, BIN_ACTION) + add_button("Delete", false, DELETE_ACTION) + add_button("Export", false, EXPORT_ACTION) + delete_confirmation.add_button("Move to Trash", false, BIN_ACTION) func open(current_palette: Palette) -> void: diff --git a/src/Preferences/ExtensionsPreferences.gd b/src/Preferences/ExtensionsPreferences.gd index 5d19974f0..3023d78e7 100644 --- a/src/Preferences/ExtensionsPreferences.gd +++ b/src/Preferences/ExtensionsPreferences.gd @@ -17,7 +17,7 @@ func _ready() -> void: _extension_loaded(extension, extension_name) extensions.extension_loaded.connect(_extension_loaded) extensions.extension_uninstalled.connect(_extension_uninstalled) - delete_confirmation.add_button(tr("Move to Trash"), false, Extensions.BIN_ACTION) + delete_confirmation.add_button("Move to Trash", false, Extensions.BIN_ACTION) if OS.get_name() == "Web": $HBoxContainer/AddExtensionButton.disabled = true $HBoxContainer/OpenFolderButton.visible = false diff --git a/src/UI/Timeline/CelButton.gd b/src/UI/Timeline/CelButton.gd index e042194fb..da16539b6 100644 --- a/src/UI/Timeline/CelButton.gd +++ b/src/UI/Timeline/CelButton.gd @@ -29,6 +29,13 @@ func _ready() -> void: transparent_checker.visible = false +func _notification(what: int) -> void: + if what == NOTIFICATION_TRANSLATION_CHANGED: + tooltip_text = ( + tr("Frame: %s, Layer: %s") % [frame + 1, Global.current_project.layers[layer].name] + ) + + func cel_switched(force_stylebox_change := false) -> void: z_index = 1 if button_pressed else 0 var current_theme := Global.control.theme diff --git a/src/UI/TopMenuContainer/TopMenuContainer.gd b/src/UI/TopMenuContainer/TopMenuContainer.gd index bbfeae307..8fa31bc1a 100644 --- a/src/UI/TopMenuContainer/TopMenuContainer.gd +++ b/src/UI/TopMenuContainer/TopMenuContainer.gd @@ -94,9 +94,22 @@ func _ready() -> void: _setup_help_menu() +func _notification(what: int) -> void: + if what == NOTIFICATION_TRANSLATION_CHANGED and Global.current_project != null: + _update_file_menu_buttons(Global.current_project) + + func _project_switched() -> void: var project := Global.current_project edit_menu.set_item_disabled(Global.EditMenu.NEW_BRUSH, not project.has_selection) + _update_file_menu_buttons(project) + for j in Tiles.MODE.values(): + tile_mode_submenu.set_item_checked(j, j == project.tiles.mode) + + _update_current_frame_mark() + + +func _update_file_menu_buttons(project: Project) -> void: if project.export_directory_path.is_empty(): file_menu.set_item_text(Global.FileMenu.SAVE, tr("Save")) else: @@ -109,10 +122,6 @@ func _project_switched() -> void: file_menu.set_item_text(Global.FileMenu.EXPORT, tr("Export") + f_name) else: file_menu.set_item_text(Global.FileMenu.EXPORT, tr("Export")) - for j in Tiles.MODE.values(): - tile_mode_submenu.set_item_checked(j, j == project.tiles.mode) - - _update_current_frame_mark() func _update_current_frame_mark() -> void: