Skip to content

Commit

Permalink
Fix some language and region names not shown in own languages (#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryonakano authored Jun 18, 2024
1 parent 553cdfa commit 585f6df
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
15 changes: 12 additions & 3 deletions src/Widgets/LanguageListBox.vala
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class SwitchboardPlugLocale.Widgets.LanguageListBox : Gtk.Box {
continue;
}

add_language (code);
add_language (code, locale);
}

var row = listbox.get_first_child ();
Expand All @@ -67,9 +67,9 @@ public class SwitchboardPlugLocale.Widgets.LanguageListBox : Gtk.Box {
}
}

private void add_language (string code) {
private void add_language (string code, string locale) {
if (!languages.has_key (code)) {
var language_string = Utils.translate (code, null);
var language_string = Utils.translate (code, locale);

if (lm.get_user_language ().slice (0, 2) == code) {
languages[code] = new LanguageRow (code, language_string, true);
Expand Down Expand Up @@ -109,6 +109,15 @@ public class SwitchboardPlugLocale.Widgets.LanguageListBox : Gtk.Box {
}
}

public string? get_selected_language_name () {
var selected_row = listbox.get_selected_row () as LanguageRow;
if (selected_row != null) {
return selected_row.text;
} else {
return null;
}
}

private class LanguageRow : Gtk.ListBoxRow {
public string code { get; construct; }
public string text { get; construct; }
Expand Down
6 changes: 3 additions & 3 deletions src/Widgets/LocaleSetting.vala
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ namespace SwitchboardPlugLocale.Widgets {
continue;
}

var region_string = Utils.translate_region (language, code, language);
var region_string = Utils.translate_region (language, code, locale);

var locale_object = new Locale (region_string, locale);

Expand Down Expand Up @@ -325,8 +325,8 @@ namespace SwitchboardPlugLocale.Widgets {
compare ();
}

public void reload_labels (string language) {
title = Utils.translate (language, null);
public void reload_labels (string language_name) {
title = language_name;
}

private void on_applied_to_system () {
Expand Down
3 changes: 2 additions & 1 deletion src/Widgets/LocaleView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,12 @@ namespace SwitchboardPlugLocale.Widgets {
}

var selected_language_code = list_box.get_selected_language_code ();
var selected_language_name = list_box.get_selected_language_name ();
var locales = Utils.get_locales_for_language_code (selected_language_code);

debug ("reloading Settings widget for language '%s'".printf (selected_language_code));
locale_setting.reload_locales.begin (selected_language_code, locales);
locale_setting.reload_labels (selected_language_code);
locale_setting.reload_labels (selected_language_name);

if (locale_manager.get_user_language () in locales) {
remove_button.sensitive = false;
Expand Down

0 comments on commit 585f6df

Please sign in to comment.