From 9bc83539d124f9645dc92e9e39001cb0192dae61 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Fri, 7 Apr 2017 11:09:47 +0200 Subject: Gettext support --- main/src/main.vala | 10 +++++++++- main/src/ui/add_conversation/chat/dialog.vala | 6 +++--- .../conference/add_groupchat_dialog.vala | 4 ++-- main/src/ui/add_conversation/conference/dialog.vala | 8 ++++---- main/src/ui/conversation_summary/message_item.vala | 2 +- main/src/ui/conversation_summary/view.vala | 4 ++-- main/src/ui/manage_accounts/add_account_dialog.vala | 2 +- main/src/ui/manage_accounts/dialog.vala | 18 +++++++++--------- main/src/ui/notifications.vala | 6 +++--- main/src/ui/occupant_menu/view.vala | 2 +- main/src/ui/unified_window.vala | 10 +++++----- 11 files changed, 40 insertions(+), 32 deletions(-) (limited to 'main/src') diff --git a/main/src/main.vala b/main/src/main.vala index 14029e47..e0d54d18 100644 --- a/main/src/main.vala +++ b/main/src/main.vala @@ -1,20 +1,28 @@ using Dino.Entities; using Dino.Ui; +extern const string GETTEXT_PACKAGE; +extern const string LOCALE_INSTALL_DIR; + namespace Dino { void main(string[] args) { + try{ string? exec_path = args.length > 0 ? args[0] : null; + SearchPathGenerator search_path_generator = new SearchPathGenerator(exec_path); if (exec_path != null && exec_path.contains(Path.DIR_SEPARATOR_S)) { string bindir = Path.get_dirname(exec_path); if (FileUtils.test(Path.build_filename(bindir, "gschemas.compiled"), FileTest.IS_REGULAR)) { Environment.set_variable("GSETTINGS_SCHEMA_DIR", Path.get_dirname(exec_path), false); } } + Intl.textdomain(GETTEXT_PACKAGE); + internationalize(GETTEXT_PACKAGE, search_path_generator.get_locale_path(GETTEXT_PACKAGE, LOCALE_INSTALL_DIR)); + Plugins.Loader loader = new Plugins.Loader(exec_path); Gtk.init(ref args); - Dino.Ui.Application app = new Dino.Ui.Application(); + Dino.Ui.Application app = new Dino.Ui.Application() { search_path_generator=search_path_generator }; app.add_main_option("plugin-paths", 0, 0, OptionArg.NONE, "Display plugin search paths and exit", null); app.handle_local_options.connect((options) => { diff --git a/main/src/ui/add_conversation/chat/dialog.vala b/main/src/ui/add_conversation/chat/dialog.vala index 910e7264..6873b4ca 100644 --- a/main/src/ui/add_conversation/chat/dialog.vala +++ b/main/src/ui/add_conversation/chat/dialog.vala @@ -18,7 +18,7 @@ public class Dialog : Gtk.Dialog { public Dialog(StreamInteractor stream_interactor) { Object(use_header_bar : 1); - this.title = "Start Chat"; + this.title = _("Start Chat"); this.modal = true; this.stream_interactor = stream_interactor; @@ -31,13 +31,13 @@ public class Dialog : Gtk.Dialog { header_bar.show_close_button = false; Button cancel_button = new Button(); - cancel_button.set_label("Cancel"); + cancel_button.set_label(_("Cancel")); cancel_button.visible = true; header_bar.pack_start(cancel_button); ok_button = new Button(); ok_button.get_style_context().add_class("suggested-action"); - ok_button.label = "Start"; + ok_button.label = _("Start"); ok_button.sensitive = false; ok_button.visible = true; header_bar.pack_end(ok_button); diff --git a/main/src/ui/add_conversation/conference/add_groupchat_dialog.vala b/main/src/ui/add_conversation/conference/add_groupchat_dialog.vala index 96d44000..10c91c70 100644 --- a/main/src/ui/add_conversation/conference/add_groupchat_dialog.vala +++ b/main/src/ui/add_conversation/conference/add_groupchat_dialog.vala @@ -25,7 +25,7 @@ protected class AddGroupchatDialog : Gtk.Dialog { public AddGroupchatDialog(StreamInteractor stream_interactor) { Object(use_header_bar : 1); this.stream_interactor = stream_interactor; - ok_button.label = "Add"; + ok_button.label = _("Add"); ok_button.get_style_context().add_class("suggested-action"); // TODO why doesn't it work in XML accounts_stack.set_visible_child_name("combobox"); account_combobox.initialize(stream_interactor); @@ -39,7 +39,7 @@ protected class AddGroupchatDialog : Gtk.Dialog { public AddGroupchatDialog.for_conference(StreamInteractor stream_interactor, Account account, Xmpp.Xep.Bookmarks.Conference conference) { this(stream_interactor); edit_confrence = conference; - ok_button.label = "Save"; + ok_button.label = _("Save"); ok_button.sensitive = true; accounts_stack.set_visible_child_name("label"); account_label.label = account.bare_jid.to_string(); diff --git a/main/src/ui/add_conversation/conference/dialog.vala b/main/src/ui/add_conversation/conference/dialog.vala index c035c11d..2da37c08 100644 --- a/main/src/ui/add_conversation/conference/dialog.vala +++ b/main/src/ui/add_conversation/conference/dialog.vala @@ -12,7 +12,7 @@ public class Dialog : Gtk.Dialog { private Stack stack = new Stack(); private Button cancel_button; private Button ok_button; - private Label cancel_label = new Label("Cancel") {visible=true}; + private Label cancel_label = new Label(_("Cancel")) {visible=true}; private Image cancel_image = new Image.from_icon_name("go-previous-symbolic", IconSize.MENU) {visible=true}; private SelectJidFragment select_fragment; @@ -23,7 +23,7 @@ public class Dialog : Gtk.Dialog { public Dialog(StreamInteractor stream_interactor) { Object(use_header_bar : 1); - this.title = "Join Conference"; + this.title = _("Join Conference"); this.modal = true; this.stream_interactor = stream_interactor; @@ -42,7 +42,7 @@ public class Dialog : Gtk.Dialog { cancel_button.add(cancel_label); cancel_button.clicked.disconnect(show_jid_add_view); cancel_button.clicked.connect(on_cancel); - ok_button.label = "Next"; + ok_button.label = _("Next"); ok_button.sensitive = select_fragment.done; ok_button.clicked.disconnect(on_ok_button_clicked); ok_button.clicked.connect(on_next_button_clicked); @@ -57,7 +57,7 @@ public class Dialog : Gtk.Dialog { cancel_button.add(cancel_image); cancel_button.clicked.disconnect(on_cancel); cancel_button.clicked.connect(show_jid_add_view); - ok_button.label = "Join"; + ok_button.label = _("Join"); ok_button.sensitive = details_fragment.done; ok_button.clicked.disconnect(on_next_button_clicked); ok_button.clicked.connect(on_ok_button_clicked); diff --git a/main/src/ui/conversation_summary/message_item.vala b/main/src/ui/conversation_summary/message_item.vala index fed67945..4b26a289 100644 --- a/main/src/ui/conversation_summary/message_item.vala +++ b/main/src/ui/conversation_summary/message_item.vala @@ -104,7 +104,7 @@ public class MessageItem : Grid, ConversationItem { } else if (timespan > TimeSpan.MINUTE) { return (timespan / TimeSpan.MINUTE).to_string() + " min ago"; } else { - return "Just now"; + return _("Just now"); } } } diff --git a/main/src/ui/conversation_summary/view.vala b/main/src/ui/conversation_summary/view.vala index 179c14e3..60d26cf0 100644 --- a/main/src/ui/conversation_summary/view.vala +++ b/main/src/ui/conversation_summary/view.vala @@ -117,9 +117,9 @@ public class View : Box { if (state_ != null) { if (state_ == Xep.ChatStateNotifications.STATE_COMPOSING || state_ == Xep.ChatStateNotifications.STATE_PAUSED) { if (state_ == Xep.ChatStateNotifications.STATE_COMPOSING) { - typing_status = new StatusItem(stream_interactor, conversation, "is typing..."); + typing_status = new StatusItem(stream_interactor, conversation, _("is typing...")); } else if (state_ == Xep.ChatStateNotifications.STATE_PAUSED) { - typing_status = new StatusItem(stream_interactor, conversation, "has stoped typing"); + typing_status = new StatusItem(stream_interactor, conversation, _("has stopped typing")); } main.add(typing_status); } diff --git a/main/src/ui/manage_accounts/add_account_dialog.vala b/main/src/ui/manage_accounts/add_account_dialog.vala index 8501f476..74754b79 100644 --- a/main/src/ui/manage_accounts/add_account_dialog.vala +++ b/main/src/ui/manage_accounts/add_account_dialog.vala @@ -18,7 +18,7 @@ public class AddAccountDialog : Gtk.Dialog { public AddAccountDialog(StreamInteractor stream_interactor) { Object(use_header_bar : 1); - this.title = "Add Account"; + this.title = _("Add Account"); cancel_button.clicked.connect(() => { close(); }); ok_button.clicked.connect(on_ok_button_clicked); diff --git a/main/src/ui/manage_accounts/dialog.vala b/main/src/ui/manage_accounts/dialog.vala index e8697bad..24a8b47c 100644 --- a/main/src/ui/manage_accounts/dialog.vala +++ b/main/src/ui/manage_accounts/dialog.vala @@ -147,9 +147,9 @@ public class Dialog : Gtk.Window { private void on_image_button_clicked() { FileChooserDialog chooser = new FileChooserDialog ( - "Select avatar", this, FileChooserAction.OPEN, - "Cancel", ResponseType.CANCEL, - "Select", ResponseType.ACCEPT); + _("Select avatar"), this, FileChooserAction.OPEN, + _("Cancel"), ResponseType.CANCEL, + _("Select"), ResponseType.ACCEPT); FileFilter filter = new FileFilter(); filter.add_mime_type("image/*"); chooser.set_filter(filter); @@ -248,11 +248,11 @@ public class Dialog : Gtk.Window { ConnectionManager.ConnectionState state = stream_interactor.connection_manager.get_state(account); switch (state) { case ConnectionManager.ConnectionState.CONNECTING: - state_label.label = "Connecting..."; break; + state_label.label = _("Connecting..."); break; case ConnectionManager.ConnectionState.CONNECTED: - state_label.label = "Connected"; break; + state_label.label = _("Connected"); break; case ConnectionManager.ConnectionState.DISCONNECTED: - state_label.label = "Disconnected"; break; + state_label.label = _("Disconnected"); break; } state_label.get_style_context().remove_class("is_error"); } @@ -275,12 +275,12 @@ public class Dialog : Gtk.Window { private string get_connection_error_description(ConnectionManager.ConnectionError error) { switch (error.source) { case ConnectionManager.ConnectionError.Source.SASL: - return "Wrong password"; + return _("Wrong password"); } if (error.identifier != null) { - return "Error" + ": " + error.identifier; + return _("Error") + ": " + error.identifier; } else { - return "Error"; + return _("Error"); } } } diff --git a/main/src/ui/notifications.vala b/main/src/ui/notifications.vala index 3846c7ba..029a4b33 100644 --- a/main/src/ui/notifications.vala +++ b/main/src/ui/notifications.vala @@ -56,9 +56,9 @@ public class Notifications : Object { } private void on_received_subscription_request(Jid jid, Account account) { - Notify.Notification notification = new Notify.Notification("Subscription request", jid.bare_jid.to_string(), null); + Notify.Notification notification = new Notify.Notification(_("Subscription request"), jid.bare_jid.to_string(), null); notification.set_image_from_pixbuf((new AvatarGenerator(40, 40)).draw_jid(stream_interactor, jid, account)); - notification.add_action("accept", "Accept", () => { + notification.add_action("accept", _("Accept"), () => { stream_interactor.get_module(PresenceManager.IDENTITY).approve_subscription(account, jid); if (stream_interactor.get_module(RosterManager.IDENTITY).get_roster_item(account, jid) == null) { @@ -71,7 +71,7 @@ public class Notifications : Object { notification.close(); } catch (Error error) { } }); - notification.add_action("deny", "Deny", () => { + notification.add_action("deny", _("Deny"), () => { stream_interactor.get_module(PresenceManager.IDENTITY).deny_subscription(account, jid); try { notification.close(); diff --git a/main/src/ui/occupant_menu/view.vala b/main/src/ui/occupant_menu/view.vala index b7fe15ba..b6b25961 100644 --- a/main/src/ui/occupant_menu/view.vala +++ b/main/src/ui/occupant_menu/view.vala @@ -45,7 +45,7 @@ public class View : Popover { Button header_button = new Button() { relief=ReliefStyle.NONE, visible=true }; header_button.add(header_box); - ModelButton private_button = new ModelButton() { active=true, text="Start private conversation", visible=true }; + ModelButton private_button = new ModelButton() { active=true, text=_("Start private conversation"), visible=true }; Box outer_box = new Box(Orientation.VERTICAL, 5) { margin=10, visible=true }; outer_box.add(header_button); diff --git a/main/src/ui/unified_window.vala b/main/src/ui/unified_window.vala index d4d9055c..1c4474c7 100644 --- a/main/src/ui/unified_window.vala +++ b/main/src/ui/unified_window.vala @@ -132,17 +132,17 @@ public class UnifiedWindow : Window { public class NoAccountsPlaceholder : UnifiedWindowPlaceholder { public NoAccountsPlaceholder() { - label.label = "No accounts active"; - primary_button.label = "Manage accounts"; + label.label = _("No accounts active"); + primary_button.label = _("Manage accounts"); secondary_button.visible = false; } } public class NoConversationsPlaceholder : UnifiedWindowPlaceholder { public NoConversationsPlaceholder() { - label.label = "No conversation active"; - primary_button.label = "Add Chat"; - secondary_button.label = "Join Conference"; + label.label = _("No conversation active"); + primary_button.label = _("Add Chat"); + secondary_button.label = _("Join Conference"); secondary_button.visible = true; } } -- cgit v1.2.3-70-g09d2