mirror of
https://github.com/oleid/gnome-shell-teatime.git
synced 2022-04-29 18:53:50 +00:00
Proper initialisation of translations
This commit is contained in:
parent
35fb22f427
commit
f2070f9725
@ -25,8 +25,7 @@ const ExtensionUtils = imports.misc.extensionUtils;
|
|||||||
const Me = ExtensionUtils.getCurrentExtension();
|
const Me = ExtensionUtils.getCurrentExtension();
|
||||||
const Utils = Me.imports.utils;
|
const Utils = Me.imports.utils;
|
||||||
|
|
||||||
Gettext.textdomain("TeaTime");
|
Utils.initTranslations("TeaTime");
|
||||||
Utils.bindTextDomain();
|
|
||||||
|
|
||||||
const _ = Gettext.gettext;
|
const _ = Gettext.gettext;
|
||||||
const N_ = function(e) { return e; };
|
const N_ = function(e) { return e; };
|
||||||
|
@ -20,8 +20,7 @@ const ExtensionUtils = imports.misc.extensionUtils;
|
|||||||
const Me = ExtensionUtils.getCurrentExtension();
|
const Me = ExtensionUtils.getCurrentExtension();
|
||||||
const Utils = Me.imports.utils;
|
const Utils = Me.imports.utils;
|
||||||
|
|
||||||
Gettext.textdomain("TeaTime");
|
Utils.initTranslations("TeaTime");
|
||||||
Utils.bindTextDomain();
|
|
||||||
|
|
||||||
const _ = Gettext.gettext;
|
const _ = Gettext.gettext;
|
||||||
const N_ = function(e) { return e; };
|
const N_ = function(e) { return e; };
|
||||||
|
32
src/utils.js
32
src/utils.js
@ -3,23 +3,33 @@
|
|||||||
Thomas Liebetraut <thomas@tommie-lie.de>
|
Thomas Liebetraut <thomas@tommie-lie.de>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const Gio = imports.gi.Gio;
|
const Gio = imports.gi.Gio;
|
||||||
const Lang = imports.lang;
|
const Lang = imports.lang;
|
||||||
|
const Gettext = imports.gettext;
|
||||||
const ExtensionUtils = imports.misc.extensionUtils;
|
const ExtensionUtils = imports.misc.extensionUtils;
|
||||||
const Me = ExtensionUtils.getCurrentExtension();
|
const Me = ExtensionUtils.getCurrentExtension();
|
||||||
|
const Config = imports.misc.config;
|
||||||
|
|
||||||
const TEATIME_STEEP_TIMES_KEY = 'steep-times';
|
const TEATIME_STEEP_TIMES_KEY = 'steep-times';
|
||||||
|
|
||||||
function bindTextDomain() {
|
function initTranslations(domain) {
|
||||||
// Evil hack to check, if extension is globally installed.
|
let extension = ExtensionUtils.getCurrentExtension();
|
||||||
// If it is, we may not bind to the text domain, as the translation won't
|
|
||||||
// be found
|
domain = domain || extension.metadata['gettext-domain'];
|
||||||
if( Me.dir.get_path() != "/usr/share/gnome-shell/extensions/TeaTime@oleid.mescharet.de" ) {
|
|
||||||
Gettext.bindtextdomain("TeaTime", Me.dir.get_path() + "/locale");
|
Gettext.textdomain(domain);
|
||||||
}
|
// check if this extension was built with "make zip-file", and thus
|
||||||
|
// has the locale files in a subfolder
|
||||||
|
// otherwise assume that extension has been installed in the
|
||||||
|
// same prefix as gnome-shell
|
||||||
|
let localeDir = extension.dir.get_child('locale');
|
||||||
|
if (localeDir.query_exists(null))
|
||||||
|
Gettext.bindtextdomain(domain, localeDir.get_path());
|
||||||
|
else
|
||||||
|
Gettext.bindtextdomain(domain, Config.LOCALEDIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function getSettings(schema) {
|
function getSettings(schema) {
|
||||||
let extension = ExtensionUtils.getCurrentExtension();
|
let extension = ExtensionUtils.getCurrentExtension();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user