diff options
author | Matt Wilson <msw@redhat.com> | 2000-08-15 16:48:22 +0000 |
---|---|---|
committer | Matt Wilson <msw@redhat.com> | 2000-08-15 16:48:22 +0000 |
commit | c67fd65dbc961483d4b15111221b670fcac0ac25 (patch) | |
tree | 58a0f5abace5b421dd7ea18cd587abf0a28374bb | |
parent | 662b220be6f5270a524963b0bf66f0e3fdff045e (diff) | |
download | anaconda-c67fd65dbc961483d4b15111221b670fcac0ac25.tar.gz anaconda-c67fd65dbc961483d4b15111221b670fcac0ac25.tar.xz anaconda-c67fd65dbc961483d4b15111221b670fcac0ac25.zip |
internationalize, create a method to get the real zone name from a translated name
-rw-r--r-- | gnome-map/timezonemapmodule.c | 29 | ||||
-rw-r--r-- | gnome-map/timezones.c | 6 |
2 files changed, 24 insertions, 11 deletions
diff --git a/gnome-map/timezonemapmodule.c b/gnome-map/timezonemapmodule.c index e0c491a0d..1e6d9de91 100644 --- a/gnome-map/timezonemapmodule.c +++ b/gnome-map/timezonemapmodule.c @@ -92,7 +92,7 @@ find_location (GPtrArray *Locations, gchar *locname) for (i=0; i < Locations->len; i++) { loc = g_ptr_array_index (Locations, i); - if (!strcmp (loc->zone, locname)) + if (!strcmp (_(loc->zone), locname)) return i; } @@ -344,15 +344,15 @@ set_hilited (MapData *mapdata, gint index, double item_x, double item_y) /* keep status bar from flickering */ gtk_label_get (GTK_LABEL (GTK_STATUSBAR (mapdata->statusbar)->label), &status_text); - if (strncmp (status_text, loc->zone, strlen (loc->zone)) != 0) + if (strncmp (status_text, _(loc->zone), strlen (loc->zone)) != 0) { char *newstr; char *sep = " - "; gtk_statusbar_pop (GTK_STATUSBAR (mapdata->statusbar), 1); - newstr = (char *) malloc (strlen (loc->zone) + strlen (sep) + + newstr = (char *) malloc (strlen (_(loc->zone)) + strlen (sep) + ((loc->comment) ? strlen (loc->comment) : 0) + 1); - strcpy (newstr, loc->zone); + strcpy (newstr, _(loc->zone)); if (loc->comment) { strcat (newstr, sep); @@ -658,7 +658,7 @@ create_location_list (MapData *mapdata) if (!gnome_map_is_loc_in_view (WorldMap, loc->longitude, loc->latitude)) continue; - row[0] = loc->zone; + row[0] = _(loc->zone); row[1] = loc->comment; newrow = gtk_clist_append (GTK_CLIST (mapdata->locationlist), row); gtk_clist_set_row_data (GTK_CLIST (mapdata->locationlist), newrow, @@ -763,8 +763,9 @@ main (int argc, char **argv) gtk_widget_show_all (mainwindow); /* pick New York City as default */ + printf ("%s\n", _("America/New_York")); set_selection (mapdata, - find_location (mapdata->Locations, "America/New_York"), + find_location (mapdata->Locations, _("America/New_York")), TRUE); gtk_main (); @@ -780,9 +781,11 @@ typedef struct tzObject_t { } tzObject; static PyObject * setcurrent (tzObject * o, PyObject * args); +static PyObject * getzone (tzObject * o, PyObject * args); static PyMethodDef tzObjectMethods[] = { { "setcurrent", (PyCFunction) setcurrent, METH_VARARGS, NULL }, + { "getzone", (PyCFunction) getzone, METH_VARARGS, NULL }, { NULL } }; @@ -826,7 +829,21 @@ static PyObject * setcurrent (tzObject * o, PyObject * args) { return Py_BuildValue("i", index); } +static PyObject * getzone (tzObject * o, PyObject * args) { + char * loc; + TimeZoneLocation *zone; + int index; + + if (!PyArg_ParseTuple(args, "s", &loc)) + return NULL; + index = find_location (o->mapdata->Locations, loc); + if (index == -1) + return NULL; + + zone = g_ptr_array_index (o->mapdata->Locations, index); + return Py_BuildValue("s", zone->zone); +} static PyObject * tzGetAttr(tzObject * o, char * name) { if (!strncmp (name, "map", 3)) { diff --git a/gnome-map/timezones.c b/gnome-map/timezones.c index 7b504ce52..299a2b7ff 100644 --- a/gnome-map/timezones.c +++ b/gnome-map/timezones.c @@ -10,12 +10,8 @@ #include <time.h> #include <math.h> #include <string.h> -#include <libintl.h> - #include "timezones.h" -#define _(string) gettext(string) - TZZoneInfo * tzinfo_get_for_location (TimeZoneLocation *loc) { @@ -159,7 +155,7 @@ loadTZDB( void ) #endif loc = g_new( TimeZoneLocation, 1); loc->country = g_strdup(tmpstrarr[0]); - loc->zone = g_strdup(_(tmpstrarr[2])); + loc->zone = g_strdup(tmpstrarr[2]); loc->comment = (tmpstrarr[3]) ? g_strdup(tmpstrarr[3]) : NULL; loc->latitude = convertPos(latstr,2); loc->longitude = convertPos(lngstr,3); |