~ubuntu-branches/ubuntu/trusty/libgweather/trusty-updates

« back to all changes in this revision

Viewing changes to libgweather/gweather-timezone.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-05-27 11:58:15 UTC
  • mfrom: (13.1.4 experimental)
  • Revision ID: package-import@ubuntu.com-20130527115815-l51yffuy20gbv9q0
Tags: 3.8.0-1ubuntu1
* Sync with Debian (LP: #1184168). Remaining changes: 
  - debian/control.in, debian/rules:
    + Run autoreconf
  - debian/rules:
    + Generate POT files on build
  - debian/patches/01_gettext_not_xml.patch: 
    + using gettext rather than add translations to the xml databases
  - debian/patches/02_no_external_gettext.patch:
    + Can't have both IT_PROG_INTLTOOL and AM_GNU_GETTEXT

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#endif
24
24
 
25
25
#include <string.h>
 
26
#include <libintl.h>
26
27
 
27
28
#define GWEATHER_I_KNOW_THIS_IS_UNSTABLE
28
29
#include "gweather-timezone.h"
30
31
#include "weather-priv.h"
31
32
 
32
33
/**
33
 
 * GWeatherTimezone:
 
34
 * SECTION:gweathertimezone
 
35
 * @Title: GWeatherTimezone
34
36
 *
35
37
 * A timezone.
36
38
 *
38
40
 * be created by calling gweather_location_new_world() to parse
39
41
 * Locations.xml, and then calling various #GWeatherLocation methods
40
42
 * to extract relevant timezones from the location hierarchy.
41
 
 **/
 
43
 */
 
44
 
42
45
struct _GWeatherTimezone {
43
46
    char *id, *name;
44
47
    int offset, dst_offset;
152
155
parse_timezone (GWeatherParser *parser)
153
156
{
154
157
    GWeatherTimezone *zone = NULL;
155
 
    char *id = NULL, *name = NULL;
 
158
    char *id = NULL, *name = NULL, *context = NULL;
156
159
    int offset = 0, dst_offset = 0;
157
160
    gboolean has_dst = FALSE;
158
161
 
175
178
                continue;
176
179
            }
177
180
 
178
 
            if (!strcmp ((const char *) xmlTextReaderConstName (parser->xml), "name"))
179
 
                name = gweather_parser_get_localized_value (parser);
 
181
            if (!strcmp ((const char *) xmlTextReaderConstName (parser->xml), "name")) {
 
182
                context = xmlTextReaderGetAttribute(parser->xml,"msgctxt"); 
 
183
                name = gweather_parser_get_value (parser);
 
184
            }
180
185
            else {
181
186
                if (xmlTextReaderNext (parser->xml) != 1)
182
187
                    break;
183
188
            }
184
189
        }
185
190
    }
186
 
 
 
191
            
187
192
    if (parse_tzdata (id, parser->year_start, parser->year_end,
188
193
                      &offset, &has_dst, &dst_offset)) {
189
194
        zone = g_slice_new0 (GWeatherTimezone);
190
195
        zone->ref_count = 1;
191
196
        zone->id = g_strdup (id);
192
 
        zone->name = g_strdup (name);
 
197
        if (context != NULL)
 
198
                zone->name = g_strdup (g_dpgettext2(GETTEXT_PACKAGE "-locations", context, name));
 
199
        else
 
200
                zone->name = g_strdup (dgettext(GETTEXT_PACKAGE "-locations",name));
193
201
        zone->offset = offset;
194
202
        zone->has_dst = has_dst;
195
203
        zone->dst_offset = dst_offset;
196
204
    }
197
205
 
198
206
    xmlFree (id);
 
207
    if (context)
 
208
        xmlFree (context);
199
209
    if (name)
200
210
        xmlFree (name);
201
211
 
359
369
 * @zone: a #GWeatherTimezone
360
370
 *
361
371
 * Gets @zone's standard offset from UTC, in minutes. Eg, a value of
362
 
 * %120 would indicate "GMT+2".
 
372
 * 120 would indicate "GMT+2".
363
373
 *
364
374
 * Return value: @zone's standard offset, in minutes
365
375
 **/
390
400
 * @zone: a #GWeatherTimezone
391
401
 *
392
402
 * Gets @zone's daylight/summer time offset from UTC, in minutes. Eg,
393
 
 * a value of %120 would indicate "GMT+2". This is only meaningful if
 
403
 * a value of 120 would indicate "GMT+2". This is only meaningful if
394
404
 * gweather_timezone_has_dst() returns %TRUE.
395
405
 *
396
406
 * Return value: @zone's daylight/summer time offset, in minutes