fx-compat: Automatically register plugin l10n sources (#2863)
Fixes #2837
This commit is contained in:
parent
367090614d
commit
bde157b085
1 changed files with 24 additions and 0 deletions
|
@ -85,6 +85,30 @@ Zotero.Intl = new function () {
|
|||
this.strings[regexpResult[1]] = regexpResult[2];
|
||||
}
|
||||
}
|
||||
|
||||
// Automatically register l10n sources for enabled plugins.
|
||||
|
||||
// A Fluent file located at
|
||||
// [plugin root]/locale/en-US/make-it-red.ftl
|
||||
// could be included in an XHTML file as
|
||||
// <link rel="localization" href="make-it-red.ftl"/>
|
||||
|
||||
// If a plugin doesn't have a subdirectory for the active locale, en-US strings
|
||||
// will be used as a fallback.
|
||||
Zotero.Plugins.addObserver({
|
||||
startup({ id: pluginID, rootURI }) {
|
||||
let source = new L10nFileSource(
|
||||
pluginID, 'app',
|
||||
Services.locale.availableLocales,
|
||||
rootURI + 'locale/{locale}/',
|
||||
);
|
||||
L10nRegistry.getInstance().registerSources([source]);
|
||||
},
|
||||
|
||||
shutdown({ id: pluginID }) {
|
||||
L10nRegistry.getInstance().removeSources([pluginID]);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue