diff --git a/src/extension.js b/src/extension.js
index 6f69dea..7f6339d 100644
--- a/src/extension.js
+++ b/src/extension.js
@@ -19,9 +19,14 @@ this program. If not, see .
'use strict';
const { Gio } = imports.gi;
+const { extensionUtils } = imports.misc;
const { main } = imports.ui;
+const Gettext = imports.gettext;
+const _ = Gettext.gettext;
+
const EXT_NAME = 'Night Theme Switcher';
+const EXT_UUID = 'nightthemeswitcher@romainvigier.fr';
const GSETTINGS_SCHEMA = 'org.gnome.desktop.interface';
const GSETTINGS_PROPERTY = 'gtk-theme';
@@ -29,6 +34,11 @@ const GSETTINGS_PROPERTY = 'gtk-theme';
class Switcher {
+ constructor() {
+ Gettext.textdomain(EXT_UUID);
+ extensionUtils.initTranslations(EXT_UUID);
+ }
+
enable() {
this.theme = new Themer();
this.variants = Variants.guess_from(this.theme.current);
@@ -47,7 +57,7 @@ class Switcher {
this.nightlight.stop_listening();
}
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);
}
finally
@@ -89,7 +99,7 @@ class Themer {
}
listen(callback) {
- this.connect = this.gsettings.connect(`changed::${GSETTINGS_PROPERTY}`, callback);
+ this.connect = this.gsettings.connect('changed::' + GSETTINGS_PROPERTY, callback);
}
stop_listening() {
@@ -134,7 +144,8 @@ class Nightlighter {
_connect_to_dbus() {
const connection = Gio.bus_get_sync(Gio.BusType.SESSION, 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(
connection,
@@ -146,7 +157,8 @@ class Nightlighter {
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);
}
}
diff --git a/src/metadata.json b/src/metadata.json
index 14bafe2..8ff1a53 100644
--- a/src/metadata.json
+++ b/src/metadata.json
@@ -4,5 +4,6 @@
"uuid": "nightthemeswitcher@romainvigier.fr",
"url": "https://gitlab.com/rmnvgr/nightthemeswitcher-gnome-shell-extension/",
"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"
}
diff --git a/src/po/fr.po b/src/po/fr.po
new file mode 100644
index 0000000..a20f57f
--- /dev/null
+++ b/src/po/fr.po
@@ -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 \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."
diff --git a/src/po/nightthemeswitcher@romainvigier.fr.pot b/src/po/nightthemeswitcher@romainvigier.fr.pot
new file mode 100644
index 0000000..6f29f6c
--- /dev/null
+++ b/src/po/nightthemeswitcher@romainvigier.fr.pot
@@ -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 \n"
+"Language-Team: LANGUAGE \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 ""