Commit 189766a6 authored by Bastien Nocera's avatar Bastien Nocera

datetime: Translate timezone names

Both Cities and Regions need to be translated. Also make sure that
we sort them properly, and use symbolic names for COLUMNS in the
region liststore.

https://bugzilla.gnome.org/show_bug.cgi?id=630264
parent a635c0b6
......@@ -327,6 +327,7 @@ panels/background/Makefile
panels/background/gnome-background-panel.desktop.in
panels/datetime/Makefile
panels/datetime/gnome-datetime-panel.desktop.in
panels/datetime/po-timezones/Makefile
panels/default-applications/Makefile
panels/default-applications/gnome-at-commandline.in
panels/default-applications/gnome-at-session.desktop.in
......
# This is used in GNOMECC_CAPPLETS_CFLAGS
cappletname = datetime
SUBDIRS = po-timezones
icons16dir = $(datadir)/icons/hicolor/16x16/apps
dist_icons16_DATA = icons/16x16/preferences-system-time.png
icons22dir = $(datadir)/icons/hicolor/22x22/apps
......@@ -60,7 +62,7 @@ dist_ui_DATA = \
data/timezone_9.5.png
INCLUDES = \
INCLUDES = \
$(PANEL_CFLAGS) \
$(GNOMECC_CAPPLETS_CFLAGS) \
$(DBUS_CFLAGS) \
......@@ -84,7 +86,7 @@ check: test-timezone
ccpanelsdir = $(PANELS_DIR)
ccpanels_LTLIBRARIES = libdate_time.la
libdate_time_la_SOURCES = \
libdate_time_la_SOURCES = \
datetime-module.c \
cc-datetime-panel.c \
cc-datetime-panel.h \
......
......@@ -26,6 +26,9 @@
#include <gsettings-desktop-schemas/gdesktop-enums.h>
#include <string.h>
#include <stdlib.h>
#include <libintl.h>
#define GETTEXT_PACKAGE_TIMEZONES GETTEXT_PACKAGE "-timezones"
G_DEFINE_DYNAMIC_TYPE (CcDateTimePanel, cc_date_time_panel, CC_TYPE_PANEL)
......@@ -35,10 +38,18 @@ G_DEFINE_DYNAMIC_TYPE (CcDateTimePanel, cc_date_time_panel, CC_TYPE_PANEL)
enum {
CITY_COL_CITY,
CITY_COL_REGION,
CITY_COL_CITY_TRANSLATED,
CITY_COL_REGION_TRANSLATED,
CITY_COL_ZONE,
CITY_NUM_COLS
};
enum {
REGION_COL_REGION,
REGION_COL_REGION_TRANSLATED,
REGION_NUM_COLS
};
#define W(x) (GtkWidget*) gtk_builder_get_object (priv->builder, x)
#define CLOCK_SCHEMA "org.gnome.desktop.interface"
......@@ -220,7 +231,7 @@ update_time (CcDateTimePanel *self)
for (i = 0; i < G_N_ELEMENTS (am_pm_widgets); i++)
gtk_widget_set_visible (W(am_pm_widgets[i]),
priv->clock_format == G_DESKTOP_CLOCK_FORMAT_12H);
priv->clock_format == G_DESKTOP_CLOCK_FORMAT_12H);
/* Update the minutes label */
label = g_date_time_format (priv->date, "%M");
......@@ -266,9 +277,9 @@ apply_button_clicked_cb (GtkButton *button,
d = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (W ("day-spinbutton")));
priv->date = g_date_time_new_local (y, mon, d,
g_date_time_get_hour (old_date),
g_date_time_get_minute (old_date),
g_date_time_get_second (old_date));
g_date_time_get_hour (old_date),
g_date_time_get_minute (old_date),
g_date_time_get_second (old_date));
g_date_time_unref (old_date);
unixtime = g_date_time_to_unix (priv->date);
......@@ -317,7 +328,7 @@ location_changed_cb (CcTimezoneMap *map,
{
gchar *string;
gtk_tree_model_get (model, &iter, 0, &string, -1);
gtk_tree_model_get (model, &iter, CITY_COL_CITY, &string, -1);
if (!g_strcmp0 (string, split[0]))
{
......@@ -340,7 +351,7 @@ location_changed_cb (CcTimezoneMap *map,
{
gchar *string;
gtk_tree_model_get (model, &iter, 0, &string, -1);
gtk_tree_model_get (model, &iter, CITY_COL_CITY, &string, -1);
if (!g_strcmp0 (string, split[1]))
{
......@@ -374,32 +385,53 @@ struct get_region_data
GHashTable *table;
};
/* Slash look-alikes that might be used in translations */
#define TRANSLATION_SPLIT \
"\x20\x44" /* FRACTION SLASH */ \
"\x22\x15" /* DIVISION SLASH */ \
"\x29\xF8" /* BIG SOLIDUS */ \
"\xFF\x0F" /* FULLWIDTH SOLIDUS */ \
"/"
static void
get_regions (TzLocation *loc,
struct get_region_data *data)
{
gchar **split;
gchar **split_translated;
split = g_strsplit (loc->zone, "/", 2);
/* remove underscores */
g_strdelimit (split[1], "_", ' ');
/* Load the translation for it */
split_translated = g_strsplit_set (dgettext (GETTEXT_PACKAGE_TIMEZONES, loc->zone),
TRANSLATION_SPLIT, 2);
/* remove underscores */
g_strdelimit (split_translated[1], "_", ' ');
if (!g_hash_table_lookup_extended (data->table, split[0], NULL, NULL))
{
g_hash_table_insert (data->table, g_strdup (split[0]),
GINT_TO_POINTER (1));
gtk_list_store_insert_with_values (data->region_store, NULL, 0, 0,
split[0], -1);
gtk_list_store_insert_with_values (data->region_store, NULL, 0,
REGION_COL_REGION, split[0],
REGION_COL_REGION_TRANSLATED, split_translated[0], -1);
}
gtk_list_store_insert_with_values (data->city_store, NULL, 0,
CITY_COL_CITY, split[1],
CITY_COL_CITY_TRANSLATED, split_translated[1],
CITY_COL_REGION, split[0],
CITY_COL_REGION_TRANSLATED, split_translated[0],
CITY_COL_ZONE, loc->zone,
-1);
g_strfreev (split);
g_strfreev (split_translated);
}
static gboolean
......@@ -457,7 +489,8 @@ load_regions_model (GtkListStore *regions, GtkListStore *cities)
tz_db_free (db);
/* sort the models */
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (regions), 0,
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (regions),
REGION_COL_REGION_TRANSLATED,
GTK_SORT_ASCENDING);
}
......@@ -497,7 +530,7 @@ city_changed_cb (GtkComboBox *box,
static void
month_year_changed (GtkWidget *widget,
CcDateTimePanel *panel)
CcDateTimePanel *panel)
{
CcDateTimePanelPrivate *priv = panel->priv;
guint mon, y;
......@@ -566,7 +599,7 @@ cc_date_time_panel_init (CcDateTimePanel *self)
gchar *objects[] = { "datetime-panel", "region-liststore", "city-liststore",
"month-liststore", "city-modelfilter", "city-modelsort", NULL };
char *buttons[] = { "hour_up_button", "hour_down_button", "min_up_button",
"min_down_button", "ampm_up_button", "ampm_down_button" };
"min_down_button", "ampm_up_button", "ampm_down_button" };
GtkWidget *widget;
GtkAdjustment *adjustment;
GError *err = NULL;
......@@ -594,7 +627,7 @@ cc_date_time_panel_init (CcDateTimePanel *self)
for (i = 0; i < G_N_ELEMENTS (buttons); i++)
{
g_signal_connect (W(buttons[i]), "clicked", G_CALLBACK (change_time),
self);
self);
}
/* set up date editing widgets */
......@@ -603,10 +636,10 @@ cc_date_time_panel_init (CcDateTimePanel *self)
gtk_combo_box_set_active (GTK_COMBO_BOX (W ("month-combobox")),
g_date_time_get_month (priv->date) - 1);
g_signal_connect (G_OBJECT (W("month-combobox")), "changed",
G_CALLBACK (month_year_changed), self);
G_CALLBACK (month_year_changed), self);
num_days = g_date_get_days_in_month (g_date_time_get_month (priv->date),
g_date_time_get_year (priv->date));
g_date_time_get_year (priv->date));
adjustment = (GtkAdjustment*) gtk_adjustment_new (g_date_time_get_day_of_month (priv->date), 1,
num_days + 1, 1, 10, 1);
gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON (W ("day-spinbutton")),
......@@ -618,7 +651,7 @@ cc_date_time_panel_init (CcDateTimePanel *self)
gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON (W ("year-spinbutton")),
adjustment);
g_signal_connect (G_OBJECT (W("year-spinbutton")), "value-changed",
G_CALLBACK (month_year_changed), self);
G_CALLBACK (month_year_changed), self);
/* set up timezone map */
priv->map = widget = (GtkWidget *) cc_timezone_map_new ();
......@@ -671,7 +704,7 @@ cc_date_time_panel_init (CcDateTimePanel *self)
city_modelfilter);
city_modelsort = GTK_TREE_MODEL_SORT (gtk_builder_get_object (priv->builder, "city-modelsort"));
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (city_modelsort), 0,
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (city_modelsort), CITY_COL_CITY_TRANSLATED,
GTK_SORT_ASCENDING);
gtk_tree_model_filter_set_visible_func (city_modelfilter,
......
......@@ -25,12 +25,17 @@
#include <glib/gi18n-lib.h>
#define GETTEXT_PACKAGE_TIMEZONES GETTEXT_PACKAGE "-timezones"
void
g_io_module_load (GIOModule *module)
{
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
bindtextdomain (GETTEXT_PACKAGE_TIMEZONES, GNOMELOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE_TIMEZONES, "UTF-8");
/* register the panel */
cc_date_time_panel_register (module);
}
......
......@@ -59,7 +59,7 @@
<child>
<object class="GtkCellRendererText" id="cellrenderertext1"/>
<attributes>
<attribute name="text">0</attribute>
<attribute name="text">1</attribute>
</attributes>
</child>
</object>
......@@ -81,11 +81,11 @@
<child>
<object class="GtkComboBox" id="city_combobox">
<property name="visible">True</property>
<property name="model">city-modelfilter</property>
<property name="model">city-modelsort</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext2"/>
<attributes>
<attribute name="text">0</attribute>
<attribute name="text">2</attribute>
</attributes>
</child>
</object>
......@@ -438,6 +438,8 @@
<columns>
<!-- column-name region -->
<column type="gchararray"/>
<!-- column-name region-translated -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkListStore" id="city-liststore">
......@@ -446,6 +448,10 @@
<column type="gchararray"/>
<!-- column-name region -->
<column type="gchararray"/>
<!-- column-name city-translated -->
<column type="gchararray"/>
<!-- column-name region-translated -->
<column type="gchararray"/>
<!-- column-name zone -->
<column type="gchararray"/>
</columns>
......
CATALOGS = $(patsubst %.po,%.mo,$(wildcard *.po))
all: $(CATALOGS)
NLSPACKAGE = $(GETTEXT_PACKAGE)-timezones
%.mo: %.po
$(AM_V_GEN) msgfmt -o $@ $<
install: $(CATALOGS)
@mkdir -p $(DESTDIR)$(localedir)
for n in $(CATALOGS); do \
l=`basename $$n .mo`; \
$(INSTALL) -m 755 -d $(DESTDIR)$(localedir)/$$l; \
$(INSTALL) -m 755 -d $(DESTDIR)$(localedir)/$$l/LC_MESSAGES; \
if [ -f $$n ]; then \
$(INSTALL) -m 644 $$n $(DESTDIR)$(localedir)/$$l/LC_MESSAGES/$(NLSPACKAGE).mo; \
fi; \
done
EXTRA_DIST=$(wildcard *.po)
CLEANFILES = $(CATALOGS)
-include $(top_srcdir)/git.mk
Those translations are copied from system-config-date
http://git.fedorahosted.org/git/?p=system-config-date.git;a=tree;f=po/timezones
and should not be modified by the GNOME translation teams.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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