locale-service 0.0.4 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,319 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.currencies = {
4
+ "AED": {
5
+ "c": "د.إ.‏"
6
+ },
7
+ "AFN": {
8
+ "c": "؋"
9
+ },
10
+ "ALL": {
11
+ "c": "Lek"
12
+ },
13
+ "AMD": {
14
+ "c": "դր."
15
+ },
16
+ "ARS": {
17
+ "c": "$"
18
+ },
19
+ "AUD": {
20
+ "c": "$"
21
+ },
22
+ "AZN": {
23
+ "c": "₼"
24
+ },
25
+ "BAM": {
26
+ "c": "КМ"
27
+ },
28
+ "BDT": {
29
+ "c": "৳"
30
+ },
31
+ "BGN": {
32
+ "c": "лв."
33
+ },
34
+ "BHD": {
35
+ "b": 3,
36
+ "c": "د.ب.‏"
37
+ },
38
+ "BND": {
39
+ "b": 0,
40
+ "c": "$"
41
+ },
42
+ "BOB": {
43
+ "c": "$b"
44
+ },
45
+ "BRL": {
46
+ "c": "R$"
47
+ },
48
+ "BYR": {
49
+ "c": "р."
50
+ },
51
+ "BZD": {
52
+ "c": "BZ$"
53
+ },
54
+ "CAD": {
55
+ "c": "$"
56
+ },
57
+ "CHF": {
58
+ "c": "Fr."
59
+ },
60
+ "CLP": {
61
+ "c": "$"
62
+ },
63
+ "CNY": {
64
+ "c": "¥"
65
+ },
66
+ "COP": {
67
+ "c": "$"
68
+ },
69
+ "CRC": {
70
+ "c": "₡"
71
+ },
72
+ "CSD": {
73
+ "c": "Din."
74
+ },
75
+ "CZK": {
76
+ "c": "Kč"
77
+ },
78
+ "DKK": {
79
+ "c": "kr."
80
+ },
81
+ "DOP": {
82
+ "c": "RD$"
83
+ },
84
+ "DZD": {
85
+ "c": "DA"
86
+ },
87
+ "EEK": {
88
+ "c": "kr"
89
+ },
90
+ "EGP": {
91
+ "c": "ج.م.‏"
92
+ },
93
+ "ETB": {
94
+ "c": "ETB"
95
+ },
96
+ "EUR": {
97
+ "c": "€"
98
+ },
99
+ "GBP": {
100
+ "c": "£"
101
+ },
102
+ "GEL": {
103
+ "c": "Lari"
104
+ },
105
+ "GTQ": {
106
+ "c": "Q"
107
+ },
108
+ "HKD": {
109
+ "c": "HK$"
110
+ },
111
+ "HNL": {
112
+ "c": "L."
113
+ },
114
+ "HRK": {
115
+ "c": "kn"
116
+ },
117
+ "HUF": {
118
+ "c": "Ft"
119
+ },
120
+ "IDR": {
121
+ "b": 0,
122
+ "c": "Rp"
123
+ },
124
+ "ILS": {
125
+ "c": "₪"
126
+ },
127
+ "INR": {
128
+ "c": "Rs."
129
+ },
130
+ "ISK": {
131
+ "b": 0,
132
+ "c": "kr."
133
+ },
134
+ "JMD": {
135
+ "c": "J$"
136
+ },
137
+ "JOD": {
138
+ "b": 3,
139
+ "c": "د.ا.‏"
140
+ },
141
+ "JPY": {
142
+ "b": 0,
143
+ "c": "¥"
144
+ },
145
+ "KES": {
146
+ "c": "S"
147
+ },
148
+ "KGS": {
149
+ "c": "сом"
150
+ },
151
+ "KHR": {
152
+ "c": "៛"
153
+ },
154
+ "KRW": {
155
+ "b": 0,
156
+ "c": "₩"
157
+ },
158
+ "KWD": {
159
+ "b": 3,
160
+ "c": "د.ك.‏"
161
+ },
162
+ "KZT": {
163
+ "c": "Т"
164
+ },
165
+ "LAK": {
166
+ "c": "₭"
167
+ },
168
+ "LBP": {
169
+ "c": "ل.ل.‏"
170
+ },
171
+ "LKR": {
172
+ "c": "රු."
173
+ },
174
+ "LTL": {
175
+ "c": "Lt"
176
+ },
177
+ "LVL": {
178
+ "c": "Ls"
179
+ },
180
+ "LYD": {
181
+ "b": 3,
182
+ "c": "د.ل.‏"
183
+ },
184
+ "MAD": {
185
+ "c": "د.م.‏"
186
+ },
187
+ "MKD": {
188
+ "c": "ден."
189
+ },
190
+ "MNT": {
191
+ "c": "₮"
192
+ },
193
+ "MOP": {
194
+ "c": "MOP"
195
+ },
196
+ "MVR": {
197
+ "c": "ރ."
198
+ },
199
+ "MXN": {
200
+ "c": "$"
201
+ },
202
+ "MYR": {
203
+ "c": "RM"
204
+ },
205
+ "NIO": {
206
+ "c": "C$"
207
+ },
208
+ "NOK": {
209
+ "c": "kr"
210
+ },
211
+ "NPR": {
212
+ "c": "रु"
213
+ },
214
+ "NZD": {
215
+ "c": "$"
216
+ },
217
+ "OMR": {
218
+ "b": 3,
219
+ "c": "ر.ع.‏"
220
+ },
221
+ "PAB": {
222
+ "c": "B/."
223
+ },
224
+ "PEN": {
225
+ "c": "S/."
226
+ },
227
+ "PHP": {
228
+ "c": "Php"
229
+ },
230
+ "PKR": {
231
+ "c": "Rs"
232
+ },
233
+ "PLN": {
234
+ "c": "zł"
235
+ },
236
+ "PYG": {
237
+ "c": "Gs"
238
+ },
239
+ "QAR": {
240
+ "c": "ر.ق.‏"
241
+ },
242
+ "RON": {
243
+ "c": "lei"
244
+ },
245
+ "RSD": {
246
+ "c": "Din."
247
+ },
248
+ "RUB": {
249
+ "c": "₽"
250
+ },
251
+ "RWF": {
252
+ "c": "RWF"
253
+ },
254
+ "SAR": {
255
+ "c": "ر.س.‏"
256
+ },
257
+ "SEK": {
258
+ "c": "kr"
259
+ },
260
+ "SGD": {
261
+ "c": "$"
262
+ },
263
+ "SYP": {
264
+ "c": "ل.س.‏"
265
+ },
266
+ "THB": {
267
+ "c": "฿"
268
+ },
269
+ "TJS": {
270
+ "c": "т.р."
271
+ },
272
+ "TMT": {
273
+ "c": "m."
274
+ },
275
+ "TND": {
276
+ "b": 3,
277
+ "c": "د.ت.‏"
278
+ },
279
+ "TRY": {
280
+ "c": "TL"
281
+ },
282
+ "TTD": {
283
+ "c": "TT$"
284
+ },
285
+ "TWD": {
286
+ "c": "NT$"
287
+ },
288
+ "UAH": {
289
+ "c": "₴"
290
+ },
291
+ "USD": {
292
+ "c": "$"
293
+ },
294
+ "UYU": {
295
+ "c": "$U"
296
+ },
297
+ "UZS": {
298
+ "c": "so'm"
299
+ },
300
+ "VEF": {
301
+ "c": "Bs. F."
302
+ },
303
+ "VND": {
304
+ "b": 0,
305
+ "c": "₫"
306
+ },
307
+ "XOF": {
308
+ "c": "XOF"
309
+ },
310
+ "YER": {
311
+ "c": "ر.ي.‏"
312
+ },
313
+ "ZAR": {
314
+ "c": "R"
315
+ },
316
+ "ZWL": {
317
+ "c": "Z$"
318
+ }
319
+ };
package/lib/index.js CHANGED
@@ -1,6 +1,80 @@
1
1
  "use strict";
