From 3e568be6d8dd027b75030ac840fb9969c38a64e4 Mon Sep 17 00:00:00 2001 From: kramo <93832451+kra-mo@users.noreply.github.com> Date: Fri, 31 Mar 2023 15:44:52 +0200 Subject: [PATCH] Fix fstrings in translations --- src/main.py | 2 +- src/preferences.py | 5 +++-- src/utils/create_details_window.py | 20 ++++++++++---------- src/utils/importer.py | 2 +- src/window.py | 4 ++-- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/main.py b/src/main.py index b23675a..50953ca 100644 --- a/src/main.py +++ b/src/main.py @@ -198,7 +198,7 @@ class CartridgesApplication(Adw.Application): title = self.win.games[game_id].name # The variable is the title of the game - toast = Adw.Toast.new(_(f"{title} removed")) + toast = Adw.Toast.new(_("{} removed").format(title)) toast.set_button_label(_("Undo")) toast.connect("button-clicked", self.win.on_undo_remove_action, game_id) toast.set_priority(Adw.ToastPriority.HIGH) diff --git a/src/preferences.py b/src/preferences.py index cb3c91c..d7201ca 100644 --- a/src/preferences.py +++ b/src/preferences.py @@ -54,9 +54,10 @@ class ImportPreferences: window.parent_widget, _("Installation Not Found"), # The variable is the name of the game launcher - _(f"Select the {name} configuration directory.") if config + _("Select the {} configuration directory.").format(name) + if config # The variable is the name of the game launcher - else _(f"Select the {name} data directory."), + else _("Select the {} data directory.").format(name), "choose_folder", _("Set Location"), ).connect("response", response) diff --git a/src/utils/create_details_window.py b/src/utils/create_details_window.py index d4a7b02..20a2159 100644 --- a/src/utils/create_details_window.py +++ b/src/utils/create_details_window.py @@ -115,21 +115,21 @@ def create_details_window(parent_widget, game_id=None): if os.name == "nt": exe_name += ".exe" - # Translate this string as you would translate "path to {exe_name}" - exe_path = _(f"C:\\path\\to\\{exe_name}") - # Translate this string as you would translate "path to {file_name}" - file_path = _(f"C:\\path\\to\\{file_name}") + # Translate this string as you would translate "path to {}" + exe_path = _("C:\\path\\to\\{}").format(exe_name) + # Translate this string as you would translate "path to {}" + file_path = _("C:\\path\\to\\{}").format(file_name) command = "start" else: - # Translate this string as you would translate "path to {exe_name}" - exe_path = _(f"/path/to/{exe_name}") - # Translate this string as you would translate "path to {file_name}" - file_path = _(f"/path/to/{file_name}") + # Translate this string as you would translate "path to {}" + exe_path = _("/path/to/{}").format(exe_name) + # Translate this string as you would translate "path to {}" + file_path = _("/path/to/{}").format(file_name) command = "xdg-open" exec_info_text = _( - f'To launch the executable "{exe_name}", use the command:\n\n"{exe_path}"\n\nTo open the file "{file_name}" with the default application, use:\n\n{command} "{file_path}"\n\nIf the path contains spaces, make sure to wrap it in double quotes!' - ) + 'To launch the executable "{}", use the command:\n\n"{}"\n\nTo open the file "{}" with the default application, use:\n\n{} "{}"\n\nIf the path contains spaces, make sure to wrap it in double quotes!' + ).format(exe_name, exe_path, file_name, command, file_path) exec_info_label = Gtk.Label( label=exec_info_text, diff --git a/src/utils/importer.py b/src/utils/importer.py index e3850b5..295dd9c 100644 --- a/src/utils/importer.py +++ b/src/utils/importer.py @@ -93,5 +93,5 @@ class Importer: self.parent_widget, _("Games Imported"), # The variable is the number of games - _(f"Successfully imported {games_no} games."), + _("Successfully imported {} games.").format(games_no), ) diff --git a/src/window.py b/src/window.py index fb7021d..730421b 100644 --- a/src/window.py +++ b/src/window.py @@ -267,7 +267,7 @@ class CartridgesWindow(Adw.ApplicationWindow): date = self.get_time(current_game.added) self.overview_added.set_label( # The variable is the date when the game was added - _(f"Added: {date}") + _("Added: {}").format(date) ) last_played_date = ( self.get_time(current_game.last_played) @@ -276,7 +276,7 @@ class CartridgesWindow(Adw.ApplicationWindow): ) self.overview_last_played.set_label( # The variable is the date when the game was last played - _(f"Last played: {last_played_date}") + _("Last played: {}").format(last_played_date) ) def a_z_sort(self, child1, child2):