Closed davidmhewitt closed 2 years ago
In Plug.vala: Since the langs array is overwritten by the reload method, it doesn't make sense to add/remove stuff first.
Oh, Unfortunately, the langs array is not overwritten. I solved this problem in this way:
src/Utils.vala:
+ public static Gee.ArrayList<string>? get_installed_languages (bool? check) {
+ if (installed_languages != null && check == true) {
return installed_languages;
}
- installed_languages = new Gee.ArrayList<string>.wrap (Gnome.Languages.get_all_locales ());
+ installed_languages = new Gee.ArrayList<string> ();
+ try {
+ string output;
+ Process.spawn_command_line_sync ("localectl \"list-locales\" \"--no-pager\"", out output);
+ var locales = output.split ("\n");
+ foreach (var locale in locales) {
+ string code;
+ if (locale != "") {
+ if (Gnome.Languages.parse_locale (locale, out code, null, null, null)) {
+ if (Gnome.Languages.language_has_translations (code)) {
+ installed_languages.add (locale);
+ }
+ }
+ }
+ }
+ } catch (Error e) {
+ warning (e.message);
+ }
/src/Plug.vala:
+ langs = Utils.get_installed_languages (true);
....
+ langs.clear ();
+ langs.add_all (langpacks);
+ reload.begin ();
Oh, Unfortunately, the langs array is not overwritten. I solved this problem in this way:
Ah yes, that's a slightly different issue. This is the minimum needed to fix #83.
Your changes there fix a different issue where languages are not added/removed to the sidebar on the left when they're installed/removed because we keep a cache array.
I'll open a separate issue for that and fix it in a different PR.
I've broken out part of #147 for this
Fixes #83
In
LocaleManager.vala
: Make sure we fall back to our alternative ways of getting the user's formats if its not set on AccountsService.In
Plug.vala
: Since thelangs
array is overwritten by thereload
method, it doesn't make sense to add/remove stuff first.In
LocaleSetting.vala
: Since the tree store is sorted alphabetically on the human readable name of the language (which could be translated), it doesn't make sense to try and select the active one by index, because the indexes could change on sort. So we use the locale key to select the active entry.