1
/* vim: set expandtab ts=8 sw=4: */
3
/* This program is free software; you can redistribute it and/or modify
4
* it under the terms of the GNU General Public as published by
5
* the Free Software Foundation; either version 2 of the , or
6
* (at your option) any later version.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU Library General Public for more details.
13
* You should have received a copy of the GNU General Public
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28
#include "translate.h"
31
static const gchar *desc_strings[] = {
33
N_("Becoming Cloudy"),
35
N_("Blizzard Conditions"),
38
N_("Chance of Rain/Snow"),
39
N_("Chance of Showers"),
41
N_("Chance of Snow/Rain"),
42
N_("Chance of T-Storm"),
49
N_("Cumulonimbus Clouds Observed"),
56
N_("Freezing Drizzle"),
58
N_("Freezing Rain/Snow"),
65
N_("Ice/Snow Mixture"),
66
N_("Increasing Clouds"),
67
N_("Isolated Showers"),
70
N_("Lightning Observed"),
71
N_("mild and breezy"),
77
N_("Occasional Sunshine"),
79
N_("Partial Clearing"),
80
N_("Partial Sunshine"),
88
N_("Rain / Snow Showers"),
100
N_("Variable Cloudiness"),
101
N_("Variable Clouds"),
104
N_("Showers in the Vicinity"),
105
N_("Light Rain Shower"),
108
N_("Light Rain / Wind"),
109
N_("Scattered Showers"),
113
N_("Partly Cloudy and Windy"),
116
N_("Clouds Early / Clearing Late"),
117
N_("Mostly Cloudy and Windy"),
119
N_("Rain and Sleet"),
120
N_("Snow Showers Late"),
121
N_("Light Drizzle and Windy"),
123
N_("Snow Showers Early"),
124
N_("Few Snow Showers"),
128
static const gchar *bard_strings[] = {
135
static const gchar *risk_strings[] = {
144
static const gchar *wdirs[] = {
165
translate_str(const gchar **loc_strings,
168
gint loc_string_len, str_len;
174
str_len = strlen(str);
179
for (i = 0; loc_strings[i] != NULL; i++)
181
loc_string_len = strlen(loc_strings[i]);
183
if (str_len != loc_string_len)
186
if (str[0] != loc_strings[i][0])
189
if (!g_ascii_strncasecmp(loc_strings[i], str, str_len))
190
return _(loc_strings[i]);
197
translate_bard (const gchar *bard)
199
return translate_str(bard_strings, bard);
203
translate_risk (const gchar *risk)
205
return translate_str(risk_strings, risk);
209
translate_desc (const gchar *desc)
211
return translate_str(desc_strings, desc);
214
/* used by translate_lsup and translate_time */
216
_fill_time(struct tm *time,
221
time->tm_hour = atoi(hour);
223
if (am[0] == 'P' && time->tm_hour != 12) /* PM or AM */
226
time->tm_min = atoi(minute);
233
#define HDATE_N sizeof(gchar) * 100
235
translate_lsup (const gchar *lsup)
239
gint size = 0, i = 0;
244
if (lsup == NULL || strlen(lsup) == 0)
247
/* 10/17/04 5:55 PM Local Time */
248
if ((lsup_split = g_strsplit_set(lsup, " /:", 8)) == NULL)
251
while(lsup_split[i++])
256
g_strfreev(lsup_split);
260
time.tm_mon = atoi(lsup_split[0]) - 1;
261
time.tm_mday = atoi(lsup_split[1]);
262
time.tm_year = atoi(lsup_split[2]) + 100;
264
_fill_time(&time, lsup_split[3], lsup_split[4], lsup_split[5]);
266
g_strfreev(lsup_split);
268
if (mktime(&time) != -1)
270
hdate = g_malloc(HDATE_N);
272
strftime(hdate, HDATE_N, _("%x at %X Local Time"), &time);
280
#define DAY_LOC_N sizeof(gchar) * 20
282
translate_day (const gchar *day)
286
const gchar *days[] = {
287
"su", "mo", "tu", "we", "th", "fr", "sa", NULL
291
if (day == NULL || strlen(day) < 2)
294
for (i = 0; days[i] != NULL; i++)
295
if (!g_ascii_strncasecmp(day, days[i], 2))
306
day_loc = g_malloc(DAY_LOC_N);
308
strftime(day_loc, DAY_LOC_N, "%A", &time);
316
translate_wind_direction (const gchar *wdir)
322
if (wdir == NULL || (wdir_len = strlen(wdir)) < 1)
325
if (strchr(wdir, '/')) /* N/A */
329
* If the direction code can be translated, then translated the
330
* whole code so that it can be correctly translated in CJK (and
331
* possibly Finnish). If not, use the old behaviour where
332
* individual direction codes are successively translated.
334
if (g_ascii_strcasecmp(wdir, _(wdir)) != 0)
335
wdir_loc = g_strdup(_(wdir));
338
wdir_loc = g_strdup("");
339
for (i = 0; i < strlen(wdir); i++)
347
tmp = g_strdup_printf("%s%s", wdir_loc,
348
translate_str(wdirs, wdir_i));
358
/* calm or a number */
360
translate_wind_speed (const gchar *wspeed,
365
if (g_ascii_strcasecmp(wspeed, "calm") == 0)
366
wspeed_loc = g_strdup(_("calm"));
367
else if (g_ascii_strcasecmp(wspeed, "N/A") == 0)
368
wspeed_loc = g_strdup(_("N/A"));
370
wspeed_loc = g_strdup_printf("%s %s", wspeed, get_unit(unit, WIND_SPEED));
376
#define TIME_LOC_N sizeof(gchar) * 20
378
translate_time (const gchar *time)
380
gchar **time_split, *time_loc;
384
if (strlen(time) == 0)
387
time_split = g_strsplit_set(time, ": ", 3);
389
while(time_split[i++])
395
time_loc = g_malloc(TIME_LOC_N);
397
_fill_time(&time_tm, time_split[0], time_split[1], time_split[2]);
398
g_strfreev(time_split);
400
strftime(time_loc, TIME_LOC_N, "%X", &time_tm);
405
/* Unlimited or a number */
407
translate_visibility (const gchar *vis,
412
if (g_ascii_strcasecmp(vis, "Unlimited") == 0)
413
vis_loc = g_strdup(_("Unlimited"));
415
vis_loc = g_strdup_printf("%s %s", vis, get_unit(unit, VIS));