Commit 877a2168 authored by Matthew Pirocchi's avatar Matthew Pirocchi

Add support for different languages: Closes #3823.

parent 847514f8
......@@ -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})
......
......@@ -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
)
......
......@@ -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;
......
......@@ -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";
......
......@@ -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";
......
......@@ -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 = "<span weight=\"bold\" size=\"larger\">%s</span>";
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 = """<span weight="bold" size="larger">%s</span>""";
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() {
......
/* 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;
}
}
/* 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 {
}
......@@ -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();
......
......@@ -45,7 +45,7 @@
<property name="can_focus">False</property>
<property name="xalign">2.2351741291171123e-10</property>
<property name="yalign">0</property>
<property name="label" translatable="yes">&lt;span weight="bold"size="larger"&gt;Please enter your email password&lt;/span&gt;</property>
<property name="label">(set in password-dialog.vala)</property>
<property name="use_markup">True</property>
</object>
<packing>
......@@ -222,13 +222,15 @@
</packing>
</child>
<child>
<object class="GtkLabel" id="label1">
<object class="GtkLabel" id="general_category_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="ypad">6</property>
<property name="label" translatable="yes">&lt;span weight="bold"&gt;General&lt;/span&gt;</property>
<property name="use_markup">True</property>
<property name="label">General</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
<packing>
<property name="left_attach">0</property>
......@@ -238,14 +240,16 @@
</packing>
</child>
<child>
<object class="GtkLabel" id="label7">
<object class="GtkLabel" id="imap_settings_category_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">6</property>
<property name="xalign">0</property>
<property name="ypad">6</property>
<property name="label" translatable="yes">&lt;span weight="bold"&gt;IMAP settings&lt;/span&gt;</property>
<property name="use_markup">True</property>
<property name="label" translatable="yes">IMAP settings</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
<packing>
<property name="left_attach">0</property>
......@@ -342,14 +346,16 @@
</packing>
</child>
<child>
<object class="GtkLabel" id="label11">
<object class="GtkLabel" id="smtp_settings_category_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">6</property>
<property name="xalign">0</property>
<property name="ypad">6</property>
<property name="label" translatable="yes">&lt;span weight="bold"&gt;SMTP settings&lt;/span&gt;</property>
<property name="use_markup">True</property>
<property name="label" translatable="yes">SMTP settings</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
<packing>
<property name="left_attach">0</property>
......
......@@ -99,7 +99,7 @@
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes" context="Toggles menu for applying labels to emails.">Move the selected conversation</property>
<property name="tooltip_text" translatable="yes" comments="Toggles menu for applying labels to emails.">Move the selected conversation</property>
<property name="use_action_appearance">False</property>
<property name="use_underline">False</property>
<property name="icon_name">folder</property>
......@@ -114,7 +114,7 @@
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes" context="Toggles menu for applying labels to emails.">Label the selected conversation</property>
<property name="tooltip_text" translatable="yes" comments="Toggles menu for applying labels to emails.">Label the selected conversation</property>
<property name="use_action_appearance">False</property>
<property name="use_underline">False</property>
<property name="icon_name">multiple-tags</property>
......@@ -140,7 +140,7 @@
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes" context="Toggles menu for marking a message as read/unread or starred/unstarred">Mark email</property>
<property name="tooltip_text" translatable="yes" comments="Toggles menu for marking a message as read/unread or starred/unstarred">Mark email</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Mark</property>
<property name="use_underline">False</property>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment