diff --git a/CMakeLists.txt b/CMakeLists.txt index bd0e757f..1d363485 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,7 @@ set(GETTEXT_PACKAGE "geary") set(RELEASE_NAME "Lightweight email client for GNOME.") set(VERSION "0.1.0+trunk") set(VERSION_INFO "Release") +set(LANGUAGE_SUPPORT_DIRECTORY ${CMAKE_INSTALL_PREFIX}/share/locale) # Packaging filenamesnames. set(ARCHIVE_BASE_NAME ${CMAKE_PROJECT_NAME}-${VERSION}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index aa810860..e023bb71 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,7 +6,7 @@ common/common-arrays.vala common/common-async.vala common/common-date.vala common/common-files.vala -common/common-intl.vala +common/common-international.vala common/common-yorba-application.vala ) @@ -273,6 +273,8 @@ set(CFLAGS -D_INSTALL_PREFIX=\"${CMAKE_INSTALL_PREFIX}\" -D_SOURCE_ROOT_DIR=\"${CMAKE_SOURCE_DIR}\" -D_GSETTINGS_DIR=\"${CMAKE_BINARY_DIR}/gsettings\" + -DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\" + -DLANGUAGE_SUPPORT_DIRECTORY=\"${LANGUAGE_SUPPORT_DIRECTORY}\" -g ) diff --git a/src/client/geary-application.vala b/src/client/geary-application.vala index d47d3088..141618f1 100644 --- a/src/client/geary-application.vala +++ b/src/client/geary-application.vala @@ -11,13 +11,12 @@ extern const string _GSETTINGS_DIR; extern const string _SOURCE_ROOT_DIR; public class GearyApplication : YorbaApplication { - // TODO: replace static strings with const strings when gettext is integrated properly public const string NAME = "Geary"; public const string PRGNAME = "geary"; - public static string DESCRIPTION = _("Email Client"); - public const string COPYRIGHT = "Copyright 2011-2012 Yorba Foundation"; + public const string DESCRIPTION = _("Email Client"); + public const string COPYRIGHT = _("Copyright 2011-2012 Yorba Foundation"); public const string WEBSITE = "http://www.yorba.org"; - public static string WEBSITE_LABEL = _("Visit the Yorba web site"); + public const string WEBSITE_LABEL = _("Visit the Yorba web site"); public const string BUGREPORT = "http://redmine.yorba.org/projects/geary/issues"; public const string VERSION = _VERSION; diff --git a/src/client/geary-controller.vala b/src/client/geary-controller.vala index 8a147358..84d51745 100644 --- a/src/client/geary-controller.vala +++ b/src/client/geary-controller.vala @@ -57,8 +57,7 @@ public class GearyController { private const int FETCH_EMAIL_CHUNK_COUNT = 50; - // TODO: Translate - private const string DEFAULT_DELETE_MESSAGE_LABEL = "_Delete"; + private const string DEFAULT_DELETE_MESSAGE_LABEL = _("_Delete"); private const string DEFAULT_DELETE_MESSAGE_TOOLTIP = null; private const string DEFAULT_DELETE_MESSAGE_ICON_NAME = "user-trash-full"; diff --git a/src/client/ui/composer-window.vala b/src/client/ui/composer-window.vala index 034d73e2..ffc194c9 100644 --- a/src/client/ui/composer-window.vala +++ b/src/client/ui/composer-window.vala @@ -6,7 +6,7 @@ // Window for sending messages. public class ComposerWindow : Gtk.Window { - private static string DEFAULT_TITLE = _("New Message"); + private const string DEFAULT_TITLE = _("New Message"); private const string ACTION_UNDO = "undo"; private const string ACTION_REDO = "redo"; diff --git a/src/client/ui/password-dialog.vala b/src/client/ui/password-dialog.vala index d53c150c..54d2dda7 100644 --- a/src/client/ui/password-dialog.vala +++ b/src/client/ui/password-dialog.vala @@ -9,6 +9,13 @@ * other data. */ public class PasswordDialog { + // We can't keep these in the glade file, because Gnome doesn't want markup in translatable + // strings, and Glade doesn't support the "larger" size attribute. See this bug report for + // details: https://bugzilla.gnome.org/show_bug.cgi?id=679006 + private const string PRIMARY_TEXT_MARKUP = "%s"; + private const string PRIMARY_TEXT_FIRST_TRY = _("Please enter your email password"); + private const string PRIMARY_TEXT_REPEATED_TRY = _("Unable to login to email server"); + private Gtk.Dialog dialog; private Gtk.Entry password_entry; private Gtk.CheckButton remember_password_checkbutton; @@ -22,24 +29,28 @@ public class PasswordDialog { Gtk.Builder builder = GearyApplication.instance.create_builder("password-dialog.glade"); // Load dialog - dialog = (Gtk.Dialog)builder.get_object("PasswordDialog"); + dialog = (Gtk.Dialog) builder.get_object("PasswordDialog"); dialog.set_type_hint(Gdk.WindowTypeHint.DIALOG); dialog.set_default_response(Gtk.ResponseType.OK); // Load editable widgets - password_entry = (Gtk.Entry)builder.get_object("password_entry"); - remember_password_checkbutton = (Gtk.CheckButton)builder.get_object("remember_password_checkbutton"); + password_entry = (Gtk.Entry) builder.get_object("password_entry"); + remember_password_checkbutton = (Gtk.CheckButton) builder.get_object("remember_password_checkbutton"); // Load non-editable widgets - Gtk.Label email_label = (Gtk.Label)builder.get_object("email_label"); - Gtk.Label real_name_label = (Gtk.Label)builder.get_object("real_name_label"); - Gtk.Label service_label = (Gtk.Label)builder.get_object("service_label"); - Gtk.Label imap_server_label = (Gtk.Label)builder.get_object("imap_server_label"); - Gtk.Label imap_port_label = (Gtk.Label)builder.get_object("imap_port_label"); - Gtk.Label imap_encryption_label = (Gtk.Label)builder.get_object("imap_encryption_label"); - Gtk.Label smtp_server_label = (Gtk.Label)builder.get_object("smtp_server_label"); - Gtk.Label smtp_port_label = (Gtk.Label)builder.get_object("smtp_port_label"); - Gtk.Label smtp_encryption_label = (Gtk.Label)builder.get_object("smtp_encryption_label"); + Gtk.Label email_label = (Gtk.Label) builder.get_object("email_label"); + Gtk.Label real_name_label = (Gtk.Label) builder.get_object("real_name_label"); + Gtk.Label service_label = (Gtk.Label) builder.get_object("service_label"); + Gtk.Label imap_server_label = (Gtk.Label) builder.get_object("imap_server_label"); + Gtk.Label imap_port_label = (Gtk.Label) builder.get_object("imap_port_label"); + Gtk.Label imap_encryption_label = (Gtk.Label) builder.get_object("imap_encryption_label"); + Gtk.Label smtp_server_label = (Gtk.Label) builder.get_object("smtp_server_label"); + Gtk.Label smtp_port_label = (Gtk.Label) builder.get_object("smtp_port_label"); + Gtk.Label smtp_encryption_label = (Gtk.Label) builder.get_object("smtp_encryption_label"); + + // Load translated text for labels with markup unsupported by glade. + Gtk.Label primary_text_label = (Gtk.Label) builder.get_object("primary_text_label"); + primary_text_label.set_markup(get_primary_text_markup(first_try)); // Find server configuration information Geary.Endpoint imap_endpoint; @@ -71,14 +82,6 @@ public class PasswordDialog { smtp_port_label.set_text(smtp_server_port.to_string()); smtp_encryption_label.set_text(smtp_server_ssl ? "on" : "off"); - // Set primary text - Gtk.Label primary_text_label = (Gtk.Label)builder.get_object("primary_text_label"); - const string primary_markup_format = """%s"""; - string primary_markup_text = first_try ? _("Please enter your email password") : - _("Unable to login to email server"); - primary_text_label.set_markup(primary_markup_format.printf(primary_markup_text)); - primary_text_label.use_markup = true; - // Add action buttons Gtk.Button cancel_button = new Gtk.Button.from_stock(Gtk.Stock.CANCEL); ok_button = new Gtk.Button.from_stock(Gtk.Stock.OK); @@ -92,9 +95,12 @@ public class PasswordDialog { password_entry.changed.connect(refresh_ok_button_sensitivity); } + private string get_primary_text_markup(bool first_try) { + return PRIMARY_TEXT_MARKUP.printf(first_try ? PRIMARY_TEXT_FIRST_TRY : PRIMARY_TEXT_REPEATED_TRY); + } + private void refresh_ok_button_sensitivity() { ok_button.sensitive = !Geary.String.is_null_or_whitespace(password_entry.get_text()); - } public bool run() { diff --git a/src/common/common-international.vala b/src/common/common-international.vala new file mode 100644 index 00000000..24ed7c95 --- /dev/null +++ b/src/common/common-international.vala @@ -0,0 +1,29 @@ +/* Copyright 2009-2012 Yorba Foundation + * + * This software is licensed under the GNU Lesser General Public License + * (version 2.1 or later). See the COPYING file in this distribution. + */ + +extern const string LANGUAGE_SUPPORT_DIRECTORY; +public const string TRANSLATABLE = "translatable"; + +namespace International { +const string SYSTEM_LOCALE = ""; + +void init(string package_name, string program_path, string locale = SYSTEM_LOCALE) { + Intl.setlocale(LocaleCategory.ALL, locale); + Intl.bindtextdomain(package_name, get_langpack_dir_path(program_path)); + Intl.bind_textdomain_codeset(package_name, "UTF-8"); + Intl.textdomain(package_name); +} + +private string get_langpack_dir_path(string program_path) { + File local_langpack_dir = + File.new_for_path(Environment.find_program_in_path(program_path)).get_parent().get_child( + "locale-langpack"); + + return (local_langpack_dir.query_exists(null)) ? local_langpack_dir.get_path() : + LANGUAGE_SUPPORT_DIRECTORY; +} +} + diff --git a/src/common/common-intl.vala b/src/common/common-intl.vala deleted file mode 100644 index 12497a02..00000000 --- a/src/common/common-intl.vala +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2011-2012 Yorba Foundation - * - * This software is licensed under the GNU Lesser General Public License - * (version 2.1 or later). See the COPYING file in this distribution. - */ - -// TODO: This fakes internationalization support until fully integrated. -public unowned string _(string text) { - return text; -} - -public unowned string C_(string context, string text) { - return text; -} - -public unowned string ngettext (string msgid, string msgid_plural, ulong n) { - return n > 1 ? msgid_plural : msgid; -} - -public const string TRANSLATABLE = "TRANSLATABLE"; - -namespace Intl { -} - diff --git a/src/common/common-yorba-application.vala b/src/common/common-yorba-application.vala index 0e82e623..b935cb15 100644 --- a/src/common/common-yorba-application.vala +++ b/src/common/common-yorba-application.vala @@ -14,6 +14,8 @@ * http://redmine.yorba.org/issues/4266 */ +extern const string GETTEXT_PACKAGE; + public abstract class YorbaApplication { public bool registered { get; private set; } @@ -119,6 +121,7 @@ public abstract class YorbaApplication { error("run() called twice."); this.args = args; + International.init(GETTEXT_PACKAGE, args[0]); running = true; exitcode = startup(); diff --git a/ui/password-dialog.glade b/ui/password-dialog.glade index 5bba0336..748e72c5 100644 --- a/ui/password-dialog.glade +++ b/ui/password-dialog.glade @@ -45,7 +45,7 @@ False 2.2351741291171123e-10 0 - <span weight="bold"size="larger">Please enter your email password</span> + (set in password-dialog.vala) True @@ -222,13 +222,15 @@ - + True False 0 6 - <span weight="bold">General</span> - True + General + + + 0 @@ -238,14 +240,16 @@ - + True False 6 0 6 - <span weight="bold">IMAP settings</span> - True + IMAP settings + + + 0 @@ -342,14 +346,16 @@ - + True False 6 0 6 - <span weight="bold">SMTP settings</span> - True + SMTP settings + + + 0 diff --git a/ui/toolbar.glade b/ui/toolbar.glade index 7d437151..90d35d0c 100644 --- a/ui/toolbar.glade +++ b/ui/toolbar.glade @@ -99,7 +99,7 @@ False True False - Move the selected conversation + Move the selected conversation False False folder @@ -114,7 +114,7 @@ False True False - Label the selected conversation + Label the selected conversation False False multiple-tags @@ -140,7 +140,7 @@ False True False - Mark email + Mark email False Mark False