@lingui/detect-locale 3.14.0 → 3.16.0
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/CHANGELOG.md +341 -0
- package/build/LICENSE +21 -0
- package/{cjs/detect-locale.development.js → build/cjs/index.js} +6 -8
- package/build/cjs/index.js.map +1 -0
- package/{esm/detect-locale.development.js → build/esm/index.js} +6 -6
- package/build/esm/index.js.map +1 -0
- package/{esm → build/esm}/package.json +0 -0
- package/build/index.d.ts +25 -0
- package/build/index.js +1 -0
- package/package.json +10 -11
- package/cjs/detect-locale.development.js.map +0 -1
- package/cjs/detect-locale.production.min.js +0 -2
- package/cjs/detect-locale.production.min.js.map +0 -1
- package/cjs/detectors/fromCookie.d.ts +0 -3
- package/cjs/detectors/fromCookie.d.ts.map +0 -1
- package/cjs/detectors/fromHtmlTag.d.ts +0 -3
- package/cjs/detectors/fromHtmlTag.d.ts.map +0 -1
- package/cjs/detectors/fromNavigator.d.ts +0 -7
- package/cjs/detectors/fromNavigator.d.ts.map +0 -1
- package/cjs/detectors/fromPath.d.ts +0 -3
- package/cjs/detectors/fromPath.d.ts.map +0 -1
- package/cjs/detectors/fromStorage.d.ts +0 -5
- package/cjs/detectors/fromStorage.d.ts.map +0 -1
- package/cjs/detectors/fromSubdomain.d.ts +0 -3
- package/cjs/detectors/fromSubdomain.d.ts.map +0 -1
- package/cjs/detectors/fromUrl.d.ts +0 -3
- package/cjs/detectors/fromUrl.d.ts.map +0 -1
- package/cjs/index.d.ts +0 -14
- package/cjs/index.d.ts.map +0 -1
- package/cjs/utils/cookie-getter.d.ts +0 -2
- package/cjs/utils/cookie-getter.d.ts.map +0 -1
- package/cjs/utils/query-string.d.ts +0 -8
- package/cjs/utils/query-string.d.ts.map +0 -1
- package/esm/detect-locale.development.js.map +0 -1
- package/esm/detect-locale.production.min.js +0 -2
- package/esm/detect-locale.production.min.js.map +0 -1
- package/esm/detectors/fromCookie.d.ts +0 -3
- package/esm/detectors/fromCookie.d.ts.map +0 -1
- package/esm/detectors/fromHtmlTag.d.ts +0 -3
- package/esm/detectors/fromHtmlTag.d.ts.map +0 -1
- package/esm/detectors/fromNavigator.d.ts +0 -7
- package/esm/detectors/fromNavigator.d.ts.map +0 -1
- package/esm/detectors/fromPath.d.ts +0 -3
- package/esm/detectors/fromPath.d.ts.map +0 -1
- package/esm/detectors/fromStorage.d.ts +0 -5
- package/esm/detectors/fromStorage.d.ts.map +0 -1
- package/esm/detectors/fromSubdomain.d.ts +0 -3
- package/esm/detectors/fromSubdomain.d.ts.map +0 -1
- package/esm/detectors/fromUrl.d.ts +0 -3
- package/esm/detectors/fromUrl.d.ts.map +0 -1
- package/esm/index.d.ts +0 -14
- package/esm/index.d.ts.map +0 -1
- package/esm/index.js +0 -33
- package/esm/utils/cookie-getter.d.ts +0 -2
- package/esm/utils/cookie-getter.d.ts.map +0 -1
- package/esm/utils/query-string.d.ts +0 -8
- package/esm/utils/query-string.d.ts.map +0 -1
- package/index.js +0 -5
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
# [3.16.0](https://github.com/lingui/js-lingui/compare/v3.15.0...v3.16.0) (2023-01-18)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @lingui/detect-locale
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [3.15.0](https://github.com/lingui/js-lingui/compare/v3.14.0...v3.15.0) (2022-11-07)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @lingui/detect-locale
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# [3.14.0](https://github.com/lingui/js-lingui/compare/v3.13.3...v3.14.0) (2022-06-22)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* Add extra package.json under `/esm` ([#1258](https://github.com/lingui/js-lingui/issues/1258)) ([80cd337](https://github.com/lingui/js-lingui/commit/80cd3378ceb5677bfa50b14f67e4e31703392298))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## [3.13.3](https://github.com/lingui/js-lingui/compare/v3.13.2...v3.13.3) (2022-04-24)
|
|
34
|
+
|
|
35
|
+
**Note:** Version bump only for package @lingui/detect-locale
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
## [3.13.2](https://github.com/lingui/js-lingui/compare/v3.13.1...v3.13.2) (2022-01-24)
|
|
42
|
+
|
|
43
|
+
**Note:** Version bump only for package @lingui/detect-locale
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
## [3.13.1](https://github.com/lingui/js-lingui/compare/v3.13.0...v3.13.1) (2022-01-21)
|
|
50
|
+
|
|
51
|
+
**Note:** Version bump only for package @lingui/detect-locale
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
# [3.13.0](https://github.com/lingui/js-lingui/compare/v3.12.1...v3.13.0) (2021-11-26)
|
|
58
|
+
|
|
59
|
+
**Note:** Version bump only for package @lingui/detect-locale
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
## [3.12.1](https://github.com/lingui/js-lingui/compare/v3.12.0...v3.12.1) (2021-09-28)
|
|
66
|
+
|
|
67
|
+
**Note:** Version bump only for package @lingui/detect-locale
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
# [3.12.0](https://github.com/lingui/js-lingui/compare/v3.11.1...v3.12.0) (2021-09-28)
|
|
74
|
+
|
|
75
|
+
**Note:** Version bump only for package @lingui/detect-locale
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
## [3.11.1](https://github.com/lingui/js-lingui/compare/v3.11.0...v3.11.1) (2021-09-07)
|
|
82
|
+
|
|
83
|
+
**Note:** Version bump only for package @lingui/detect-locale
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
# [3.11.0](https://github.com/lingui/js-lingui/compare/v3.10.4...v3.11.0) (2021-09-07)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
### Bug Fixes
|
|
93
|
+
|
|
94
|
+
* sideEffects to false for shrinking bundle size ([#1129](https://github.com/lingui/js-lingui/issues/1129)) ([57cd2e5](https://github.com/lingui/js-lingui/commit/57cd2e576945ba30aea30d5cf5bcb27d1f77fe4c))
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
## [3.10.4](https://github.com/lingui/js-lingui/compare/v3.10.3...v3.10.4) (2021-06-16)
|
|
101
|
+
|
|
102
|
+
**Note:** Version bump only for package @lingui/detect-locale
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
## [3.10.3](https://github.com/lingui/js-lingui/compare/v3.10.2...v3.10.3) (2021-06-14)
|
|
109
|
+
|
|
110
|
+
**Note:** Version bump only for package @lingui/detect-locale
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
## [3.10.2](https://github.com/lingui/js-lingui/compare/v3.10.1...v3.10.2) (2021-06-08)
|
|
117
|
+
|
|
118
|
+
**Note:** Version bump only for package @lingui/detect-locale
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
## [3.10.1](https://github.com/lingui/js-lingui/compare/v3.10.0...v3.10.1) (2021-06-08)
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
### Bug Fixes
|
|
128
|
+
|
|
129
|
+
* reverts reduce size of ESM packages ([#1066](https://github.com/lingui/js-lingui/issues/1066)) ([3a057e0](https://github.com/lingui/js-lingui/commit/3a057e0c61224b98c93203e0d88136fa48f309ba))
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
# [3.10.0](https://github.com/lingui/js-lingui/compare/v3.9.0...v3.10.0) (2021-06-08)
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
### Bug Fixes
|
|
139
|
+
|
|
140
|
+
* reduce size of ESM packages ([#1066](https://github.com/lingui/js-lingui/issues/1066)) ([9990eba](https://github.com/lingui/js-lingui/commit/9990ebaa9d30f7e218c106a2abfd7ddbcf0e0170))
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
# [3.9.0](https://github.com/lingui/js-lingui/compare/v3.8.10...v3.9.0) (2021-05-18)
|
|
147
|
+
|
|
148
|
+
**Note:** Version bump only for package @lingui/detect-locale
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
## [3.8.10](https://github.com/lingui/js-lingui/compare/v3.8.9...v3.8.10) (2021-04-19)
|
|
155
|
+
|
|
156
|
+
**Note:** Version bump only for package @lingui/detect-locale
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
## [3.8.9](https://github.com/lingui/js-lingui/compare/v3.8.8...v3.8.9) (2021-04-09)
|
|
163
|
+
|
|
164
|
+
**Note:** Version bump only for package @lingui/detect-locale
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
## [3.8.8](https://github.com/lingui/js-lingui/compare/v3.8.7...v3.8.8) (2021-04-09)
|
|
171
|
+
|
|
172
|
+
**Note:** Version bump only for package @lingui/detect-locale
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
## [3.8.7](https://github.com/lingui/js-lingui/compare/v3.8.6...v3.8.7) (2021-04-09)
|
|
179
|
+
|
|
180
|
+
**Note:** Version bump only for package @lingui/detect-locale
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
## [3.8.6](https://github.com/lingui/js-lingui/compare/v3.8.5...v3.8.6) (2021-04-08)
|
|
187
|
+
|
|
188
|
+
**Note:** Version bump only for package @lingui/detect-locale
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
## [3.8.5](https://github.com/lingui/js-lingui/compare/v3.8.4...v3.8.5) (2021-04-08)
|
|
195
|
+
|
|
196
|
+
**Note:** Version bump only for package @lingui/detect-locale
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
## [3.8.4](https://github.com/lingui/js-lingui/compare/v3.8.3...v3.8.4) (2021-04-08)
|
|
203
|
+
|
|
204
|
+
**Note:** Version bump only for package @lingui/detect-locale
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
## [3.8.3](https://github.com/lingui/js-lingui/compare/v3.8.2...v3.8.3) (2021-04-05)
|
|
211
|
+
|
|
212
|
+
**Note:** Version bump only for package @lingui/detect-locale
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
## [3.8.2](https://github.com/lingui/js-lingui/compare/v3.8.1...v3.8.2) (2021-03-31)
|
|
219
|
+
|
|
220
|
+
**Note:** Version bump only for package @lingui/detect-locale
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
## [3.8.1](https://github.com/lingui/js-lingui/compare/v3.8.0...v3.8.1) (2021-03-23)
|
|
227
|
+
|
|
228
|
+
**Note:** Version bump only for package @lingui/detect-locale
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
# [3.8.0](https://github.com/lingui/js-lingui/compare/v3.7.2...v3.8.0) (2021-03-23)
|
|
235
|
+
|
|
236
|
+
**Note:** Version bump only for package @lingui/detect-locale
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
## [3.7.2](https://github.com/lingui/js-lingui/compare/v3.7.1...v3.7.2) (2021-03-14)
|
|
243
|
+
|
|
244
|
+
**Note:** Version bump only for package @lingui/detect-locale
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
## [3.7.1](https://github.com/lingui/js-lingui/compare/v3.7.0...v3.7.1) (2021-03-07)
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
### Bug Fixes
|
|
254
|
+
|
|
255
|
+
* exports attribute on package.json, expo compat ([#997](https://github.com/lingui/js-lingui/issues/997)) ([79aa509](https://github.com/lingui/js-lingui/commit/79aa50998185847064d80f2a38be0ebcb64424f9))
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
# [3.7.0](https://github.com/lingui/js-lingui/compare/v3.6.0...v3.7.0) (2021-03-04)
|
|
262
|
+
|
|
263
|
+
**Note:** Version bump only for package @lingui/detect-locale
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
# [3.6.0](https://github.com/lingui/js-lingui/compare/v3.5.1...v3.6.0) (2021-02-23)
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
### Features
|
|
273
|
+
|
|
274
|
+
* ship universal modules with ESM ([#979](https://github.com/lingui/js-lingui/issues/979)) ([6cd5fe0](https://github.com/lingui/js-lingui/commit/6cd5fe0a71dd5cf7e0832bd3e9902a2f6ba789f6))
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
## [3.5.1](https://github.com/lingui/js-lingui/compare/v3.5.0...v3.5.1) (2021-02-09)
|
|
281
|
+
|
|
282
|
+
**Note:** Version bump only for package @lingui/detect-locale
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
# [3.5.0](https://github.com/lingui/js-lingui/compare/v3.4.0...v3.5.0) (2021-02-02)
|
|
289
|
+
|
|
290
|
+
**Note:** Version bump only for package @lingui/detect-locale
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
# [3.4.0](https://github.com/lingui/js-lingui/compare/v3.3.0...v3.4.0) (2021-01-13)
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
### Bug Fixes
|
|
300
|
+
|
|
301
|
+
* **detect-locale:** ESM import not published ([#926](https://github.com/lingui/js-lingui/issues/926)) ([4ad90d4](https://github.com/lingui/js-lingui/commit/4ad90d4c60b752e9f0d82f3dd71936711c51573d))
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
# [3.3.0](https://github.com/lingui/js-lingui/compare/v3.2.3...v3.3.0) (2020-12-08)
|
|
308
|
+
|
|
309
|
+
**Note:** Version bump only for package @lingui/detect-locale
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
## [3.2.3](https://github.com/lingui/js-lingui/compare/v3.2.2...v3.2.3) (2020-11-22)
|
|
316
|
+
|
|
317
|
+
**Note:** Version bump only for package @lingui/detect-locale
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
## [3.2.2](https://github.com/lingui/js-lingui/compare/v3.2.1...v3.2.2) (2020-11-20)
|
|
324
|
+
|
|
325
|
+
**Note:** Version bump only for package @lingui/detect-locale
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
# [3.2.0](https://github.com/lingui/js-lingui/compare/v3.1.0...v3.2.0) (2020-11-12)
|
|
332
|
+
|
|
333
|
+
**Note:** Version bump only for package @lingui/detect-locale
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
# [3.1.0](https://github.com/lingui/js-lingui/compare/v3.0.3...v3.1.0) (2020-11-10)
|
|
340
|
+
|
|
341
|
+
**Note:** Version bump only for package @lingui/detect-locale
|
package/build/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Tomáš Ehrlich
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
function getCookie(key) {
|
|
6
4
|
if (!key) {
|
|
7
5
|
return;
|
|
@@ -87,11 +85,11 @@ function detectHtmlTag(htmlTagIdentifier) {
|
|
|
87
85
|
return null;
|
|
88
86
|
}
|
|
89
87
|
|
|
90
|
-
/**
|
|
91
|
-
* Simple query string parser.
|
|
92
|
-
*
|
|
93
|
-
* @param {String} query The query string that needs to be parsed.
|
|
94
|
-
* @returns {Object}
|
|
88
|
+
/**
|
|
89
|
+
* Simple query string parser.
|
|
90
|
+
*
|
|
91
|
+
* @param {String} query The query string that needs to be parsed.
|
|
92
|
+
* @returns {Object}
|
|
95
93
|
*/
|
|
96
94
|
function parse(query) {
|
|
97
95
|
var parser = /([^=?#&]+)=?([^&]*)/g;
|
|
@@ -168,4 +166,4 @@ exports.fromStorage = detectFromStorage;
|
|
|
168
166
|
exports.fromSubdomain = detectFromSubdomain;
|
|
169
167
|
exports.fromUrl = detectFromUrl;
|
|
170
168
|
exports.multipleDetect = multipleDetect;
|
|
171
|
-
//# sourceMappingURL=
|
|
169
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/utils/cookie-getter.ts","../../src/detectors/fromCookie.ts","../../src/detectors/fromPath.ts","../../src/detectors/fromStorage.ts","../../src/detectors/fromNavigator.ts","../../src/detectors/fromSubdomain.ts","../../src/detectors/fromHtmlTag.ts","../../src/utils/query-string.ts","../../src/detectors/fromUrl.ts","../../src/index.ts"],"sourcesContent":["export function getCookie(key: string): string {\n if (!key) {\n return;\n }\n\n // To prevent the for loop in the first place assign an empty array\n // in case there are no cookies at all.\n const cookies = globalThis.document.cookie ? globalThis.document.cookie.split('; ') : []\n const jar = {}\n for (let i = 0; i < cookies.length; i++) {\n const parts = cookies[i].split('=')\n let value = parts.slice(1).join('=')\n\n if (value[0] === '\"') {\n value = value.slice(1, -1)\n }\n\n try {\n const foundKey = parts[0].replace(/(%[\\dA-F]{2})+/gi, decodeURIComponent)\n jar[foundKey] = value.replace(/(%[\\dA-F]{2})+/gi, decodeURIComponent)\n\n if (key === foundKey) {\n break\n }\n } catch (e) {}\n }\n\n return key ? jar[key] : jar\n}","import { LocaleString } from \"..\"\nimport { getCookie } from \"../utils/cookie-getter\"\n\nexport default function detectFromCookie(\n key: string\n): LocaleString {\n return getCookie(key)\n}","import { LocaleString } from \"../\"\n\nexport default function detectFromPath(\n localePathIndex: number,\n location: Partial<Location> = globalThis.location,\n): LocaleString {\n const locale: RegExpMatchArray = location.pathname.match(/\\/([a-zA-Z-]*)/g)\n if (Array.isArray(locale)) {\n return locale[localePathIndex].replace(\"/\", \"\")\n }\n\n return null\n}","import { LocaleString } from \"..\"\n\nexport default function detectFromStorage(\n key: string,\n options: { useSessionStorage: boolean } = { useSessionStorage: false }\n): LocaleString {\n if (options.useSessionStorage) {\n return globalThis.sessionStorage.getItem(key);\n }\n\n return globalThis.localStorage.getItem(key);\n}","import { LocaleString } from \"..\"\n\ntype IE11NavigatorLanguage = {\n userLanguage?: string\n}\n\nexport default function detectFromNavigator(\n navigator: Partial<Navigator & IE11NavigatorLanguage> = globalThis.navigator\n): LocaleString {\n\n const result: LocaleString = navigator.language || navigator.userLanguage\n return result\n}","import { LocaleString } from \"../\"\n\nexport default function detectFromSubdomain(\n localeSubdomainIndex: number,\n location: Partial<Location> = globalThis.location,\n): LocaleString {\n const locale: RegExpMatchArray = location.href.match(/(?:http[s]*\\:\\/\\/)*(.*?)\\.(?=[^\\/]*\\..{2,5})/gi)\n if (Array.isArray(locale)) {\n return locale[localeSubdomainIndex]\n .replace('http://', '')\n .replace('https://', '')\n .replace('.', '')\n }\n\n return null\n}","import { LocaleString } from \"..\"\n\nexport default function detectHtmlTag(\n htmlTagIdentifier: string,\n document: Partial<Document> = globalThis.document\n): LocaleString {\n if (htmlTagIdentifier) {\n return document.documentElement.getAttribute(htmlTagIdentifier)\n }\n\n return null\n}","\n/**\n * Simple query string parser.\n *\n * @param {String} query The query string that needs to be parsed.\n * @returns {Object}\n */\nexport function parse(query) {\n const parser = /([^=?#&]+)=?([^&]*)/g;\n const result = {};\n let part;\n\n while (part = parser.exec(query)) {\n const key = decode(part[1]);\n const value = decode(part[2]);\n\n //\n // Prevent overriding of existing properties. This ensures that build-in\n // methods like `toString` or __proto__ are not overriden by malicious\n // querystrings.\n //\n // In the case if failed decoding, we want to omit the key/value pairs\n // from the result.\n //\n if (key === null || value === null || key in result) continue;\n result[key] = value;\n }\n\n return result;\n}\n\nfunction decode(input) {\n try {\n return decodeURIComponent(input.replace(/\\+/g, ' '));\n } catch (e) {\n return null;\n }\n}\nfunction encode(input) {\n try {\n return encodeURIComponent(input);\n } catch (e) {\n return null;\n }\n}\n","import { parse } from \"../utils/query-string\";\nimport { LocaleString } from \"..\";\n\nexport default function detectFromUrl(\n parameter: string,\n location: Partial<Location> = globalThis.location\n): LocaleString {\n if (!parameter) throw new Error(\"fromUrl parameter is required\");\n\n const result: LocaleString = parse(location.search)[parameter] || null\n return result\n}","import \"./utils/globalThis.polyfill.js\"\nimport fromCookie from \"./detectors/fromCookie\"\nimport fromPath from \"./detectors/fromPath\"\nimport fromStorage from \"./detectors/fromStorage\"\nimport fromNavigator from \"./detectors/fromNavigator\"\nimport fromSubdomain from \"./detectors/fromSubdomain\"\nimport fromHtmlTag from \"./detectors/fromHtmlTag\"\nimport fromUrl from \"./detectors/fromUrl\"\n\nexport type LocaleString = string\nexport type DetectParamsFunctions = string\n\nfunction detect(...args): LocaleString | null {\n for (let i = 0; i < args.length; i++) {\n const res: LocaleString = typeof args[i] === \"function\" ? args[i]() : args[i]\n if (res) return res\n }\n\n return null\n}\n\nfunction multipleDetect(...args): LocaleString[] {\n const locales = []\n for (let i = 0; i < args.length; i++) {\n const res: LocaleString = typeof args[i] === \"function\" ? args[i]() : args[i]\n if (res) locales.push(res)\n }\n\n return locales\n}\n\nexport {\n detect,\n multipleDetect,\n fromCookie,\n fromHtmlTag,\n fromNavigator,\n fromPath,\n fromStorage,\n fromSubdomain,\n fromUrl,\n}\n"],"names":["getCookie","key","cookies","globalThis","document","cookie","split","jar","i","length","parts","value","slice","join","foundKey","replace","decodeURIComponent","e","detectFromCookie","detectFromPath","localePathIndex","location","locale","pathname","match","Array","isArray","detectFromStorage","options","useSessionStorage","sessionStorage","getItem","localStorage","detectFromNavigator","navigator","result","language","userLanguage","detectFromSubdomain","localeSubdomainIndex","href","detectHtmlTag","htmlTagIdentifier","documentElement","getAttribute","parse","query","parser","part","exec","decode","input","detectFromUrl","parameter","Error","search","detect","args","res","multipleDetect","locales","push"],"mappings":";;AAAO,SAASA,SAAT,CAAmBC,GAAnB,EAAwC;AAC7C,EAAI,IAAA,CAACA,GAAL,EAAU;AACR,IAAA,OAAA;AACD,GAH4C;AAM7C;;;AACA,EAAA,IAAMC,OAAO,GAAGC,UAAU,CAACC,QAAX,CAAoBC,MAApB,GAA6BF,UAAU,CAACC,QAAX,CAAoBC,MAApB,CAA2BC,KAA3B,CAAiC,IAAjC,CAA7B,GAAsE,EAAtF,CAAA;AACA,EAAMC,IAAAA,GAAG,GAAG,EAAZ,CAAA;;AACA,EAAA,KAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGN,OAAO,CAACO,MAA5B,EAAoCD,CAAC,EAArC,EAAyC;AACvC,IAAME,IAAAA,KAAK,GAAGR,OAAO,CAACM,CAAD,CAAP,CAAWF,KAAX,CAAiB,GAAjB,CAAd,CAAA;AACA,IAAIK,IAAAA,KAAK,GAAGD,KAAK,CAACE,KAAN,CAAY,CAAZ,CAAeC,CAAAA,IAAf,CAAoB,GAApB,C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jD,CAAD,CAA1E,CAAA;AACA,IAAIkD,IAAAA,GAAJ,EAAS,OAAOA,GAAP,CAAA;AACV,GAAA;;AAED,EAAA,OAAO,IAAP,CAAA;AACD,CAAA;;AAED,SAASC,cAAT,GAAiD;AAC/C,EAAMC,IAAAA,OAAO,GAAG,EAAhB,CAAA;;AAD+C,EAAA,KAAA,IAAA,KAAA,GAAA,SAAA,CAAA,MAAA,EAAtBH,IAAsB,GAAA,IAAA,KAAA,CAAA,KAAA,CAAA,EAAA,KAAA,GAAA,CAAA,EAAA,KAAA,GAAA,KAAA,EAAA,KAAA,EAAA,EAAA;AAAtBA,IAAAA,IAAsB,CAAA,KAAA,CAAA,GAAA,SAAA,CAAA,KAAA,CAAA,CAAA;AAAA,GAAA;;AAE/C,EAAA,KAAK,IAAIjD,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGiD,IAAI,CAAChD,MAAzB,EAAiCD,CAAC,EAAlC,EAAsC;AACpC,IAAA,IAAMkD,GAAiB,GAAG,OAAOD,IAAI,CAACjD,CAAD,CAAX,KAAmB,UAAnB,GAAgCiD,IAAI,CAACjD,CAAD,CAAJ,EAAhC,GAA4CiD,IAAI,CAACjD,CAAD,CAA1E,CAAA;AACA,IAAA,IAAIkD,GAAJ,EAASE,OAAO,CAACC,IAAR,CAAaH,GAAb,CAAA,CAAA;AACV,GAAA;;AAED,EAAA,OAAOE,OAAP,CAAA;AACD;;;;;;;;;;;;"}
|
|
@@ -83,11 +83,11 @@ function detectHtmlTag(htmlTagIdentifier) {
|
|
|
83
83
|
return null;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
/**
|
|
87
|
-
* Simple query string parser.
|
|
88
|
-
*
|
|
89
|
-
* @param {String} query The query string that needs to be parsed.
|
|
90
|
-
* @returns {Object}
|
|
86
|
+
/**
|
|
87
|
+
* Simple query string parser.
|
|
88
|
+
*
|
|
89
|
+
* @param {String} query The query string that needs to be parsed.
|
|
90
|
+
* @returns {Object}
|
|
91
91
|
*/
|
|
92
92
|
function parse(query) {
|
|
93
93
|
var parser = /([^=?#&]+)=?([^&]*)/g;
|
|
@@ -156,4 +156,4 @@ function multipleDetect() {
|
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
export { detect, detectFromCookie as fromCookie, detectHtmlTag as fromHtmlTag, detectFromNavigator as fromNavigator, detectFromPath as fromPath, detectFromStorage as fromStorage, detectFromSubdomain as fromSubdomain, detectFromUrl as fromUrl, multipleDetect };
|
|
159
|
-
//# sourceMappingURL=
|
|
159
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/utils/cookie-getter.ts","../../src/detectors/fromCookie.ts","../../src/detectors/fromPath.ts","../../src/detectors/fromStorage.ts","../../src/detectors/fromNavigator.ts","../../src/detectors/fromSubdomain.ts","../../src/detectors/fromHtmlTag.ts","../../src/utils/query-string.ts","../../src/detectors/fromUrl.ts","../../src/index.ts"],"sourcesContent":["export function getCookie(key: string): string {\n if (!key) {\n return;\n }\n\n // To prevent the for loop in the first place assign an empty array\n // in case there are no cookies at all.\n const cookies = globalThis.document.cookie ? globalThis.document.cookie.split('; ') : []\n const jar = {}\n for (let i = 0; i < cookies.length; i++) {\n const parts = cookies[i].split('=')\n let value = parts.slice(1).join('=')\n\n if (value[0] === '\"') {\n value = value.slice(1, -1)\n }\n\n try {\n const foundKey = parts[0].replace(/(%[\\dA-F]{2})+/gi, decodeURIComponent)\n jar[foundKey] = value.replace(/(%[\\dA-F]{2})+/gi, decodeURIComponent)\n\n if (key === foundKey) {\n break\n }\n } catch (e) {}\n }\n\n return key ? jar[key] : jar\n}","import { LocaleString } from \"..\"\nimport { getCookie } from \"../utils/cookie-getter\"\n\nexport default function detectFromCookie(\n key: string\n): LocaleString {\n return getCookie(key)\n}","import { LocaleString } from \"../\"\n\nexport default function detectFromPath(\n localePathIndex: number,\n location: Partial<Location> = globalThis.location,\n): LocaleString {\n const locale: RegExpMatchArray = location.pathname.match(/\\/([a-zA-Z-]*)/g)\n if (Array.isArray(locale)) {\n return locale[localePathIndex].replace(\"/\", \"\")\n }\n\n return null\n}","import { LocaleString } from \"..\"\n\nexport default function detectFromStorage(\n key: string,\n options: { useSessionStorage: boolean } = { useSessionStorage: false }\n): LocaleString {\n if (options.useSessionStorage) {\n return globalThis.sessionStorage.getItem(key);\n }\n\n return globalThis.localStorage.getItem(key);\n}","import { LocaleString } from \"..\"\n\ntype IE11NavigatorLanguage = {\n userLanguage?: string\n}\n\nexport default function detectFromNavigator(\n navigator: Partial<Navigator & IE11NavigatorLanguage> = globalThis.navigator\n): LocaleString {\n\n const result: LocaleString = navigator.language || navigator.userLanguage\n return result\n}","import { LocaleString } from \"../\"\n\nexport default function detectFromSubdomain(\n localeSubdomainIndex: number,\n location: Partial<Location> = globalThis.location,\n): LocaleString {\n const locale: RegExpMatchArray = location.href.match(/(?:http[s]*\\:\\/\\/)*(.*?)\\.(?=[^\\/]*\\..{2,5})/gi)\n if (Array.isArray(locale)) {\n return locale[localeSubdomainIndex]\n .replace('http://', '')\n .replace('https://', '')\n .replace('.', '')\n }\n\n return null\n}","import { LocaleString } from \"..\"\n\nexport default function detectHtmlTag(\n htmlTagIdentifier: string,\n document: Partial<Document> = globalThis.document\n): LocaleString {\n if (htmlTagIdentifier) {\n return document.documentElement.getAttribute(htmlTagIdentifier)\n }\n\n return null\n}","\n/**\n * Simple query string parser.\n *\n * @param {String} query The query string that needs to be parsed.\n * @returns {Object}\n */\nexport function parse(query) {\n const parser = /([^=?#&]+)=?([^&]*)/g;\n const result = {};\n let part;\n\n while (part = parser.exec(query)) {\n const key = decode(part[1]);\n const value = decode(part[2]);\n\n //\n // Prevent overriding of existing properties. This ensures that build-in\n // methods like `toString` or __proto__ are not overriden by malicious\n // querystrings.\n //\n // In the case if failed decoding, we want to omit the key/value pairs\n // from the result.\n //\n if (key === null || value === null || key in result) continue;\n result[key] = value;\n }\n\n return result;\n}\n\nfunction decode(input) {\n try {\n return decodeURIComponent(input.replace(/\\+/g, ' '));\n } catch (e) {\n return null;\n }\n}\nfunction encode(input) {\n try {\n return encodeURIComponent(input);\n } catch (e) {\n return null;\n }\n}\n","import { parse } from \"../utils/query-string\";\nimport { LocaleString } from \"..\";\n\nexport default function detectFromUrl(\n parameter: string,\n location: Partial<Location> = globalThis.location\n): LocaleString {\n if (!parameter) throw new Error(\"fromUrl parameter is required\");\n\n const result: LocaleString = parse(location.search)[parameter] || null\n return result\n}","import \"./utils/globalThis.polyfill.js\"\nimport fromCookie from \"./detectors/fromCookie\"\nimport fromPath from \"./detectors/fromPath\"\nimport fromStorage from \"./detectors/fromStorage\"\nimport fromNavigator from \"./detectors/fromNavigator\"\nimport fromSubdomain from \"./detectors/fromSubdomain\"\nimport fromHtmlTag from \"./detectors/fromHtmlTag\"\nimport fromUrl from \"./detectors/fromUrl\"\n\nexport type LocaleString = string\nexport type DetectParamsFunctions = string\n\nfunction detect(...args): LocaleString | null {\n for (let i = 0; i < args.length; i++) {\n const res: LocaleString = typeof args[i] === \"function\" ? args[i]() : args[i]\n if (res) return res\n }\n\n return null\n}\n\nfunction multipleDetect(...args): LocaleString[] {\n const locales = []\n for (let i = 0; i < args.length; i++) {\n const res: LocaleString = typeof args[i] === \"function\" ? args[i]() : args[i]\n if (res) locales.push(res)\n }\n\n return locales\n}\n\nexport {\n detect,\n multipleDetect,\n fromCookie,\n fromHtmlTag,\n fromNavigator,\n fromPath,\n fromStorage,\n fromSubdomain,\n fromUrl,\n}\n"],"names":["getCookie","key","cookies","globalThis","document","cookie","split","jar","i","length","parts","value","slice","join","foundKey","replace","decodeURIComponent","e","detectFromCookie","detectFromPath","localePathIndex","location","locale","pathname","match","Array","isArray","detectFromStorage","options","useSessionStorage","sessionStorage","getItem","localStorage","detectFromNavigator","navigator","result","language","userLanguage","detectFromSubdomain","localeSubdomainIndex","href","detectHtmlTag","htmlTagIdentifier","documentElement","getAttribute","parse","query","parser","part","exec","decode","input","detectFromUrl","parameter","Error","search","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AC,EAAlC,EAAsC;AACpC,IAAA,IAAMkD,GAAiB,GAAG,OAAOD,IAAI,CAACjD,CAAD,CAAX,KAAmB,UAAnB,GAAgCiD,IAAI,CAACjD,CAAD,CAAJ,EAAhC,GAA4CiD,IAAI,CAACjD,CAAD,CAA1E,CAAA;AACA,IAAA,IAAIkD,GAAJ,EAASE,OAAO,CAACC,IAAR,CAAaH,GAAb,CAAA,CAAA;AACV,GAAA;;AAED,EAAA,OAAOE,OAAP,CAAA;AACD;;;;"}
|
|
File without changes
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
declare function detectFromCookie(key: string): LocaleString;
|
|
2
|
+
|
|
3
|
+
declare function detectFromPath(localePathIndex: number, location?: Partial<Location>): LocaleString;
|
|
4
|
+
|
|
5
|
+
declare function detectFromStorage(key: string, options?: {
|
|
6
|
+
useSessionStorage: boolean;
|
|
7
|
+
}): LocaleString;
|
|
8
|
+
|
|
9
|
+
declare type IE11NavigatorLanguage = {
|
|
10
|
+
userLanguage?: string;
|
|
11
|
+
};
|
|
12
|
+
declare function detectFromNavigator(navigator?: Partial<Navigator & IE11NavigatorLanguage>): LocaleString;
|
|
13
|
+
|
|
14
|
+
declare function detectFromSubdomain(localeSubdomainIndex: number, location?: Partial<Location>): LocaleString;
|
|
15
|
+
|
|
16
|
+
declare function detectHtmlTag(htmlTagIdentifier: string, document?: Partial<Document>): LocaleString;
|
|
17
|
+
|
|
18
|
+
declare function detectFromUrl(parameter: string, location?: Partial<Location>): LocaleString;
|
|
19
|
+
|
|
20
|
+
declare type LocaleString = string;
|
|
21
|
+
declare type DetectParamsFunctions = string;
|
|
22
|
+
declare function detect(...args: any[]): LocaleString | null;
|
|
23
|
+
declare function multipleDetect(...args: any[]): LocaleString[];
|
|
24
|
+
|
|
25
|
+
export { DetectParamsFunctions, LocaleString, detect, detectFromCookie as fromCookie, detectHtmlTag as fromHtmlTag, detectFromNavigator as fromNavigator, detectFromPath as fromPath, detectFromStorage as fromStorage, detectFromSubdomain as fromSubdomain, detectFromUrl as fromUrl, multipleDetect };
|
package/build/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require("./cjs/index.js")
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingui/detect-locale",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.16.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"description": "@Lingui package to help you find the correct browser/server locale",
|
|
6
|
-
"main": "index.js",
|
|
7
|
-
"module": "esm/index.js",
|
|
8
|
-
"types": "
|
|
6
|
+
"main": "./build/cjs/index.js",
|
|
7
|
+
"module": "./build/esm/index.js",
|
|
8
|
+
"types": "./build/index.d.ts",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"keywords": [
|
|
11
11
|
"i18n",
|
|
@@ -27,23 +27,22 @@
|
|
|
27
27
|
"url": "https://github.com/lingui/js-lingui/issues"
|
|
28
28
|
},
|
|
29
29
|
"engines": {
|
|
30
|
-
"node": ">=
|
|
30
|
+
"node": ">=14.0.0"
|
|
31
31
|
},
|
|
32
32
|
"exports": {
|
|
33
33
|
".": {
|
|
34
|
-
"require": "./index.js",
|
|
35
|
-
"import": "./esm/index.js"
|
|
34
|
+
"require": "./build/cjs/index.js",
|
|
35
|
+
"import": "./build/esm/index.js"
|
|
36
36
|
},
|
|
37
37
|
"./package.json": "./package.json"
|
|
38
38
|
},
|
|
39
39
|
"files": [
|
|
40
40
|
"LICENSE",
|
|
41
41
|
"README.md",
|
|
42
|
-
"
|
|
43
|
-
"cjs/",
|
|
44
|
-
"esm/"
|
|
42
|
+
"build/"
|
|
45
43
|
],
|
|
46
44
|
"devDependencies": {
|
|
47
45
|
"jsdom": "^16.4.0"
|
|
48
|
-
}
|
|
46
|
+
},
|
|
47
|
+
"gitHead": "e8c1f518b988f45f3f6da84333550b215dcde94b"
|
|
49
48
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"detect-locale.development.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";function e(e){for(var t,o=/([^=?#&]+)=?([^&]*)/g,n={};t=o.exec(e);){var a=r(t[1]),l=r(t[2]);null===a||null===l||a in n||(n[a]=l)}return n}function r(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.detect=function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];for(var o=0;o<r.length;o++){var n="function"==typeof r[o]?r[o]():r[o];if(n)return n}return null},exports.fromCookie=function(e){return function(e){if(e){for(var r=globalThis.document.cookie?globalThis.document.cookie.split("; "):[],t={},o=0;o<r.length;o++){var n=r[o].split("="),a=n.slice(1).join("=");'"'===a[0]&&(a=a.slice(1,-1));try{var l=n[0].replace(/(%[\dA-F]{2})+/gi,decodeURIComponent);if(t[l]=a.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent),e===l)break}catch(e){}}return e?t[e]:t}}(e)},exports.fromHtmlTag=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:globalThis.document;return e?r.documentElement.getAttribute(e):null},exports.fromNavigator=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:globalThis.navigator,r=e.language||e.userLanguage;return r},exports.fromPath=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:globalThis.location,t=r.pathname.match(/\/([a-zA-Z-]*)/g);return Array.isArray(t)?t[e].replace("/",""):null},exports.fromStorage=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{useSessionStorage:!1};return r.useSessionStorage?globalThis.sessionStorage.getItem(e):globalThis.localStorage.getItem(e)},exports.fromSubdomain=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:globalThis.location,t=r.href.match(/(?:http[s]*\:\/\/)*(.*?)\.(?=[^\/]*\..{2,5})/gi);return Array.isArray(t)?t[e].replace("http://","").replace("https://","").replace(".",""):null},exports.fromUrl=function(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:globalThis.location;if(!r)throw new Error("fromUrl parameter is required");var o=e(t.search)[r]||null;return o},exports.multipleDetect=function(){for(var e=[],r=arguments.length,t=new Array(r),o=0;o<r;o++)t[o]=arguments[o];for(var n=0;n<t.length;n++){var a="function"==typeof t[n]?t[n]():t[n];a&&e.push(a)}return e};
|
|
2
|
-
//# sourceMappingURL=detect-locale.production.min.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"detect-locale.production.min.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fromCookie.d.ts","sourceRoot":"","sources":["../packages/detect-locale/src/detectors/fromCookie.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAA;AAGjC,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACtC,GAAG,EAAE,MAAM,GACV,YAAY,CAEd"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fromHtmlTag.d.ts","sourceRoot":"","sources":["../packages/detect-locale/src/detectors/fromHtmlTag.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAA;AAEjC,MAAM,CAAC,OAAO,UAAU,aAAa,CACnC,iBAAiB,EAAE,MAAM,EACzB,QAAQ,GAAE,OAAO,CAAC,QAAQ,CAAuB,GAChD,YAAY,CAMd"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { LocaleString } from "..";
|
|
2
|
-
declare type IE11NavigatorLanguage = {
|
|
3
|
-
userLanguage?: string;
|
|
4
|
-
};
|
|
5
|
-
export default function detectFromNavigator(navigator?: Partial<Navigator & IE11NavigatorLanguage>): LocaleString;
|
|
6
|
-
export {};
|
|
7
|
-
//# sourceMappingURL=fromNavigator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fromNavigator.d.ts","sourceRoot":"","sources":["../packages/detect-locale/src/detectors/fromNavigator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAA;AAEjC,aAAK,qBAAqB,GAAG;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,MAAM,CAAC,OAAO,UAAU,mBAAmB,CACzC,SAAS,GAAE,OAAO,CAAC,SAAS,GAAG,qBAAqB,CAAwB,GAC3E,YAAY,CAId"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fromPath.d.ts","sourceRoot":"","sources":["../packages/detect-locale/src/detectors/fromPath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,KAAK,CAAA;AAElC,MAAM,CAAC,OAAO,UAAU,cAAc,CACpC,eAAe,EAAE,MAAM,EACvB,QAAQ,GAAE,OAAO,CAAC,QAAQ,CAAuB,GAChD,YAAY,CAOd"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fromStorage.d.ts","sourceRoot":"","sources":["../packages/detect-locale/src/detectors/fromStorage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAA;AAEjC,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,GAAG,EAAE,MAAM,EACX,OAAO,GAAE;IAAE,iBAAiB,EAAE,OAAO,CAAA;CAAiC,GACrE,YAAY,CAMd"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fromSubdomain.d.ts","sourceRoot":"","sources":["../packages/detect-locale/src/detectors/fromSubdomain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,KAAK,CAAA;AAElC,MAAM,CAAC,OAAO,UAAU,mBAAmB,CACzC,oBAAoB,EAAE,MAAM,EAC5B,QAAQ,GAAE,OAAO,CAAC,QAAQ,CAAuB,GAChD,YAAY,CAUd"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fromUrl.d.ts","sourceRoot":"","sources":["../packages/detect-locale/src/detectors/fromUrl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAElC,MAAM,CAAC,OAAO,UAAU,aAAa,CACnC,SAAS,EAAE,MAAM,EACjB,QAAQ,GAAE,OAAO,CAAC,QAAQ,CAAuB,GAChD,YAAY,CAKd"}
|
package/cjs/index.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import "./utils/globalThis.polyfill.js";
|
|
2
|
-
import fromCookie from "./detectors/fromCookie";
|
|
3
|
-
import fromPath from "./detectors/fromPath";
|
|
4
|
-
import fromStorage from "./detectors/fromStorage";
|
|
5
|
-
import fromNavigator from "./detectors/fromNavigator";
|
|
6
|
-
import fromSubdomain from "./detectors/fromSubdomain";
|
|
7
|
-
import fromHtmlTag from "./detectors/fromHtmlTag";
|
|
8
|
-
import fromUrl from "./detectors/fromUrl";
|
|
9
|
-
export declare type LocaleString = string;
|
|
10
|
-
export declare type DetectParamsFunctions = string;
|
|
11
|
-
declare function detect(...args: any[]): LocaleString | null;
|
|
12
|
-
declare function multipleDetect(...args: any[]): LocaleString[];
|
|
13
|
-
export { detect, multipleDetect, fromCookie, fromHtmlTag, fromNavigator, fromPath, fromStorage, fromSubdomain, fromUrl, };
|
|
14
|
-
//# sourceMappingURL=index.d.ts.map
|
package/cjs/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["packages/detect-locale/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAA;AACvC,OAAO,UAAU,MAAM,wBAAwB,CAAA;AAC/C,OAAO,QAAQ,MAAM,sBAAsB,CAAA;AAC3C,OAAO,WAAW,MAAM,yBAAyB,CAAA;AACjD,OAAO,aAAa,MAAM,2BAA2B,CAAA;AACrD,OAAO,aAAa,MAAM,2BAA2B,CAAA;AACrD,OAAO,WAAW,MAAM,yBAAyB,CAAA;AACjD,OAAO,OAAO,MAAM,qBAAqB,CAAA;AAEzC,oBAAY,YAAY,GAAG,MAAM,CAAA;AACjC,oBAAY,qBAAqB,GAAG,MAAM,CAAA;AAE1C,iBAAS,MAAM,CAAC,GAAG,IAAI,OAAA,GAAG,YAAY,GAAG,IAAI,CAO5C;AAED,iBAAS,cAAc,CAAC,GAAG,IAAI,OAAA,GAAG,YAAY,EAAE,CAQ/C;AAED,OAAO,EACL,MAAM,EACN,cAAc,EACd,UAAU,EACV,WAAW,EACX,aAAa,EACb,QAAQ,EACR,WAAW,EACX,aAAa,EACb,OAAO,GACR,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cookie-getter.d.ts","sourceRoot":"","sources":["../packages/detect-locale/src/utils/cookie-getter.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CA4B7C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"query-string.d.ts","sourceRoot":"","sources":["../packages/detect-locale/src/utils/query-string.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,KAAK,KAAA,MAsB1B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"detect-locale.development.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
function r(r){return function(r){if(r){for(var e=globalThis.document.cookie?globalThis.document.cookie.split("; "):[],n={},t=0;t<e.length;t++){var o=e[t].split("="),a=o.slice(1).join("=");'"'===a[0]&&(a=a.slice(1,-1));try{var l=o[0].replace(/(%[\dA-F]{2})+/gi,decodeURIComponent);if(n[l]=a.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent),r===l)break}catch(r){}}return r?n[r]:n}}(r)}function e(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:globalThis.location,n=e.pathname.match(/\/([a-zA-Z-]*)/g);return Array.isArray(n)?n[r].replace("/",""):null}function n(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{useSessionStorage:!1};return e.useSessionStorage?globalThis.sessionStorage.getItem(r):globalThis.localStorage.getItem(r)}function t(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:globalThis.navigator,e=r.language||r.userLanguage;return e}function o(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:globalThis.location,n=e.href.match(/(?:http[s]*\:\/\/)*(.*?)\.(?=[^\/]*\..{2,5})/gi);return Array.isArray(n)?n[r].replace("http://","").replace("https://","").replace(".",""):null}function a(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:globalThis.document;return r?e.documentElement.getAttribute(r):null}function l(r){for(var e,n=/([^=?#&]+)=?([^&]*)/g,t={};e=n.exec(r);){var o=i(e[1]),a=i(e[2]);null===o||null===a||o in t||(t[o]=a)}return t}function i(r){try{return decodeURIComponent(r.replace(/\+/g," "))}catch(r){return null}}function u(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:globalThis.location;if(!r)throw new Error("fromUrl parameter is required");var n=l(e.search)[r]||null;return n}function c(){for(var r=arguments.length,e=new Array(r),n=0;n<r;n++)e[n]=arguments[n];for(var t=0;t<e.length;t++){var o="function"==typeof e[t]?e[t]():e[t];if(o)return o}return null}function g(){for(var r=[],e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];for(var o=0;o<n.length;o++){var a="function"==typeof n[o]?n[o]():n[o];a&&r.push(a)}return r}export{c as detect,r as fromCookie,a as fromHtmlTag,t as fromNavigator,e as fromPath,n as fromStorage,o as fromSubdomain,u as fromUrl,g as multipleDetect};
|
|
2
|
-
//# sourceMappingURL=detect-locale.production.min.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"detect-locale.production.min.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fromCookie.d.ts","sourceRoot":"","sources":["../packages/detect-locale/src/detectors/fromCookie.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAA;AAGjC,MAAM,CAAC,OAAO,UAAU,gBAAgB,CACtC,GAAG,EAAE,MAAM,GACV,YAAY,CAEd"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fromHtmlTag.d.ts","sourceRoot":"","sources":["../packages/detect-locale/src/detectors/fromHtmlTag.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAA;AAEjC,MAAM,CAAC,OAAO,UAAU,aAAa,CACnC,iBAAiB,EAAE,MAAM,EACzB,QAAQ,GAAE,OAAO,CAAC,QAAQ,CAAuB,GAChD,YAAY,CAMd"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { LocaleString } from "..";
|
|
2
|
-
declare type IE11NavigatorLanguage = {
|
|
3
|
-
userLanguage?: string;
|
|
4
|
-
};
|
|
5
|
-
export default function detectFromNavigator(navigator?: Partial<Navigator & IE11NavigatorLanguage>): LocaleString;
|
|
6
|
-
export {};
|
|
7
|
-
//# sourceMappingURL=fromNavigator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fromNavigator.d.ts","sourceRoot":"","sources":["../packages/detect-locale/src/detectors/fromNavigator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAA;AAEjC,aAAK,qBAAqB,GAAG;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,MAAM,CAAC,OAAO,UAAU,mBAAmB,CACzC,SAAS,GAAE,OAAO,CAAC,SAAS,GAAG,qBAAqB,CAAwB,GAC3E,YAAY,CAId"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fromPath.d.ts","sourceRoot":"","sources":["../packages/detect-locale/src/detectors/fromPath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,KAAK,CAAA;AAElC,MAAM,CAAC,OAAO,UAAU,cAAc,CACpC,eAAe,EAAE,MAAM,EACvB,QAAQ,GAAE,OAAO,CAAC,QAAQ,CAAuB,GAChD,YAAY,CAOd"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fromStorage.d.ts","sourceRoot":"","sources":["../packages/detect-locale/src/detectors/fromStorage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAA;AAEjC,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,GAAG,EAAE,MAAM,EACX,OAAO,GAAE;IAAE,iBAAiB,EAAE,OAAO,CAAA;CAAiC,GACrE,YAAY,CAMd"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fromSubdomain.d.ts","sourceRoot":"","sources":["../packages/detect-locale/src/detectors/fromSubdomain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,KAAK,CAAA;AAElC,MAAM,CAAC,OAAO,UAAU,mBAAmB,CACzC,oBAAoB,EAAE,MAAM,EAC5B,QAAQ,GAAE,OAAO,CAAC,QAAQ,CAAuB,GAChD,YAAY,CAUd"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fromUrl.d.ts","sourceRoot":"","sources":["../packages/detect-locale/src/detectors/fromUrl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAElC,MAAM,CAAC,OAAO,UAAU,aAAa,CACnC,SAAS,EAAE,MAAM,EACjB,QAAQ,GAAE,OAAO,CAAC,QAAQ,CAAuB,GAChD,YAAY,CAKd"}
|
package/esm/index.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import "./utils/globalThis.polyfill.js";
|
|
2
|
-
import fromCookie from "./detectors/fromCookie";
|
|
3
|
-
import fromPath from "./detectors/fromPath";
|
|
4
|
-
import fromStorage from "./detectors/fromStorage";
|
|
5
|
-
import fromNavigator from "./detectors/fromNavigator";
|
|
6
|
-
import fromSubdomain from "./detectors/fromSubdomain";
|
|
7
|
-
import fromHtmlTag from "./detectors/fromHtmlTag";
|
|
8
|
-
import fromUrl from "./detectors/fromUrl";
|
|
9
|
-
export declare type LocaleString = string;
|
|
10
|
-
export declare type DetectParamsFunctions = string;
|
|
11
|
-
declare function detect(...args: any[]): LocaleString | null;
|
|
12
|
-
declare function multipleDetect(...args: any[]): LocaleString[];
|
|
13
|
-
export { detect, multipleDetect, fromCookie, fromHtmlTag, fromNavigator, fromPath, fromStorage, fromSubdomain, fromUrl, };
|
|
14
|
-
//# sourceMappingURL=index.d.ts.map
|
package/esm/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["packages/detect-locale/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAA;AACvC,OAAO,UAAU,MAAM,wBAAwB,CAAA;AAC/C,OAAO,QAAQ,MAAM,sBAAsB,CAAA;AAC3C,OAAO,WAAW,MAAM,yBAAyB,CAAA;AACjD,OAAO,aAAa,MAAM,2BAA2B,CAAA;AACrD,OAAO,aAAa,MAAM,2BAA2B,CAAA;AACrD,OAAO,WAAW,MAAM,yBAAyB,CAAA;AACjD,OAAO,OAAO,MAAM,qBAAqB,CAAA;AAEzC,oBAAY,YAAY,GAAG,MAAM,CAAA;AACjC,oBAAY,qBAAqB,GAAG,MAAM,CAAA;AAE1C,iBAAS,MAAM,CAAC,GAAG,IAAI,OAAA,GAAG,YAAY,GAAG,IAAI,CAO5C;AAED,iBAAS,cAAc,CAAC,GAAG,IAAI,OAAA,GAAG,YAAY,EAAE,CAQ/C;AAED,OAAO,EACL,MAAM,EACN,cAAc,EACd,UAAU,EACV,WAAW,EACX,aAAa,EACb,QAAQ,EACR,WAAW,EACX,aAAa,EACb,OAAO,GACR,CAAA"}
|
package/esm/index.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
detect as detectDev,
|
|
3
|
-
fromCookie as fromCookieDev,
|
|
4
|
-
fromHtmlTag as fromHtmlTagDev,
|
|
5
|
-
fromNavigator as fromNavigatorDev,
|
|
6
|
-
fromPath as fromPathDev,
|
|
7
|
-
fromStorage as fromStorageDev,
|
|
8
|
-
fromSubdomain as fromSubdomainDev,
|
|
9
|
-
fromUrl as fromUrlDev,
|
|
10
|
-
multipleDetect as multipleDetectDev,
|
|
11
|
-
} from "./detect-locale.development.js"
|
|
12
|
-
|
|
13
|
-
import {
|
|
14
|
-
detect as detectProd,
|
|
15
|
-
fromCookie as fromCookieProd,
|
|
16
|
-
fromHtmlTag as fromHtmlTagProd,
|
|
17
|
-
fromNavigator as fromNavigatorProd,
|
|
18
|
-
fromPath as fromPathProd,
|
|
19
|
-
fromStorage as fromStorageProd,
|
|
20
|
-
fromSubdomain as fromSubdomainProd,
|
|
21
|
-
fromUrl as fromUrlProd,
|
|
22
|
-
multipleDetect as multipleDetectProd,
|
|
23
|
-
} from "./detect-locale.production.min.js"
|
|
24
|
-
|
|
25
|
-
export const detect = process.env.NODE_ENV === "production" ? detectProd : detectDev;
|
|
26
|
-
export const fromCookie = process.env.NODE_ENV === "production" ? fromCookieProd : fromCookieDev;
|
|
27
|
-
export const fromHtmlTag = process.env.NODE_ENV === "production" ? fromHtmlTagProd : fromHtmlTagDev;
|
|
28
|
-
export const fromNavigator = process.env.NODE_ENV === "production" ? fromNavigatorProd : fromNavigatorDev;
|
|
29
|
-
export const fromPath = process.env.NODE_ENV === "production" ? fromPathProd : fromPathDev;
|
|
30
|
-
export const fromStorage = process.env.NODE_ENV === "production" ? fromStorageProd : fromStorageDev;
|
|
31
|
-
export const fromSubdomain = process.env.NODE_ENV === "production" ? fromSubdomainProd : fromSubdomainDev;
|
|
32
|
-
export const fromUrl = process.env.NODE_ENV === "production" ? fromUrlProd : fromUrlDev;
|
|
33
|
-
export const multipleDetect = process.env.NODE_ENV === "production" ? multipleDetectProd : multipleDetectDev;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cookie-getter.d.ts","sourceRoot":"","sources":["../packages/detect-locale/src/utils/cookie-getter.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CA4B7C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"query-string.d.ts","sourceRoot":"","sources":["../packages/detect-locale/src/utils/query-string.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,KAAK,KAAA,MAsB1B"}
|