Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fully translate welcome page on rotation #338

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading