Skip to content

Commit

Permalink
fix: fully translate welcome page
Browse files Browse the repository at this point in the history
  • Loading branch information
jardon committed Oct 2, 2024
1 parent 892c3b0 commit 20e5fcd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 42 deletions.
52 changes: 12 additions & 40 deletions vanilla_first_setup/defaults/welcome.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import time
import sys
from gi.repository import Gtk, GLib, Adw
from gettext import translation
from vanilla_first_setup.utils.recipe import RecipeLoader

from vanilla_first_setup.utils.run_async import RunAsync
from vanilla_first_setup.core.languages import all_locale


@Gtk.Template(resource_path="/org/vanillaos/FirstSetup/gtk/default-welcome.ui")
Expand All @@ -29,43 +32,7 @@ class VanillaDefaultWelcome(Adw.Bin):
btn_next = Gtk.Template.Child()
status_page = Gtk.Template.Child()
title_label = Gtk.Template.Child()

welcome = [
"Welcome",
"Benvenuto",
"Bienvenido",
"Bienvenue",
"Willkommen",
"Bem-vindo",
"Добро пожаловать",
"欢迎",
"ようこそ",
"환영합니다",
"أهلا بك",
"ברוך הבא",
"Καλώς ήρθατε",
"Hoşgeldiniz",
"Welkom",
"Witamy",
"Välkommen",
"Tervetuloa",
"Vítejte",
"Üdvözöljük",
"Bun venit",
"Vitajte",
"Tere tulemast",
"Sveiki atvykę",
"Dobrodošli",
"خوش آمدید",
"आपका स्वागत है",
"স্বাগতম",
"வரவேற்கிறோம்",
"స్వాగతం",
"मुबारक हो",
"સુસ્વાગત છે",
"ಸುಸ್ವಾಗತ",
"സ്വാഗതം",
]
welcome_message = Gtk.Template.Child()

def validate_advanced(self):
recipeLoader = RecipeLoader()
Expand Down Expand Up @@ -103,9 +70,14 @@ def step_id(self):
def __start_welcome_animation(self):
def change_langs():
while True:
for lang in self.welcome:
GLib.idle_add(self.title_label.set_text, lang)
time.sleep(1.2)
for locale in all_locale:
translator = translation('vanilla-first-setup', localedir=f"{sys.base_prefix}/share/locale", languages=[locale], fallback=True)
_ = translator.gettext
GLib.idle_add(self.title_label.set_text, _("Welcome!"))
GLib.idle_add(self.btn_next.set_label, _("Next"))
GLib.idle_add(self.btn_advanced.set_label, _("Advanced"))
GLib.idle_add(self.welcome_message.set_label, _("Make your choices, this wizard will take care of everything."))
time.sleep(2.0)

RunAsync(change_langs, None)

Expand Down
4 changes: 2 additions & 2 deletions vanilla_first_setup/gtk/default-welcome.ui
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">Make your choices, this wizard will take care of everything</property>
<object class="GtkLabel" id="welcome_message">
<property name="label" translatable="yes">Make your choices, this wizard will take care of everything</property>
<property name="justify">2</property>
</object>
</child>
Expand Down

0 comments on commit 20e5fcd

Please sign in to comment.