@noe-teritorio/opening_hours 3.14.1

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.
package/package.json ADDED
@@ -0,0 +1,133 @@
1
+ {
2
+ "name": "@noe-teritorio/opening_hours",
3
+ "type": "commonjs",
4
+ "types": "./types/index.d.ts",
5
+ "description": "Library to parse and process opening_hours tag from OpenStreetMap data",
6
+ "version": "3.14.1",
7
+ "main": "./build/opening_hours.js",
8
+ "module": "./build/opening_hours.esm.mjs",
9
+ "sideEffects": false,
10
+ "exports": {
11
+ ".": {
12
+ "import": "./build/opening_hours.esm.mjs",
13
+ "require": "./build/opening_hours.js",
14
+ "types": "./types/index.d.ts"
15
+ },
16
+ "./package.json": "./package.json"
17
+ },
18
+ "homepage": "https://github.com/opening-hours/opening_hours.js",
19
+ "author": "Dmitry Marakasov <amdmi3@amdmi3.ru>",
20
+ "maintainers": [
21
+ "Robin Schneider <ypid@riseup.net>"
22
+ ],
23
+ "contributors": [
24
+ {
25
+ "name": "Contributors",
26
+ "url": "https://github.com/opening-hours/opening_hours.js/graphs/contributors"
27
+ }
28
+ ],
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "git+https://github.com/opening-hours/opening_hours.js.git"
32
+ },
33
+ "bugs": "https://github.com/opening-hours/opening_hours.js/issues?state=open",
34
+ "keywords": [
35
+ "openstreetmap",
36
+ "OSM",
37
+ "opening_hours"
38
+ ],
39
+ "license": "LGPL-3.0-only",
40
+ "files": [
41
+ "Makefile",
42
+ "build/opening_hours.js",
43
+ "build/opening_hours.esm.mjs",
44
+ "build/opening_hours.esm.mjs.map",
45
+ "CHANGELOG.md",
46
+ "LICENSES/",
47
+ "REUSE.toml",
48
+ "site/js/",
49
+ "src/locales/i18n.js",
50
+ "types/index.d.ts"
51
+ ],
52
+ "directories": {
53
+ "doc": "./docs/"
54
+ },
55
+ "scripts": {
56
+ "build": "make build",
57
+ "test-quick": "make check",
58
+ "test": "make check-full",
59
+ "lint": "eslint",
60
+ "typecheck": "tsc --project jsconfig.json",
61
+ "lint:fix": "eslint --fix",
62
+ "benchmark": "make benchmark",
63
+ "interactive_testing": "make run-interactive_testing",
64
+ "regex_search": "make run-regex_search",
65
+ "prepare": "husky",
66
+ "readme": "doctoc README.md --title \"## Table of Contents\"",
67
+ "check-updates": "npm-check-updates --upgrade"
68
+ },
69
+ "dependencies": {
70
+ "i18next": "^26.3.6",
71
+ "suncalc": "^2.0.1"
72
+ },
73
+ "devDependencies": {
74
+ "@commitlint/cli": "^21.2.1",
75
+ "@commitlint/config-conventional": "^21.2.0",
76
+ "@eslint/js": "^10.0.1",
77
+ "@eslint/markdown": "^8.0.3",
78
+ "@rollup/plugin-commonjs": "^29.0.3",
79
+ "@rollup/plugin-json": "^6.1.0",
80
+ "@rollup/plugin-node-resolve": "^16.0.3",
81
+ "@rollup/plugin-terser": "^1.0.0",
82
+ "@rollup/plugin-yaml": "^5.0.0",
83
+ "@stylistic/eslint-plugin": "^5.10.0",
84
+ "@types/node": "^26.2.0",
85
+ "cldr-dates-full": "^48.2.0",
86
+ "cldr-localenames-full": "^48.2.0",
87
+ "commit-and-tag-version": "^13.1.2",
88
+ "commitizen": "^4.3.2",
89
+ "cz-conventional-changelog": "^3.3.0",
90
+ "doctoc": "^2.5.0",
91
+ "eslint": "^10.8.1",
92
+ "eslint-plugin-jsdoc": "^64.0.1",
93
+ "glob": "^13.0.6",
94
+ "globals": "^17.9.0",
95
+ "husky": "^9.1.7",
96
+ "lint-staged": "^17.3.0",
97
+ "npm-check-updates": "^23.0.2",
98
+ "package-json-validator-cli": "^0.1.11",
99
+ "rollup": "^4.62.4",
100
+ "terser": "^5.49.2",
101
+ "timekeeper": "^2.3.1",
102
+ "typescript": "^6.0.3",
103
+ "typescript-eslint": "^8.66.0",
104
+ "yaml": "^2.9.0",
105
+ "yargs": "^18.1.0"
106
+ },
107
+ "engines": {
108
+ "node": ">=14"
109
+ },
110
+ "devEngines": {
111
+ "runtime": {
112
+ "name": "node",
113
+ "version": ">=22",
114
+ "onFail": "error"
115
+ },
116
+ "packageManager": {
117
+ "name": "npm",
118
+ "version": ">=11",
119
+ "onFail": "error"
120
+ }
121
+ },
122
+ "allowScripts": {
123
+ "fsevents": false
124
+ },
125
+ "config": {
126
+ "commitizen": {
127
+ "path": "./node_modules/cz-conventional-changelog"
128
+ }
129
+ },
130
+ "lint-staged": {
131
+ "*.{js,mjs,ts}": "eslint --fix"
132
+ }
133
+ }
@@ -0,0 +1,247 @@
1
+ /*
2
+ * SPDX-FileCopyrightText: © 2015 Robin Schneider <ypid@riseup.net>
3
+ *
4
+ * SPDX-License-Identifier: LGPL-3.0-only
5
+ *
6
+ * Upstream source: https://wiki.openstreetmap.org/wiki/Nominatim/Country_Codes
7
+ */
8
+ export const countryToLanguageMapping = {
9
+ 'ad': 'ca',
10
+ 'ae': 'ar',
11
+ 'af': 'fa,ps',
12
+ 'ag': 'en',
13
+ 'ai': 'en',
14
+ 'al': 'sq',
15
+ 'am': 'hy',
16
+ 'an': 'nl,en',
17
+ 'ao': 'pt',
18
+ 'ar': 'es',
19
+ 'as': 'en,sm',
20
+ 'at': 'de',
21
+ 'au': 'en',
22
+ 'aw': 'nl,pap',
23
+ 'ax': 'sv',
24
+ 'ba': 'bs,hr,sr',
25
+ 'bb': 'en',
26
+ 'bd': 'bn',
27
+ 'be': 'nl,fr,de',
28
+ 'bf': 'fr',
29
+ 'bh': 'ar',
30
+ 'bi': 'fr',
31
+ 'bj': 'fr',
32
+ 'bl': 'fr',
33
+ 'bm': 'en',
34
+ 'bn': 'ms',
35
+ 'bo': 'es,qu,ay',
36
+ 'br': 'pt',
37
+ 'bs': 'en',
38
+ 'bt': 'dz',
39
+ 'bv': 'no',
40
+ 'bw': 'en,tn',
41
+ 'by': 'be,ru',
42
+ 'bz': 'en',
43
+ 'ca': 'en,fr',
44
+ 'cc': 'en',
45
+ 'cd': 'fr',
46
+ 'cf': 'fr',
47
+ 'cg': 'fr',
48
+ 'ch': 'de,fr,it,rm',
49
+ 'ci': 'fr',
50
+ 'ck': 'en,rar',
51
+ 'cl': 'es',
52
+ 'cm': 'fr,en',
53
+ 'cn': 'zh',
54
+ 'co': 'es',
55
+ 'cr': 'es',
56
+ 'cu': 'es',
57
+ 'cv': 'pt',
58
+ 'cx': 'en',
59
+ 'cy': 'el,tr',
60
+ 'cz': 'cs',
61
+ 'dj': 'fr,ar,so',
62
+ 'dk': 'da',
63
+ 'dm': 'en',
64
+ 'do': 'es',
65
+ 'dz': 'ar',
66
+ 'ec': 'es',
67
+ 'ee': 'et',
68
+ 'eg': 'ar',
69
+ 'eh': 'ar,es,fr',
70
+ 'er': 'ti,ar,en',
71
+ 'es': 'es,ca,eu,gl,an,oc,ast',
72
+ 'et': 'am,om',
73
+ 'fi': 'fi,sv,se',
74
+ 'fj': 'en',
75
+ 'fk': 'en',
76
+ 'fm': 'en',
77
+ 'ga': 'fr',
78
+ 'gb': 'en,ga,cy,gd,kw',
79
+ 'gd': 'en',
80
+ 'ge': 'ka',
81
+ 'gf': 'fr',
82
+ 'gg': 'en',
83
+ 'gh': 'en',
84
+ 'gi': 'en',
85
+ 'gl': 'kl,da',
86
+ 'gm': 'en',
87
+ 'gn': 'fr',
88
+ 'gp': 'fr',
89
+ 'gq': 'es,fr,pt',
90
+ 'gr': 'el',
91
+ 'gs': 'en',
92
+ 'gt': 'es',
93
+ 'gu': 'en,ch',
94
+ 'gw': 'pt',
95
+ 'gy': 'en',
96
+ 'hk': 'zh,en',
97
+ 'hm': 'en',
98
+ 'hn': 'es',
99
+ 'ht': 'fr,ht',
100
+ 'ie': 'en,ga',
101
+ 'il': 'he',
102
+ 'im': 'en',
103
+ 'in': 'hi,en',
104
+ 'io': 'en',
105
+ 'iq': 'ar,ku',
106
+ 'ir': 'fa',
107
+ 'it': 'it,de,fr',
108
+ 'je': 'en',
109
+ 'jm': 'en',
110
+ 'jo': 'ar',
111
+ 'jp': 'ja',
112
+ 'ke': 'sw,en',
113
+ 'kg': 'ky,ru',
114
+ 'kh': 'km',
115
+ 'ki': 'en',
116
+ 'km': 'ar,fr',
117
+ 'kn': 'en',
118
+ 'kp': 'ko',
119
+ 'kr': 'ko,en',
120
+ 'kw': 'ar',
121
+ 'ky': 'en',
122
+ 'kz': 'kk,ru',
123
+ 'la': 'lo',
124
+ 'lb': 'ar,fr',
125
+ 'lc': 'en',
126
+ 'li': 'de',
127
+ 'lk': 'si,ta',
128
+ 'lr': 'en',
129
+ 'ls': 'en,st',
130
+ 'lu': 'lb,fr,de',
131
+ 'ly': 'ar',
132
+ 'ma': 'ar',
133
+ 'mc': 'fr',
134
+ 'md': 'ru,uk,ro',
135
+ 'me': 'srp,sq,bs,hr,sr',
136
+ 'mf': 'fr',
137
+ 'mg': 'mg,fr',
138
+ 'mh': 'en,mh',
139
+ 'ml': 'fr',
140
+ 'mm': 'my',
141
+ 'mo': 'zh,pt',
142
+ 'mp': 'ch',
143
+ 'mq': 'fr',
144
+ 'mr': 'ar,fr',
145
+ 'ms': 'en',
146
+ 'mt': 'mt,en',
147
+ 'mu': 'mfe,fr,en',
148
+ 'mv': 'dv',
149
+ 'mw': 'en,ny',
150
+ 'mx': 'es',
151
+ 'my': 'ms',
152
+ 'mz': 'pt',
153
+ 'na': 'en,sf,de',
154
+ 'nc': 'fr',
155
+ 'ne': 'fr',
156
+ 'nf': 'en,pih',
157
+ 'ng': 'en',
158
+ 'ni': 'es',
159
+ 'no': 'nb,nn,no,se',
160
+ 'np': 'ne',
161
+ 'nr': 'na,en',
162
+ 'nu': 'niu,en',
163
+ 'nz': 'mi,en',
164
+ 'om': 'ar',
165
+ 'pa': 'es',
166
+ 'pe': 'es',
167
+ 'pf': 'fr',
168
+ 'pg': 'en,tpi,ho',
169
+ 'ph': 'en,tl',
170
+ 'pk': 'en,ur',
171
+ 'pm': 'fr',
172
+ 'pn': 'en,pih',
173
+ 'pr': 'es,en',
174
+ 'ps': 'ar,he',
175
+ 'pw': 'en,pau,ja,sov,tox',
176
+ 'py': 'es,gn',
177
+ 'qa': 'ar',
178
+ 're': 'fr',
179
+ 'rs': 'sr',
180
+ 'rw': 'rw,fr,en',
181
+ 'sa': 'ar',
182
+ 'sb': 'en',
183
+ 'sc': 'fr,en,crs',
184
+ 'sd': 'ar,en',
185
+ 'se': 'sv',
186
+ 'sg': 'en,ms,zh,ta',
187
+ 'sh': 'en',
188
+ 'si': 'sl',
189
+ 'sj': 'no',
190
+ 'sl': 'en',
191
+ 'sm': 'it',
192
+ 'sn': 'fr',
193
+ 'so': 'so,ar',
194
+ 'sr': 'nl',
195
+ 'st': 'pt',
196
+ 'ss': 'en',
197
+ 'sv': 'es',
198
+ 'sy': 'ar',
199
+ 'sz': 'en,ss',
200
+ 'tc': 'en',
201
+ 'td': 'fr,ar',
202
+ 'tf': 'fr',
203
+ 'tg': 'fr',
204
+ 'tj': 'tg,ru',
205
+ 'tk': 'tkl,en,sm',
206
+ 'tl': 'pt,tet',
207
+ 'tm': 'tk',
208
+ 'tn': 'ar',
209
+ 'to': 'en',
210
+ 'tt': 'en',
211
+ 'tv': 'en',
212
+ 'tw': 'zh',
213
+ 'tz': 'sw,en',
214
+ 'ua': 'uk',
215
+ 'ug': 'en,sw',
216
+ 'um': 'en',
217
+ 'us': 'en',
218
+ 'uy': 'es',
219
+ 'uz': 'uz,kaa',
220
+ 'va': 'it',
221
+ 'vc': 'en',
222
+ 've': 'es',
223
+ 'vg': 'en',
224
+ 'vi': 'en',
225
+ 'vn': 'vi',
226
+ 'vu': 'bi,en,fr',
227
+ 'wf': 'fr',
228
+ 'ws': 'sm,en',
229
+ 'ye': 'ar',
230
+ 'yt': 'fr',
231
+ 'za': 'zu,xh,af,st,tn,en',
232
+ 'zm': 'en',
233
+ 'zw': 'en,sn,nd ',
234
+ };
235
+
236
+ /**
237
+ * Get the preferred languages for a country code.
238
+ * @param {string} country_code - ISO 3166-1 alpha-2 country code.
239
+ * @returns {string} Comma-separated preferred language codes, or the country code when unknown.
240
+ */
241
+ export function mapCountryToLanguage(country_code) {
242
+ if (typeof countryToLanguageMapping[country_code] !== 'undefined') {
243
+ return countryToLanguageMapping[country_code];
244
+ } else {
245
+ return country_code;
246
+ }
247
+ }