Restart after migrating legacy locale prefs

DTDs are loaded based on the initial state of `intl.locale.requested`,
so if `intl.locale.matchOS` was false, we need to restart after
migrating that to keep part of the UI from being in the wrong locale.
(Before zotero/zotero-standalone-build@ced8a0fa63, it would've been
English. After it would probably be the OS locale.)

https://forums.zotero.org/discussion/79673/zotero-5-0-77-beta-has-no-localization-anymore
This commit is contained in:
Dan Stillman 2019-10-27 03:38:08 -04:00
parent 1a66f5e518
commit d96fe03fa2
2 changed files with 7 additions and 0 deletions

View file

@ -35,9 +35,11 @@ Zotero.Intl = new function () {
var prevLocale = Zotero.Prefs.get('general.useragent.locale', true);
if (prevMatchOS !== undefined || prevLocale !== undefined) {
let restart = false;
if (prevMatchOS === false && prevLocale) {
try {
Services.locale.setRequestedLocales([prevLocale]);
restart = true;
}
catch (e) {
// Don't panic if the value is not a valid locale code
@ -45,6 +47,10 @@ Zotero.Intl = new function () {
}
Zotero.Prefs.clear('intl.locale.matchOS', true);
Zotero.Prefs.clear('general.useragent.locale', true);
if (restart) {
Zotero.Utilities.Internal.quitZotero(true);
return;
}
}
Components.utils.import("resource://gre/modules/PluralForm.jsm");

View file

@ -240,6 +240,7 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
Zotero.browser = "g";
Zotero.Intl.init();
if (this.restarting) return;
yield Zotero.Prefs.init();
Zotero.Debug.init(options && options.forceDebugLog);