Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translation Support + German Translation #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions [email protected]/convenience.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

const Gettext = imports.gettext;
const Config = imports.misc.config;

const Gio = imports.gi.Gio;
const ExtensionUtils = imports.misc.extensionUtils;

Expand Down Expand Up @@ -65,3 +68,26 @@ function getSettings(schema) {

return new Gio.Settings({ settings_schema: schemaObj });
}

/**
* initTranslations:
* @domain: (optional): the gettext domain to use
*
* Initialize Gettext to load translations from extensionsdir/locale.
* If @domain is not provided, it will be taken from metadata['gettext-domain']
*/
function initTranslations(domain) {
let extension = ExtensionUtils.getCurrentExtension();

domain = domain || extension.metadata['gettext-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);
}
18 changes: 11 additions & 7 deletions [email protected]/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ const Parser = Me.imports.parsers.factory;
const Log = Me.imports.logger;
const Settings = Convenience.getSettings();

const Gettext = imports.gettext.domain('rss-feed');
const _ = Gettext.gettext;

const ExtensionGui = {
RssPopupMenuItem: Me.imports.extensiongui.rsspopupmenuitem.RssPopupMenuItem,
RssPopupSubMenuMenuItem: Me.imports.extensiongui.rsspopupsubmenumenuitem.RssPopupSubMenuMenuItem
Expand Down Expand Up @@ -89,12 +92,12 @@ const RssFeedButton = new Lang.Class({
});

let systemMenu = Main.panel.statusArea.aggregateMenu._system;
let prevBtn = systemMenu._createActionButton('go-previous-symbolic', "Previous");
let nextBtn = systemMenu._createActionButton('go-next-symbolic', "Next");
let reloadBtn = systemMenu._createActionButton('view-refresh-symbolic', "Reload RSS Feeds");
let settingsBtn = systemMenu._createActionButton('preferences-system-symbolic', "RSS Feed Settings");
let prevBtn = systemMenu._createActionButton('go-previous-symbolic', _("Previous"));
let nextBtn = systemMenu._createActionButton('go-next-symbolic', _("Next"));
let reloadBtn = systemMenu._createActionButton('view-refresh-symbolic', _("Reload RSS Feeds"));
let settingsBtn = systemMenu._createActionButton('preferences-system-symbolic', _("RSS Feed Settings"));

this._lastUpdateTime = new St.Button({label: 'Last update: --:--'});
this._lastUpdateTime = new St.Button({label: _("Last update")+': --:--'});

this._buttonMenu.actor.add_actor(prevBtn);
this._buttonMenu.actor.add_actor(nextBtn);
Expand Down Expand Up @@ -329,7 +332,7 @@ const RssFeedButton = new Lang.Class({

// update last download time
let time = new Date();
this._lastUpdateTime.set_label('Last update: ' + this._pad(time.getHours(), 2)
this._lastUpdateTime.set_label(_("Last update")+': ' + this._pad(time.getHours(), 2)
+ ':' + this._pad(time.getMinutes(), 2));

rssParser.clear();
Expand Down Expand Up @@ -362,7 +365,7 @@ const RssFeedButton = new Lang.Class({
}
else {

let subMenu = new PopupMenu.PopupMenuItem('No data available');
let subMenu = new PopupMenu.PopupMenuItem(_("No data available"));
this._feedsSection.addMenuItem(subMenu);
}

Expand All @@ -384,6 +387,7 @@ let rssFeedBtn;
* Initialize the extension
*/
function init() {
Convenience.initTranslations("rss-feed");

// hack for dconf
let enabled = Settings.get_boolean(DEBUG_ENABLED_KEY);
Expand Down
Binary file not shown.
60 changes: 60 additions & 0 deletions [email protected]/locale/de/LC_MESSAGES/rss-feed.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: RSS Feed GNOME Shell Extension\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-06-18 11:03-0300\n"
"PO-Revision-Date: 2015-06-18 11:03-0300\n"
"Last-Translator: Jonatan Zeidler <[email protected]>\n"
"Language-Team: German <[email protected]>\n"
"Language: de\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: Poedit 1.7.5\n"
"X-Poedit-SourceCharset: UTF-8\n"

#: extension.js:95
msgid "Previous"
msgstr "Zurück"

#: extension.js:96
msgid "Next"
msgstr "Weiter"

#: extension.js:97
msgid "Reload RSS Feeds"
msgstr "RSS-Quellen abrufen"

#: extension.js:98
msgid "RSS Feed Settings"
msgstr "Einstellungen der RSS-Quellen"

#: extension.js:100 extension.js:335
msgid "Last update"
msgstr "Zuletzt aktualisiert"

#: extension.js:368
msgid "No data available"
msgstr "Keine Daten verfügbar"

#: prefs.js:65
msgid "Update interval (minutes):"
msgstr "Aktualisierungsintervall (Minuten):"

#: prefs.js:78
msgid "RSS sources per page:"
msgstr "RSS-Quellen pro Seite:"

#: prefs.js:187
msgid "New RSS Feed source"
msgstr "Neue RSS-Quelle"

#: prefs.js:211
msgid "Edit RSS Feed source"
msgstr "RSS-Quelle bearbeiten"
13 changes: 9 additions & 4 deletions [email protected]/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ const Lang = imports.lang;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const Settings = Me.imports.convenience.getSettings();

const Convenience = Me.imports.convenience;
const Gettext = imports.gettext.domain('rss-feed');
const _ = Gettext.gettext;

const COLUMN_ID = 0;
const MAX_UPDATE_INTERVAL = 1440;
const MAX_SOURCES_LIMIT = 1024;
Expand Down Expand Up @@ -58,7 +62,7 @@ const RssFeedSettingsWidget = new GObject.Class({
// update interval
let box = new Gtk.Box( { orientation: Gtk.Orientation.HORIZONTAL, spacing: 6 } );
box.set_margin_bottom(6);
let label = new Gtk.Label({ xalign: 0, label: 'Update interval (minutes):' });
let label = new Gtk.Label({ xalign: 0, label: _("Update interval (minutes):") });
box.pack_start(label, true, true, 0);

let spinbtn = Gtk.SpinButton.new_with_range(0, MAX_UPDATE_INTERVAL, 1);
Expand All @@ -71,7 +75,7 @@ const RssFeedSettingsWidget = new GObject.Class({
// items visible per page
let box2 = new Gtk.Box( { orientation: Gtk.Orientation.HORIZONTAL, spacing: 6 } );
box2.set_margin_bottom(6);
let label2 = new Gtk.Label({ xalign: 0, label: 'RSS sources per page:' });
let label2 = new Gtk.Label({ xalign: 0, label: _("RSS sources per page:") });
box2.pack_start(label2, true, true, 0);

let spinbtn2 = Gtk.SpinButton.new_with_range(1, MAX_SOURCES_LIMIT, 1);
Expand Down Expand Up @@ -180,7 +184,7 @@ const RssFeedSettingsWidget = new GObject.Class({
*/
_createNew: function() {

this._createDialog('New RSS Feed source', '', Lang.bind(this, function() {
this._createDialog(_("New RSS Feed source"), '', Lang.bind(this, function() {

// update tree view
let iter = this._store.append();
Expand All @@ -204,7 +208,7 @@ const RssFeedSettingsWidget = new GObject.Class({
let [any, model, iter] = this._actor.get_selection().get_selected();

if (any) {
this._createDialog('Edit RSS Feed source', model.get_value(iter, COLUMN_ID),
this._createDialog(_("Edit RSS Feed source"), model.get_value(iter, COLUMN_ID),
Lang.bind(this, function() {
// update tree view
this._store.set_value(iter, COLUMN_ID, this._entry.get_text());
Expand Down Expand Up @@ -273,6 +277,7 @@ const RssFeedSettingsWidget = new GObject.Class({
* Initialize the settings widget
*/
function init() {
Convenience.initTranslations("rss-feed");
}

/*
Expand Down
58 changes: 58 additions & 0 deletions [email protected]/rss-feed.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-06-18 11:03-0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"

#: extension.js:95
msgid "Previous"
msgstr ""

#: extension.js:96
msgid "Next"
msgstr ""

#: extension.js:97
msgid "Reload RSS Feeds"
msgstr ""

#: extension.js:98
msgid "RSS Feed Settings"
msgstr ""

#: extension.js:100 extension.js:335
msgid "Last update"
msgstr ""

#: extension.js:368
msgid "No data available"
msgstr ""

#: prefs.js:65
msgid "Update interval (minutes):"
msgstr ""

#: prefs.js:78
msgid "RSS sources per page:"
msgstr ""

#: prefs.js:187
msgid "New RSS Feed source"
msgstr ""

#: prefs.js:211
msgid "Edit RSS Feed source"
msgstr ""