extensions: Add static defineTranslationFunctions() method
The method can be used to define a set of gettext functions that call the corresponding method of an extension. Those functions are very similar to the gettext functions we are exporting, except that: - looking up the extension is delegated to the Extension/Preferences class - it is possible to avoid examining the stack when called with `import.meta.url` Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2838>
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import {ExtensionBase, setExtensionManager} from './sharedInternals.js';
|
||||
import {ExtensionBase, GettextWrapper, setExtensionManager} from './sharedInternals.js';
|
||||
|
||||
export {gettext, ngettext, pgettext} from './sharedInternals.js';
|
||||
|
||||
@ -6,6 +6,11 @@ const {extensionManager} = imports.ui.main;
|
||||
setExtensionManager(extensionManager);
|
||||
|
||||
export class Extension extends ExtensionBase {
|
||||
static defineTranslationFunctions(url) {
|
||||
const wrapper = new GettextWrapper(this, url);
|
||||
return wrapper.defineTranslationFunctions();
|
||||
}
|
||||
|
||||
enable() {
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user