2
- Object.defineProperty(exports,"__esModule",{value:true});
3
- var LocaleService_1 = require("./LocaleService");
4
- exports.DefaultLocaleService = LocaleService_1.DefaultLocaleService;
5
- var CurrencyService_1 = require("./CurrencyService");
6
- exports.DefaultCurrencyService = CurrencyService_1.DefaultCurrencyService;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var currencies_1 = require("./currencies");
4
+ var locales_1 = require("./locales");
5
+ var map_1 = require("./map");
6
+ var initLocale = false;
7
+ var lr = {};
8
+ function initLocaleResources() {
9
+ var keys = Object.keys(locales_1.locales);
10
+ for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
11
+ var key = keys_1[_i];
12
+ var x = locales_1.locales[key];
13
+ var l = {
14
+ id: x.a,
15
+ countryCode: x.b,
16
+ dateFormat: (x.c !== undefined ? x.c : 'dd/MM/yyyy'),
17
+ firstDayOfWeek: (x.d !== undefined ? x.d : 2),
18
+ decimalSeparator: (x.e !== undefined ? x.e : '.'),
19
+ groupSeparator: (x.f !== undefined ? x.f : ','),
20
+ decimalDigits: (x.g !== undefined ? x.g : 2),
21
+ currencyCode: (x.h !== undefined ? x.h : 'EUR'),
22
+ currencySymbol: (x.i !== undefined ? x.i : '€'),
23
+ currencyPattern: (x.j !== undefined ? x.j : 2),
24
+ currencySample: x.k
25
+ };
26
+ lr[key] = l;
27
+ }
28
+ }
29
+ function getLocaleFromResources(i) {
30
+ if (!initLocale) {
31
+ initLocaleResources();
32
+ initLocale = true;
33
+ }
34
+ return lr[i];
35
+ }
36
+ function locale(l) {
37
+ var lc = getLocaleFromResources(l);
38
+ if (!lc) {
39
+ var newId = map_1.map[l];
40
+ if (!newId) {
41
+ return undefined;
42
+ }
43
+ lc = getLocaleFromResources(newId);
44
+ }
45
+ return lc;
46
+ }
47
+ exports.locale = locale;
48
+ function id(lang) {
49
+ var i = map_1.map[lang];
50
+ return i;
51
+ }
52
+ exports.id = id;
53
+ var initCurrency = false;
54
+ var cr = {};
55
+ function initCurrencyResources() {
56
+ var keys = Object.keys(currencies_1.currencies);
57
+ for (var _i = 0, keys_2 = keys; _i < keys_2.length; _i++) {
58
+ var key = keys_2[_i];
59
+ var x = currencies_1.currencies[key];
60
+ var c = {
61
+ currencyCode: key,
62
+ decimalDigits: (x.b !== undefined ? x.b : 2),
63
+ currencySymbol: x.c
64
+ };
65
+ cr[key] = c;
66
+ }
67
+ }
68
+ function currency(currencyCode) {
69
+ if (!currencyCode) {
70
+ return undefined;
71
+ }
72
+ var code = currencyCode.toUpperCase();
73
+ if (!initCurrency) {
74
+ initCurrencyResources();
75
+ initCurrency = true;
76
+ }
77
+ var c = cr[code];
78
+ return c;
79
+ }
80
+ exports.currency = currency;