@prosopo/locale 3.6.1 → 3.7.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/.turbo/turbo-build$colon$cjs.log +8 -9
- package/.turbo/turbo-build$colon$tsc.log +6 -9
- package/.turbo/turbo-build.log +12 -16
- package/CHANGELOG.md +40 -0
- package/LICENSE +201 -0
- package/dist/cjs/direction.cjs +19 -0
- package/dist/cjs/errorMessage.cjs +15 -0
- package/dist/cjs/index.cjs +5 -0
- package/dist/cjs/locales/en/translation.cjs +23 -5
- package/dist/cjs/translationKey.cjs +4 -0
- package/dist/direction.d.ts +3 -0
- package/dist/direction.d.ts.map +1 -0
- package/dist/direction.js +19 -0
- package/dist/direction.js.map +1 -0
- package/dist/errorMessage.d.ts +7 -0
- package/dist/errorMessage.d.ts.map +1 -0
- package/dist/errorMessage.js +15 -0
- package/dist/errorMessage.js.map +1 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/locales/ar/translation.json +23 -5
- package/dist/locales/az/translation.json +23 -5
- package/dist/locales/cs/translation.json +23 -5
- package/dist/locales/de/translation.json +23 -5
- package/dist/locales/el/translation.json +23 -5
- package/dist/locales/en/translation.js +23 -5
- package/dist/locales/en/translation.json +23 -5
- package/dist/locales/es/translation.json +23 -5
- package/dist/locales/fi/translation.json +23 -5
- package/dist/locales/fr/translation.json +23 -5
- package/dist/locales/hi/translation.json +23 -5
- package/dist/locales/hu/translation.json +23 -5
- package/dist/locales/id/translation.json +23 -5
- package/dist/locales/it/translation.json +23 -5
- package/dist/locales/ja/translation.json +23 -5
- package/dist/locales/jv/translation.json +23 -5
- package/dist/locales/ko/translation.json +23 -5
- package/dist/locales/ml/translation.json +23 -5
- package/dist/locales/ms/translation.json +23 -5
- package/dist/locales/nl/translation.json +23 -5
- package/dist/locales/no/translation.json +23 -5
- package/dist/locales/pl/translation.json +23 -5
- package/dist/locales/pt/translation.json +23 -5
- package/dist/locales/pt-BR/translation.json +23 -5
- package/dist/locales/ro/translation.json +23 -5
- package/dist/locales/ru/translation.json +23 -5
- package/dist/locales/sr/translation.json +23 -5
- package/dist/locales/sv/translation.json +23 -5
- package/dist/locales/th/translation.json +23 -5
- package/dist/locales/tr/translation.json +23 -5
- package/dist/locales/uk/translation.json +23 -5
- package/dist/locales/vi/translation.json +23 -5
- package/dist/locales/zh-CN/translation.json +23 -5
- package/dist/tests/direction.unit.test.d.ts +2 -0
- package/dist/tests/direction.unit.test.d.ts.map +1 -0
- package/dist/tests/direction.unit.test.js +31 -0
- package/dist/tests/direction.unit.test.js.map +1 -0
- package/dist/tests/errorMessage.unit.test.d.ts +2 -0
- package/dist/tests/errorMessage.unit.test.d.ts.map +1 -0
- package/dist/tests/errorMessage.unit.test.js +49 -0
- package/dist/tests/errorMessage.unit.test.js.map +1 -0
- package/dist/tests/i18nFrontend.unit.test.js +22 -11
- package/dist/tests/i18nFrontend.unit.test.js.map +1 -1
- package/dist/tests/locale.test-d.js +18 -3
- package/dist/tests/locale.test-d.js.map +1 -1
- package/dist/tests/thrownErrorKeys.unit.test.d.ts +2 -0
- package/dist/tests/thrownErrorKeys.unit.test.d.ts.map +1 -0
- package/dist/tests/thrownErrorKeys.unit.test.js +59 -0
- package/dist/tests/thrownErrorKeys.unit.test.js.map +1 -0
- package/dist/tests/translationKey.unit.test.js +13 -1
- package/dist/tests/translationKey.unit.test.js.map +1 -1
- package/dist/translationKey.d.ts +7 -1
- package/dist/translationKey.d.ts.map +1 -1
- package/dist/translationKey.js +4 -1
- package/dist/translationKey.js.map +1 -1
- package/dist/translator.d.ts +2 -1
- package/dist/translator.d.ts.map +1 -1
- package/dist/translator.js.map +1 -1
- package/dist/types.d.ts +2 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +65 -66
- package/src/i18SharedOptions.ts +0 -29
- package/src/i18nBackend.ts +0 -69
- package/src/i18nFrontend.ts +0 -267
- package/src/i18nMiddleware.ts +0 -35
- package/src/index.ts +0 -29
- package/src/loadI18next.ts +0 -136
- package/src/locales/ar/translation.json +0 -476
- package/src/locales/az/translation.json +0 -476
- package/src/locales/cs/translation.json +0 -476
- package/src/locales/de/translation.json +0 -476
- package/src/locales/el/translation.json +0 -476
- package/src/locales/en/translation.json +0 -476
- package/src/locales/es/translation.json +0 -476
- package/src/locales/fi/translation.json +0 -476
- package/src/locales/fr/translation.json +0 -476
- package/src/locales/hi/translation.json +0 -476
- package/src/locales/hu/translation.json +0 -476
- package/src/locales/id/translation.json +0 -476
- package/src/locales/it/translation.json +0 -476
- package/src/locales/ja/translation.json +0 -476
- package/src/locales/jv/translation.json +0 -476
- package/src/locales/ko/translation.json +0 -476
- package/src/locales/ml/translation.json +0 -476
- package/src/locales/ms/translation.json +0 -476
- package/src/locales/nl/translation.json +0 -476
- package/src/locales/no/translation.json +0 -476
- package/src/locales/pl/translation.json +0 -476
- package/src/locales/pt/translation.json +0 -476
- package/src/locales/pt-BR/translation.json +0 -476
- package/src/locales/ro/translation.json +0 -476
- package/src/locales/ru/translation.json +0 -476
- package/src/locales/sr/translation.json +0 -476
- package/src/locales/sv/translation.json +0 -476
- package/src/locales/th/translation.json +0 -476
- package/src/locales/tr/translation.json +0 -476
- package/src/locales/uk/translation.json +0 -476
- package/src/locales/vi/translation.json +0 -476
- package/src/locales/zh-CN/translation.json +0 -476
- package/src/process.ts +0 -29
- package/src/tests/i18SharedOptions.unit.test.ts +0 -139
- package/src/tests/i18nBackend.unit.test.ts +0 -241
- package/src/tests/i18nFrontend.unit.test.ts +0 -393
- package/src/tests/i18nMiddleware.unit.test.ts +0 -159
- package/src/tests/loadI18next.unit.test.ts +0 -443
- package/src/tests/locale.test-d.ts +0 -160
- package/src/tests/localePlaceholders.unit.test.ts +0 -81
- package/src/tests/locales.unit.test.ts +0 -79
- package/src/tests/process.unit.test.ts +0 -33
- package/src/tests/translationKey.unit.test.ts +0 -140
- package/src/tests/translations.unit.test.ts +0 -97
- package/src/tests/translator.unit.test.ts +0 -213
- package/src/tests/util.unit.test.ts +0 -102
- package/src/translationKey.ts +0 -64
- package/src/translations.ts +0 -55
- package/src/translator.ts +0 -68
- package/src/types.ts +0 -42
- package/src/util.ts +0 -25
- package/tsconfig.cjs.json +0 -21
- package/tsconfig.json +0 -22
- package/tsconfig.tsbuildinfo +0 -1
- package/tsconfig.types.json +0 -9
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
> @prosopo/locale@3.6.1 build:cjs
|
|
3
|
-
> NODE_ENV=${NODE_ENV:-development}; vite build --config vite.cjs.config.ts --mode $NODE_ENV
|
|
4
|
-
|
|
1
|
+
$ NODE_ENV=${NODE_ENV:-development}; vite build --config vite.cjs.config.ts --mode $NODE_ENV
|
|
5
2
|
ViteCommonJSConfig: .
|
|
6
3
|
{
|
|
7
4
|
tsConfigPaths: [ '/home/runner/work/captcha/captcha/packages/util/tsconfig.json' ]
|
|
@@ -11,24 +8,26 @@ ViteCommonJSConfig: .
|
|
|
11
8
|
[36mvite v8.1.5 [32mbuilding ssr environment for production...[36m[39m
|
|
12
9
|
Bundle build started
|
|
13
10
|
[2K
|
|
14
|
-
✓
|
|
11
|
+
✓ 15 modules transformed.
|
|
15
12
|
rendering chunks...
|
|
16
13
|
computing gzip size...
|
|
17
14
|
dist/cjs/util.cjs 0.28 kB │ gzip: 0.17 kB
|
|
15
|
+
dist/cjs/direction.cjs 0.37 kB │ gzip: 0.25 kB
|
|
18
16
|
dist/cjs/i18SharedOptions.cjs 0.39 kB │ gzip: 0.24 kB
|
|
19
17
|
dist/cjs/i18nMiddleware.cjs 0.51 kB │ gzip: 0.26 kB
|
|
20
|
-
dist/cjs/
|
|
18
|
+
dist/cjs/errorMessage.cjs 0.70 kB │ gzip: 0.40 kB
|
|
21
19
|
dist/cjs/process.cjs 0.78 kB │ gzip: 0.46 kB
|
|
22
20
|
dist/cjs/translations.cjs 0.80 kB │ gzip: 0.40 kB
|
|
23
21
|
dist/cjs/translator.cjs 0.83 kB │ gzip: 0.45 kB
|
|
24
|
-
dist/cjs/
|
|
22
|
+
dist/cjs/translationKey.cjs 0.91 kB │ gzip: 0.44 kB
|
|
25
23
|
dist/cjs/_virtual/_rolldown/runtime.cjs 1.00 kB │ gzip: 0.50 kB
|
|
24
|
+
dist/cjs/index.cjs 1.20 kB │ gzip: 0.34 kB
|
|
26
25
|
dist/cjs/i18nBackend.cjs 1.47 kB │ gzip: 0.62 kB
|
|
27
26
|
dist/cjs/loadI18next.cjs 2.03 kB │ gzip: 0.84 kB
|
|
28
27
|
dist/cjs/i18nFrontend.cjs 6.07 kB │ gzip: 2.44 kB
|
|
29
|
-
dist/cjs/locales/en/translation.cjs
|
|
28
|
+
dist/cjs/locales/en/translation.cjs 17.51 kB │ gzip: 6.27 kB
|
|
30
29
|
|
|
31
|
-
[32m✓ built in
|
|
30
|
+
[32m✓ built in 88ms[39m
|
|
32
31
|
[copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/ar/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/ar/translation.json
|
|
33
32
|
[copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/az/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/az/translation.json
|
|
34
33
|
[copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/cs/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/cs/translation.json
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
> tsc --build --verbose
|
|
4
|
-
|
|
5
|
-
9:56:01 AM - Projects in this build:
|
|
1
|
+
$ tsc --build --verbose
|
|
2
|
+
1:37:21 PM - Projects in this build:
|
|
6
3
|
* ../../dev/config/tsconfig.json
|
|
7
4
|
* ../util/tsconfig.json
|
|
8
5
|
* tsconfig.json
|
|
9
6
|
|
|
10
|
-
|
|
7
|
+
1:37:21 PM - Project '../../dev/config/tsconfig.json' is up to date because newest input '../../dev/config/src/webpack/webpack.config.ts' is older than output '../../dev/config/tsconfig.tsbuildinfo'
|
|
11
8
|
|
|
12
|
-
|
|
9
|
+
1:37:21 PM - Project '../util/tsconfig.json' is up to date because newest input '../util/src/url.ts' is older than output '../util/tsconfig.tsbuildinfo'
|
|
13
10
|
|
|
14
|
-
|
|
11
|
+
1:37:21 PM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
|
|
15
12
|
|
|
16
|
-
|
|
13
|
+
1:37:21 PM - Building project '/home/runner/work/captcha/captcha/packages/locale/tsconfig.json'...
|
|
17
14
|
|
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
> npm run build:cross-env -- --mode ${NODE_ENV:-development}
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
> @prosopo/locale@3.6.1 build:cross-env
|
|
7
|
-
> vite build --config vite.esm.config.ts --mode production
|
|
8
|
-
|
|
1
|
+
$ pnpm run build:cross-env --mode ${NODE_ENV:-development}
|
|
2
|
+
$ vite build --config vite.esm.config.ts --mode production
|
|
9
3
|
ViteEsmConfig: .
|
|
10
4
|
{
|
|
11
5
|
tsConfigPaths: [ '/home/runner/work/captcha/captcha/packages/util/tsconfig.json' ]
|
|
@@ -15,33 +9,35 @@ ViteEsmConfig: .
|
|
|
15
9
|
[36mvite v8.1.5 [32mbuilding ssr environment for production...[36m[39m
|
|
16
10
|
Bundle build started
|
|
17
11
|
[2K
|
|
18
|
-
✓
|
|
12
|
+
✓ 15 modules transformed.
|
|
19
13
|
rendering chunks...
|
|
20
14
|
computing gzip size...
|
|
21
15
|
dist/_virtual/_rolldown/runtime.js 0.04 kB │ gzip: 0.06 kB
|
|
22
16
|
dist/util.js 0.25 kB │ gzip: 0.16 kB
|
|
23
17
|
dist/i18nMiddleware.js 0.31 kB │ gzip: 0.19 kB
|
|
18
|
+
dist/direction.js 0.35 kB │ gzip: 0.25 kB
|
|
24
19
|
dist/i18SharedOptions.js 0.35 kB │ gzip: 0.24 kB
|
|
25
|
-
dist/
|
|
26
|
-
dist/
|
|
20
|
+
dist/errorMessage.js 0.65 kB │ gzip: 0.39 kB
|
|
21
|
+
dist/index.js 0.67 kB │ gzip: 0.25 kB
|
|
27
22
|
dist/translations.js 0.74 kB │ gzip: 0.40 kB
|
|
28
23
|
dist/process.js 0.77 kB │ gzip: 0.46 kB
|
|
29
24
|
dist/translator.js 0.79 kB │ gzip: 0.44 kB
|
|
25
|
+
dist/translationKey.js 0.83 kB │ gzip: 0.43 kB
|
|
30
26
|
dist/i18nBackend.js 1.01 kB │ gzip: 0.53 kB
|
|
31
27
|
dist/loadI18next.js 1.93 kB │ gzip: 0.83 kB
|
|
32
28
|
dist/i18nFrontend.js 5.98 kB │ gzip: 2.42 kB
|
|
33
|
-
dist/locales/en/translation.js
|
|
29
|
+
dist/locales/en/translation.js 17.27 kB │ gzip: 6.24 kB
|
|
34
30
|
|
|
35
|
-
[32m✓ built in
|
|
36
|
-
[copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/az/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/az/translation.json
|
|
31
|
+
[32m✓ built in 32ms[39m
|
|
37
32
|
[copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/ar/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/ar/translation.json
|
|
33
|
+
[copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/az/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/az/translation.json
|
|
38
34
|
[copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/cs/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/cs/translation.json
|
|
39
35
|
[copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/de/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/de/translation.json
|
|
40
36
|
[copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/el/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/el/translation.json
|
|
41
37
|
[copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/en/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/en/translation.json
|
|
42
38
|
[copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/es/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/es/translation.json
|
|
43
|
-
[copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/fr/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/fr/translation.json
|
|
44
39
|
[copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/fi/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/fi/translation.json
|
|
40
|
+
[copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/fr/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/fr/translation.json
|
|
45
41
|
[copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/hi/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/hi/translation.json
|
|
46
42
|
[copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/hu/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/hu/translation.json
|
|
47
43
|
[copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/id/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/id/translation.json
|
|
@@ -53,8 +49,8 @@ dist/locales/en/translation.js 16.41 kB │ gzip: 5.97 kB
|
|
|
53
49
|
[copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/ms/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/ms/translation.json
|
|
54
50
|
[copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/nl/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/nl/translation.json
|
|
55
51
|
[copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/no/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/no/translation.json
|
|
56
|
-
[copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/pl/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/pl/translation.json
|
|
57
52
|
[copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/pt/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/pt/translation.json
|
|
53
|
+
[copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/pl/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/pl/translation.json
|
|
58
54
|
[copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/pt-BR/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/pt-BR/translation.json
|
|
59
55
|
[copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/ro/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/ro/translation.json
|
|
60
56
|
[copy-plugin] copying /home/runner/work/captcha/captcha/packages/locale/src/locales/ru/translation.json to /home/runner/work/captcha/captcha/packages/locale/dist/locales/ru/translation.json
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,45 @@
|
|
|
1
1
|
# @prosopo/locale
|
|
2
2
|
|
|
3
|
+
## 3.7.0
|
|
4
|
+
### Minor Changes
|
|
5
|
+
|
|
6
|
+
- dcb691b: Add a refresh control to the puzzle captcha.
|
|
7
|
+
|
|
8
|
+
A user who can't solve the puzzle they were given can now ask for a different one, from a button in the puzzle's header. The replacement comes through a new frictionless session, like a wrong answer already does.
|
|
9
|
+
|
|
10
|
+
The widget tells the provider which session was refreshed (`refreshOf`). The provider then records `refreshOf`, `refreshCount` and `refreshedAfterMs` on the new session, so refresh behaviour can be scored later. After three refreshes in a row it serves an image challenge instead, with reason `PUZZLE_REFRESH_LIMIT`. It only does this if the site has image enabled. The switch only goes from puzzle to image, so a client that lies about its refreshes can only make its own challenge harder. A client that leaves the field out gets a normal session, the same as reloading the page.
|
|
11
|
+
|
|
12
|
+
The image widget's reload button now reports itself as a refresh too. That way a user who was moved onto image isn't sent back to the puzzle by their next reload.
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [a17e8eb]
|
|
17
|
+
- @prosopo/util@3.3.14
|
|
18
|
+
|
|
19
|
+
## 3.6.2
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- 8ed0eb8: Every error key the code throws now has a translation. Twelve keys were missing from the catalogue, so users and logs saw the raw key: ten thrown keys plus the `CAPTCHA.INVALID_TIMESTAMP` and `CAPTCHA.DECISION_MACHINE_DENIED` result reasons. They are added to all 32 locales. The database import error threw `DATABASE.DATABASE_IMPORT_ERROR`, a typo for the existing `DATABASE.DATABASE_IMPORT_FAILED`. A new test fails if an error is thrown with a key that is not in the catalogue.
|
|
23
|
+
- 06784d0: Translation keys are now a typed union built from the English catalogue, so calling the translator with a key that does not exist fails to compile. Error classes only pass a message to the translator when it is a real catalogue key, and free-text messages are shown as they are.
|
|
24
|
+
- 4461043: Widget accessibility fixes.
|
|
25
|
+
|
|
26
|
+
- Screen readers now announce the checkbox's error message, through a polite live region that exists from the moment the widget mounts.
|
|
27
|
+
- The authenticated ("Verified agent" / "Trusted request") badge now follows `theme: "dark"` and the widget's language.
|
|
28
|
+
- The badge no longer carries a fixed `aria-label`, which hid its visible text and said "Verified agent" even for a trusted request.
|
|
29
|
+
- 92edebd: The widget's loading spinner and the reload icon no longer announce hard-coded English. The spinner is a progress indicator labelled from the new `WIDGET.LOADING` string (in all 32 languages) once translations are loaded, and the reload icon's tooltip uses the same translated label as the button.
|
|
30
|
+
- 54a07f3: Provider errors shown in the widget now use the widget's configured language. The provider translates errors into the browser's language, so a German widget in an English browser showed English errors. The widget now translates the error key itself and keeps the provider's text only for errors its catalogue does not know.
|
|
31
|
+
- b75e9b7: Fix the error FAQ link and translate two widget strings.
|
|
32
|
+
|
|
33
|
+
- The error FAQ link no longer ends in `//` when `PROSOPO_DOCS_URL` is set, and a trailing slash on that variable no longer breaks it.
|
|
34
|
+
- The "Cannot load CAPTCHA" fallback message now shows in the widget's language.
|
|
35
|
+
- The image challenge's reload button now has a translated accessible name instead of always being "Reload".
|
|
36
|
+
- Adds `WIDGET.CANNOT_LOAD` and `WIDGET.RELOAD` to every locale.
|
|
37
|
+
- 6d5b7f5: The widget now lays itself out right to left when its language is written right to left (Arabic today). The bundle sets `dir` on the widget from its language, and the checkbox, spinner and logo use start/end spacing so they mirror. The widget still ignores the page's own direction, so an English widget on an Arabic page stays left to right. `@prosopo/locale` gains `getLanguageDirection` for this.
|
|
38
|
+
- Updated dependencies [de6bb08]
|
|
39
|
+
- Updated dependencies [8d7ba8c]
|
|
40
|
+
- Updated dependencies [995e954]
|
|
41
|
+
- @prosopo/util@3.3.13
|
|
42
|
+
|
|
3
43
|
## 3.6.1
|
|
4
44
|
### Patch Changes
|
|
5
45
|
|
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2022 PROSOPO LIMITED
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/direction.ts
|
|
2
|
+
var RTL_LANGUAGES = /* @__PURE__ */ new Set([
|
|
3
|
+
"ar",
|
|
4
|
+
"ckb",
|
|
5
|
+
"dv",
|
|
6
|
+
"fa",
|
|
7
|
+
"he",
|
|
8
|
+
"ps",
|
|
9
|
+
"sd",
|
|
10
|
+
"ug",
|
|
11
|
+
"ur",
|
|
12
|
+
"yi"
|
|
13
|
+
]);
|
|
14
|
+
var getLanguageDirection = (language) => {
|
|
15
|
+
const primary = language.split(/[-_]/)[0]?.toLowerCase() ?? "";
|
|
16
|
+
return RTL_LANGUAGES.has(primary) ? "rtl" : "ltr";
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
exports.getLanguageDirection = getLanguageDirection;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const require_translationKey = require("./translationKey.cjs");
|
|
2
|
+
//#region src/errorMessage.ts
|
|
3
|
+
/**
|
|
4
|
+
* The provider translates error messages into the request's Accept-Language,
|
|
5
|
+
* which is the browser's language rather than the widget's. Re-translating the
|
|
6
|
+
* error key on the client shows the error in the language the widget renders
|
|
7
|
+
* in. Free text and keys the catalogue doesn't have keep the server's message.
|
|
8
|
+
*/
|
|
9
|
+
var localiseErrorMessage = (i18n, error) => {
|
|
10
|
+
const { key, message } = error;
|
|
11
|
+
if (!key || !require_translationKey.isTranslationKey(key) || !i18n?.isInitialized) return message;
|
|
12
|
+
return i18n.t(key, { defaultValue: message });
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
exports.localiseErrorMessage = localiseErrorMessage;
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_direction = require("./direction.cjs");
|
|
2
3
|
const require_loadI18next = require("./loadI18next.cjs");
|
|
3
4
|
const require_i18nMiddleware = require("./i18nMiddleware.cjs");
|
|
4
5
|
const require_translations = require("./translations.cjs");
|
|
5
6
|
const require_util = require("./util.cjs");
|
|
6
7
|
const require_translationKey = require("./translationKey.cjs");
|
|
7
8
|
const require_translator = require("./translator.cjs");
|
|
9
|
+
const require_errorMessage = require("./errorMessage.cjs");
|
|
8
10
|
exports.LanguageCodes = require_translations.LanguageCodes;
|
|
9
11
|
exports.Languages = require_translations.Languages;
|
|
10
12
|
exports.createTranslator = require_translator.createTranslator;
|
|
13
|
+
exports.getLanguageDirection = require_direction.getLanguageDirection;
|
|
11
14
|
exports.i18nMiddleware = require_i18nMiddleware.default;
|
|
12
15
|
exports.isClientSide = require_util.isClientSide;
|
|
13
16
|
exports.isLanguage = require_translations.isLanguage;
|
|
17
|
+
exports.isTranslationKey = require_translationKey.isTranslationKey;
|
|
14
18
|
exports.loadI18next = require_loadI18next.default;
|
|
19
|
+
exports.localiseErrorMessage = require_errorMessage.localiseErrorMessage;
|
|
15
20
|
exports.translationKeys = require_translationKey.translationKeys;
|
|
@@ -13,6 +13,11 @@ var WIDGET = {
|
|
|
13
13
|
"INSECURE_CONTEXT": "Procaptcha requires a secure (HTTPS) connection",
|
|
14
14
|
"CHECKING": "Checking that you are human",
|
|
15
15
|
"IMAGE_DIALOG_LABEL": "Image challenge",
|
|
16
|
+
"CANNOT_LOAD": "Cannot load CAPTCHA",
|
|
17
|
+
"RELOAD": "Reload",
|
|
18
|
+
"VERIFIED_AGENT": "Verified agent",
|
|
19
|
+
"TRUSTED_REQUEST": "Trusted request",
|
|
20
|
+
"LOADING": "Loading",
|
|
16
21
|
"PUZZLE": {
|
|
17
22
|
"DIALOG_LABEL": "Puzzle challenge",
|
|
18
23
|
"DRAG": "Drag the piece to the target",
|
|
@@ -22,7 +27,8 @@ var WIDGET = {
|
|
|
22
27
|
"KEYBOARD_HINT": "Use the arrow keys to move the piece, holding shift for smaller steps. Press Enter to submit it, Home to put it back at the start, or Escape to cancel.",
|
|
23
28
|
"POSITION": "{{x}} percent across, {{y}} percent down",
|
|
24
29
|
"CHECKING": "Checking your answer",
|
|
25
|
-
"RETRY_ANNOUNCEMENT": "Not quite. A new puzzle has loaded and the piece is back at the start."
|
|
30
|
+
"RETRY_ANNOUNCEMENT": "Not quite. A new puzzle has loaded and the piece is back at the start.",
|
|
31
|
+
"REFRESH": "Show a different puzzle"
|
|
26
32
|
}
|
|
27
33
|
};
|
|
28
34
|
var GENERAL = {
|
|
@@ -36,7 +42,9 @@ var GENERAL = {
|
|
|
36
42
|
"ACCOUNT_NOT_FOUND": "Account not found",
|
|
37
43
|
"SITE_KEY_NOT_FOUND": "Site key not found",
|
|
38
44
|
"INVALID_TIMESTAMP": "Invalid timestamp",
|
|
39
|
-
"MISSING_SECRET_KEY": "Missing secret key"
|
|
45
|
+
"MISSING_SECRET_KEY": "Missing secret key",
|
|
46
|
+
"MISSING_AUTH_HEADER": "Missing authorization header",
|
|
47
|
+
"INVALID_JWT": "Invalid JWT"
|
|
40
48
|
};
|
|
41
49
|
var CONTRACT = {
|
|
42
50
|
"INVALID_ADDRESS": "Failed to encode invalid address",
|
|
@@ -81,7 +89,13 @@ var DATABASE = {
|
|
|
81
89
|
"TABLES_UNDEFINED": "Tables undefined",
|
|
82
90
|
"CONNECTION_UNDEFINED": "Connection undefined",
|
|
83
91
|
"COMMITMENT_FLAG_FAILED": "Failed to flag commitment as processed",
|
|
84
|
-
"UNKNOWN": "Unknown database error"
|
|
92
|
+
"UNKNOWN": "Unknown database error",
|
|
93
|
+
"QUERY_ERROR": "Database query failed",
|
|
94
|
+
"REDIS_ACCESS_RULES_CONNECTION_UNDEFINED": "Redis access rules connection undefined",
|
|
95
|
+
"USER_ACCESS_RULES_STORAGE_UNDEFINED": "User access rules storage undefined",
|
|
96
|
+
"SESSION_STORE_FAILED": "Failed to store session",
|
|
97
|
+
"SESSION_CHECK_REMOVE_FAILED": "Failed to check and remove session",
|
|
98
|
+
"SESSION_GET_FAILED": "Failed to get session"
|
|
85
99
|
};
|
|
86
100
|
var CAPTCHA = {
|
|
87
101
|
"PARSE_ERROR": "Error parsing captcha",
|
|
@@ -100,7 +114,10 @@ var CAPTCHA = {
|
|
|
100
114
|
"INVALID_SALT": "Invalid salt",
|
|
101
115
|
"INVALID_TOKEN": "Invalid token",
|
|
102
116
|
"INVALID_SOLUTION": "Invalid solution",
|
|
103
|
-
"DECRYPTION_ERROR": "Error decrypting"
|
|
117
|
+
"DECRYPTION_ERROR": "Error decrypting",
|
|
118
|
+
"SOLUTION_NOT_FOUND": "Solution not found",
|
|
119
|
+
"DECISION_MACHINE_DENIED": "Denied by the decision machine",
|
|
120
|
+
"INVALID_TIMESTAMP": "Invalid timestamp"
|
|
104
121
|
};
|
|
105
122
|
var API = {
|
|
106
123
|
"CAPTCHA_FAILED": "You answered one or more captchas incorrectly. Please try again",
|
|
@@ -144,7 +161,8 @@ var API = {
|
|
|
144
161
|
"MOBILE_BLOCKED": "Requests from mobile network connections are not allowed for this site",
|
|
145
162
|
"SATELLITE_BLOCKED": "Requests from satellite connections are not allowed for this site",
|
|
146
163
|
"CRAWLER_BLOCKED": "Requests from known crawlers are not allowed for this site",
|
|
147
|
-
"DISALLOWED_WEBVIEW": "Requests from in-app browsers (WebViews) are not allowed for this site"
|
|
164
|
+
"DISALLOWED_WEBVIEW": "Requests from in-app browsers (WebViews) are not allowed for this site",
|
|
165
|
+
"INTERNAL_SERVER_ERROR": "Internal server error"
|
|
148
166
|
};
|
|
149
167
|
var PORTAL = {
|
|
150
168
|
"CANNOT_MODIFY_OWNER_USER": "Cannot modify owner user",
|
|
@@ -13,6 +13,10 @@ function getLeafFieldPath(obj) {
|
|
|
13
13
|
}, []);
|
|
14
14
|
}
|
|
15
15
|
var translationKeys = getLeafFieldPath(require_translation.default);
|
|
16
|
+
var translationKeySet = new Set(translationKeys);
|
|
17
|
+
/** For keys that only exist at runtime, e.g. an error message. */
|
|
18
|
+
var isTranslationKey = (value) => translationKeySet.has(value);
|
|
16
19
|
//#endregion
|
|
17
20
|
exports.getLeafFieldPath = getLeafFieldPath;
|
|
21
|
+
exports.isTranslationKey = isTranslationKey;
|
|
18
22
|
exports.translationKeys = translationKeys;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"direction.d.ts","sourceRoot":"","sources":["../src/direction.ts"],"names":[],"mappings":"AAcA,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,KAAK,CAAC;AAkB1C,eAAO,MAAM,oBAAoB,aAAc,MAAM,KAAG,aAGvD,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/direction.ts
|
|
2
|
+
var RTL_LANGUAGES = /* @__PURE__ */ new Set([
|
|
3
|
+
"ar",
|
|
4
|
+
"ckb",
|
|
5
|
+
"dv",
|
|
6
|
+
"fa",
|
|
7
|
+
"he",
|
|
8
|
+
"ps",
|
|
9
|
+
"sd",
|
|
10
|
+
"ug",
|
|
11
|
+
"ur",
|
|
12
|
+
"yi"
|
|
13
|
+
]);
|
|
14
|
+
var getLanguageDirection = (language) => {
|
|
15
|
+
const primary = language.split(/[-_]/)[0]?.toLowerCase() ?? "";
|
|
16
|
+
return RTL_LANGUAGES.has(primary) ? "rtl" : "ltr";
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
export { getLanguageDirection };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"direction.js","sourceRoot":"","sources":["../src/direction.ts"],"names":[],"mappings":"AAmBA,MAAM,aAAa,GAAwB,IAAI,GAAG,CAAC;IAClD,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;CACJ,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,QAAgB,EAAiB,EAAE;IACvE,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;IAC/D,OAAO,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;AACnD,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Ti18n } from "./types.js";
|
|
2
|
+
export interface KeyedErrorMessage {
|
|
3
|
+
message: string;
|
|
4
|
+
key?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const localiseErrorMessage: (i18n: Ti18n | undefined, error: KeyedErrorMessage) => string;
|
|
7
|
+
//# sourceMappingURL=errorMessage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorMessage.d.ts","sourceRoot":"","sources":["../src/errorMessage.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,WAAW,iBAAiB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;CACb;AAQD,eAAO,MAAM,oBAAoB,SAC1B,KAAK,GAAG,SAAS,SAChB,iBAAiB,KACtB,MAMF,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { isTranslationKey } from "./translationKey.js";
|
|
2
|
+
//#region src/errorMessage.ts
|
|
3
|
+
/**
|
|
4
|
+
* The provider translates error messages into the request's Accept-Language,
|
|
5
|
+
* which is the browser's language rather than the widget's. Re-translating the
|
|
6
|
+
* error key on the client shows the error in the language the widget renders
|
|
7
|
+
* in. Free text and keys the catalogue doesn't have keep the server's message.
|
|
8
|
+
*/
|
|
9
|
+
var localiseErrorMessage = (i18n, error) => {
|
|
10
|
+
const { key, message } = error;
|
|
11
|
+
if (!key || !isTranslationKey(key) || !i18n?.isInitialized) return message;
|
|
12
|
+
return i18n.t(key, { defaultValue: message });
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
export { localiseErrorMessage };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorMessage.js","sourceRoot":"","sources":["../src/errorMessage.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAcvD,MAAM,CAAC,MAAM,oBAAoB,GAAG,CACnC,IAAuB,EACvB,KAAwB,EACf,EAAE;IACX,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IAC/B,IAAI,CAAC,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,aAAa,EAAE,CAAC;QAC5D,OAAO,OAAO,CAAC;IAChB,CAAC;IACD,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,CAAC;AAC/C,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
export { getLanguageDirection } from "./direction.js";
|
|
2
|
+
export type { TextDirection } from "./direction.js";
|
|
1
3
|
export { default as i18nMiddleware } from "./i18nMiddleware.js";
|
|
2
4
|
export { default as loadI18next } from "./loadI18next.js";
|
|
3
5
|
export { isLanguage, LanguageCodes, Languages } from "./translations.js";
|
|
4
6
|
export type { Language } from "./translations.js";
|
|
5
7
|
export { isClientSide } from "./util.js";
|
|
6
|
-
export { translationKeys } from "./translationKey.js";
|
|
8
|
+
export { isTranslationKey, translationKeys } from "./translationKey.js";
|
|
7
9
|
export type { TranslationKey } from "./translationKey.js";
|
|
8
10
|
export { createTranslator } from "./translator.js";
|
|
9
11
|
export type { Translator } from "./translator.js";
|
|
10
12
|
export type { I18nEvent, Ti18n, TranslateFn, TranslateOptions, } from "./types.js";
|
|
13
|
+
export { localiseErrorMessage } from "./errorMessage.js";
|
|
14
|
+
export type { KeyedErrorMessage } from "./errorMessage.js";
|
|
11
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACzE,YAAY,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACzE,YAAY,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACxE,YAAY,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,YAAY,EACX,SAAS,EACT,KAAK,EACL,WAAW,EACX,gBAAgB,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC"}
|