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,6 +1,6 @@
|
||||
import GObject from 'gi://GObject';
|
||||
|
||||
import {ExtensionBase, setExtensionManager} from './sharedInternals.js';
|
||||
import {ExtensionBase, GettextWrapper, setExtensionManager} from './sharedInternals.js';
|
||||
import {extensionManager} from '../extensionsService.js';
|
||||
|
||||
setExtensionManager(extensionManager);
|
||||
@ -8,6 +8,11 @@ setExtensionManager(extensionManager);
|
||||
export {gettext, ngettext, pgettext} from './sharedInternals.js';
|
||||
|
||||
export class ExtensionPreferences extends ExtensionBase {
|
||||
static defineTranslationFunctions(url) {
|
||||
const wrapper = new GettextWrapper(this, url);
|
||||
return wrapper.defineTranslationFunctions();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill the preferences window with preferences.
|
||||
*
|
||||
|
Reference in New Issue
Block a user