Fix startup errors in some non-English locales in Fx30 on OS X
nsICollation broke for some locales. (Testing requires changing the language setting in Language & Region and then restarting the computer. The change seems to not fully go into effect until then, even though the UI changes.) This is fixed in Nightly, but we can work around it by using the new Intl.Collator.
This commit is contained in:
parent
9f379c99e0
commit
979e62714c
|
@ -67,7 +67,6 @@ Components.utils.import("resource://gre/modules/Services.jsm");
|
|||
this.safeDebug = safeDebug;
|
||||
this.getString = getString;
|
||||
this.localeJoin = localeJoin;
|
||||
this.getLocaleCollation = getLocaleCollation;
|
||||
this.setFontSize = setFontSize;
|
||||
this.flattenArguments = flattenArguments;
|
||||
this.getAncestorByTagName = getAncestorByTagName;
|
||||
|
@ -1467,12 +1466,32 @@ Components.utils.import("resource://gre/modules/Services.jsm");
|
|||
}
|
||||
|
||||
|
||||
function getLocaleCollation() {
|
||||
this.getLocaleCollation = function () {
|
||||
if (this.collation) {
|
||||
return this.collation;
|
||||
}
|
||||
|
||||
var localeService = Components.classes["@mozilla.org/intl/nslocaleservice;1"]
|
||||
.getService(Components.interfaces.nsILocaleService);
|
||||
var collationFactory = Components.classes["@mozilla.org/intl/collation-factory;1"]
|
||||
.getService(Components.interfaces.nsICollationFactory);
|
||||
return collationFactory.CreateCollation(localeService.getApplicationLocale());
|
||||
.getService(Components.interfaces.nsILocaleService);
|
||||
var appLocale = localeService.getApplicationLocale();
|
||||
|
||||
// Use nsICollation before Fx29
|
||||
if (Zotero.platformMajorVersion < 29) {
|
||||
var localeService = Components.classes["@mozilla.org/intl/nslocaleservice;1"]
|
||||
.getService(Components.interfaces.nsILocaleService);
|
||||
var collationFactory = Components.classes["@mozilla.org/intl/collation-factory;1"]
|
||||
.getService(Components.interfaces.nsICollationFactory);
|
||||
return this.collation = collationFactory.CreateCollation(appLocale);
|
||||
}
|
||||
|
||||
var locale = appLocale.getCategory('NSILOCALE_COLLATE');
|
||||
var collator = new Intl.Collator(locale);
|
||||
// Until old code is updated, pretend we're returning an nsICollation
|
||||
return this.collation = {
|
||||
compareString: function (_, a, b) {
|
||||
return collator.compare(a, b);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user