Add translations support
This commit is contained in:
+16
-4
@@ -19,9 +19,14 @@ this program. If not, see <http s ://www.gnu.org/licenses/>.
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { Gio } = imports.gi;
|
const { Gio } = imports.gi;
|
||||||
|
const { extensionUtils } = imports.misc;
|
||||||
const { main } = imports.ui;
|
const { main } = imports.ui;
|
||||||
|
|
||||||
|
const Gettext = imports.gettext;
|
||||||
|
const _ = Gettext.gettext;
|
||||||
|
|
||||||
const EXT_NAME = 'Night Theme Switcher';
|
const EXT_NAME = 'Night Theme Switcher';
|
||||||
|
const EXT_UUID = 'nightthemeswitcher@romainvigier.fr';
|
||||||
|
|
||||||
const GSETTINGS_SCHEMA = 'org.gnome.desktop.interface';
|
const GSETTINGS_SCHEMA = 'org.gnome.desktop.interface';
|
||||||
const GSETTINGS_PROPERTY = 'gtk-theme';
|
const GSETTINGS_PROPERTY = 'gtk-theme';
|
||||||
@@ -29,6 +34,11 @@ const GSETTINGS_PROPERTY = 'gtk-theme';
|
|||||||
|
|
||||||
class Switcher {
|
class Switcher {
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
Gettext.textdomain(EXT_UUID);
|
||||||
|
extensionUtils.initTranslations(EXT_UUID);
|
||||||
|
}
|
||||||
|
|
||||||
enable() {
|
enable() {
|
||||||
this.theme = new Themer();
|
this.theme = new Themer();
|
||||||
this.variants = Variants.guess_from(this.theme.current);
|
this.variants = Variants.guess_from(this.theme.current);
|
||||||
@@ -47,7 +57,7 @@ class Switcher {
|
|||||||
this.nightlight.stop_listening();
|
this.nightlight.stop_listening();
|
||||||
}
|
}
|
||||||
catch(e) {
|
catch(e) {
|
||||||
const message = 'Errors occured while disabling the extension, try removing it.';
|
const message = _('Errors occured while disabling the extension, try removing it.');
|
||||||
main.notifyError(EXT_NAME, message);
|
main.notifyError(EXT_NAME, message);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
@@ -89,7 +99,7 @@ class Themer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
listen(callback) {
|
listen(callback) {
|
||||||
this.connect = this.gsettings.connect(`changed::${GSETTINGS_PROPERTY}`, callback);
|
this.connect = this.gsettings.connect('changed::' + GSETTINGS_PROPERTY, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
stop_listening() {
|
stop_listening() {
|
||||||
@@ -134,7 +144,8 @@ class Nightlighter {
|
|||||||
_connect_to_dbus() {
|
_connect_to_dbus() {
|
||||||
const connection = Gio.bus_get_sync(Gio.BusType.SESSION, null);
|
const connection = Gio.bus_get_sync(Gio.BusType.SESSION, null);
|
||||||
if ( connection === null ) {
|
if ( connection === null ) {
|
||||||
throw new Error('Unable to connect to the session bus');
|
const message = _('Unable to connect to the session bus.');
|
||||||
|
throw new Error(message);
|
||||||
}
|
}
|
||||||
this.proxy = Gio.DBusProxy.new_sync(
|
this.proxy = Gio.DBusProxy.new_sync(
|
||||||
connection,
|
connection,
|
||||||
@@ -146,7 +157,8 @@ class Nightlighter {
|
|||||||
null
|
null
|
||||||
);
|
);
|
||||||
if ( this.proxy === null ) {
|
if ( this.proxy === null ) {
|
||||||
throw new Error('Unable to create proxy to the session bus');
|
const message = _('Unable to create proxy to the session bus.');
|
||||||
|
throw new Error(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -4,5 +4,6 @@
|
|||||||
"uuid": "nightthemeswitcher@romainvigier.fr",
|
"uuid": "nightthemeswitcher@romainvigier.fr",
|
||||||
"url": "https://gitlab.com/rmnvgr/nightthemeswitcher-gnome-shell-extension/",
|
"url": "https://gitlab.com/rmnvgr/nightthemeswitcher-gnome-shell-extension/",
|
||||||
"version": 7,
|
"version": 7,
|
||||||
"shell-version": ["3.28", "3.30","3.32", "3.34"]
|
"shell-version": ["3.28", "3.30","3.32", "3.34"],
|
||||||
|
"gettext-domain": "nightthemeswitcher@romainvigier.fr"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
# Night Theme Switcher
|
||||||
|
# Copyright (C) 2019 Romain Vigier
|
||||||
|
# This file is distributed under the same license as the Night Theme Switcher package.
|
||||||
|
# Romain Vigier <>, 2019.
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: Night Theme Switcher 7\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2019-11-25 00:27+0100\n"
|
||||||
|
"PO-Revision-Date: 2019-11-25 00:28+0100\n"
|
||||||
|
"Last-Translator: Romain Vigier <>\n"
|
||||||
|
"Language-Team: French <none>\n"
|
||||||
|
"Language: fr\n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"Plural-Forms: nplurals=2; plural=(n > 1)\n"
|
||||||
|
"X-Generator: Gtranslator 3.34.0\n"
|
||||||
|
|
||||||
|
#: src/extension.js:60
|
||||||
|
msgid "Errors occured while disabling the extension, try removing it."
|
||||||
|
msgstr ""
|
||||||
|
"Des erreurs sont survenues en désactivant l’extension, essayez de la "
|
||||||
|
"supprimer."
|
||||||
|
|
||||||
|
#: src/extension.js:147
|
||||||
|
msgid "Unable to connect to the session bus."
|
||||||
|
msgstr "Impossible de se connecter au bus de la session."
|
||||||
|
|
||||||
|
#: src/extension.js:160
|
||||||
|
msgid "Unable to create proxy to the session bus."
|
||||||
|
msgstr "Impossible de créer une passerelle vers le bus de la session."
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
# Night Theme Switcher
|
||||||
|
# Copyright (C) 2019 Romain Vigier
|
||||||
|
# This file is distributed under the same license as the Night Theme Switcher package.
|
||||||
|
# Romain Vigier <>, 2019.
|
||||||
|
#
|
||||||
|
#, fuzzy
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: Night Theme Switcher 7\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2019-11-25 00:27+0100\n"
|
||||||
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
"Language: \n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=CHARSET\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
|
||||||
|
#: src/extension.js:60
|
||||||
|
msgid "Errors occured while disabling the extension, try removing it."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/extension.js:147
|
||||||
|
msgid "Unable to connect to the session bus."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: src/extension.js:160
|
||||||
|
msgid "Unable to create proxy to the session bus."
|
||||||
|
msgstr ""
|
||||||
Reference in New Issue
Block a user