mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-09 12:51:09 +02:00
Use schema-generated i18n API for both content script and addon contexts, instead of just the addon context. MozReview-Commit-ID: AKDAFxNv6Zs --HG-- extra : rebase_source : ea66e8bab7b4713d971614ce27e8c1d9350a0a14
34 lines
911 B
JavaScript
34 lines
911 B
JavaScript
"use strict";
|
|
|
|
var {classes: Cc, interfaces: Ci, utils: Cu} = Components;
|
|
|
|
Cu.import("resource://gre/modules/ExtensionUtils.jsm");
|
|
var {
|
|
detectLanguage,
|
|
} = ExtensionUtils;
|
|
|
|
function i18nApiFactory(context) {
|
|
let {extension} = context;
|
|
return {
|
|
i18n: {
|
|
getMessage: function(messageName, substitutions) {
|
|
return extension.localizeMessage(messageName, substitutions, {cloneScope: context.cloneScope});
|
|
},
|
|
|
|
getAcceptLanguages: function() {
|
|
let result = extension.localeData.acceptLanguages;
|
|
return Promise.resolve(result);
|
|
},
|
|
|
|
getUILanguage: function() {
|
|
return extension.localeData.uiLocale;
|
|
},
|
|
|
|
detectLanguage: function(text) {
|
|
return detectLanguage(text);
|
|
},
|
|
},
|
|
};
|
|
}
|
|
extensions.registerSchemaAPI("i18n", "addon_child", i18nApiFactory);
|
|
extensions.registerSchemaAPI("i18n", "content_child", i18nApiFactory);
|