diff options
author | Florian Müllner <fmuellner@gnome.org> | 2020-04-12 02:45:55 +0200 |
---|---|---|
committer | Marge Bot <marge-bot@gnome.org> | 2021-08-14 18:45:25 +0000 |
commit | 1deb13e1aaabfd04b2641976a224b6fc2be3b9ec (patch) | |
tree | 0f1850ca2735a25064910c1d3a0c4a665d23c7c9 /subprojects/extensions-tool | |
parent | b9f38f95e37b67ac3aa67f87e301742156ba7ceb (diff) | |
download | gnome-shell-1deb13e1aaabfd04b2641976a224b6fc2be3b9ec.tar.gz |
extensionUtils: Add gettext convenience helpers
We have initTranslations() for binding an extension's
gettext domain, but nothing to help with using gettext
from an extension.
Such help would be useful though, as an extension that
calls textdomain() like a normal application would
inadvertently changes the default domain for the whole
gnome-shell process.
Instead, extensions have to use domain-specific versions
of the gettext functions:
```js
const Gettext = imports.gettext.domain('my-extension');
const _ = Gettext.gettext;
```
Make this a bit easier by adding those functions directly
to the extensions object when initTranslations() is called,
then expose helper functions for calling them.
https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2594
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1941>
Diffstat (limited to 'subprojects/extensions-tool')
-rw-r--r-- | subprojects/extensions-tool/src/templates/indicator/extension.js | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/subprojects/extensions-tool/src/templates/indicator/extension.js b/subprojects/extensions-tool/src/templates/indicator/extension.js index 5d9753efc..9ed2c385c 100644 --- a/subprojects/extensions-tool/src/templates/indicator/extension.js +++ b/subprojects/extensions-tool/src/templates/indicator/extension.js @@ -22,14 +22,13 @@ const GETTEXT_DOMAIN = 'my-indicator-extension'; const { GObject, St } = imports.gi; -const Gettext = imports.gettext.domain(GETTEXT_DOMAIN); -const _ = Gettext.gettext; - const ExtensionUtils = imports.misc.extensionUtils; const Main = imports.ui.main; const PanelMenu = imports.ui.panelMenu; const PopupMenu = imports.ui.popupMenu; +const _ = ExtensionUtils.gettext; + const Indicator = GObject.registerClass( class Indicator extends PanelMenu.Button { _init() { |