forked from hebcal/hebcal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
translations.c
113 lines (107 loc) · 3.65 KB
/
translations.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
* DO NOT EDIT THIS FILE!
* Generated by ./po2gperf.pl
*/
#include "translations.h"
#include <string.h>
const char *hebcal_langs[] = {
"ashkenazi",
"ashkenazi_litvish",
"ashkenazi_poylish",
"ashkenazi_standard",
"fi",
"fr",
"he",
"hu",
"pl",
"ru",
NULL
};
struct event_title * hebcal_lookup_ashkenazi(const char *str, unsigned int len);
struct event_title * hebcal_lookup_ashkenazi_litvish(const char *str, unsigned int len);
struct event_title * hebcal_lookup_ashkenazi_poylish(const char *str, unsigned int len);
struct event_title * hebcal_lookup_ashkenazi_standard(const char *str, unsigned int len);
struct event_title * hebcal_lookup_fi(const char *str, unsigned int len);
struct event_title * hebcal_lookup_fr(const char *str, unsigned int len);
struct event_title * hebcal_lookup_he(const char *str, unsigned int len);
struct event_title * hebcal_lookup_hu(const char *str, unsigned int len);
struct event_title * hebcal_lookup_pl(const char *str, unsigned int len);
struct event_title * hebcal_lookup_ru(const char *str, unsigned int len);
hebcal_lang g_lang = HEBCAL_LANG_DEFAULT;
void hebcal_set_language(hebcal_lang lang) {
g_lang = lang;
}
hebcal_lang hebcal_get_language(const char *locale) {
if (!locale || !locale[0]) {
return HEBCAL_LANG_DEFAULT;
} else if (0 == strcmp(locale, "ashkenazi")) {
return HEBCAL_LANG_ASHKENAZI;
} else if (0 == strcmp(locale, "ashkenazi_litvish")) {
return HEBCAL_LANG_ASHKENAZI_LITVISH;
} else if (0 == strcmp(locale, "ashkenazi_poylish")) {
return HEBCAL_LANG_ASHKENAZI_POYLISH;
} else if (0 == strcmp(locale, "ashkenazi_standard")) {
return HEBCAL_LANG_ASHKENAZI_STANDARD;
} else if (0 == strcmp(locale, "fi")) {
return HEBCAL_LANG_FI;
} else if (0 == strcmp(locale, "fr")) {
return HEBCAL_LANG_FR;
} else if (0 == strcmp(locale, "he")) {
return HEBCAL_LANG_HE;
} else if (0 == strcmp(locale, "hu")) {
return HEBCAL_LANG_HU;
} else if (0 == strcmp(locale, "pl")) {
return HEBCAL_LANG_PL;
} else if (0 == strcmp(locale, "ru")) {
return HEBCAL_LANG_RU;
} else {
return HEBCAL_LANG_UNDEFINED;
}
}
const char * lookup_translation(const char *src) {
struct event_title *et;
if (!src || !src[0]) {
return src;
}
switch (g_lang) {
case HEBCAL_LANG_DEFAULT:
return src;
case HEBCAL_LANG_ASHKENAZI:
et = hebcal_lookup_ashkenazi(src, strlen(src));
break;
case HEBCAL_LANG_ASHKENAZI_LITVISH:
et = hebcal_lookup_ashkenazi_litvish(src, strlen(src));
break;
case HEBCAL_LANG_ASHKENAZI_POYLISH:
et = hebcal_lookup_ashkenazi_poylish(src, strlen(src));
break;
case HEBCAL_LANG_ASHKENAZI_STANDARD:
et = hebcal_lookup_ashkenazi_standard(src, strlen(src));
break;
case HEBCAL_LANG_FI:
et = hebcal_lookup_fi(src, strlen(src));
break;
case HEBCAL_LANG_FR:
et = hebcal_lookup_fr(src, strlen(src));
break;
case HEBCAL_LANG_HE:
et = hebcal_lookup_he(src, strlen(src));
break;
case HEBCAL_LANG_HU:
et = hebcal_lookup_hu(src, strlen(src));
break;
case HEBCAL_LANG_PL:
et = hebcal_lookup_pl(src, strlen(src));
break;
case HEBCAL_LANG_RU:
et = hebcal_lookup_ru(src, strlen(src));
break;
case HEBCAL_LANG_UNDEFINED:
default:
return src;
}
if (et && et->dest && et->dest[0]) {
return et->dest;
}
return src;
}