@prosopo/locale 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/README.md +1 -0
  2. package/coverage/base.css +224 -0
  3. package/coverage/block-navigation.js +87 -0
  4. package/coverage/clover.xml +6 -0
  5. package/coverage/coverage-final.json +1 -0
  6. package/coverage/favicon.png +0 -0
  7. package/coverage/index.html +101 -0
  8. package/coverage/prettify.css +1 -0
  9. package/coverage/prettify.js +2 -0
  10. package/coverage/sort-arrow-sprite.png +0 -0
  11. package/coverage/sorter.js +196 -0
  12. package/dist/cjs/index.cjs +14 -0
  13. package/dist/cjs/locales/en.json.cjs +840 -0
  14. package/dist/cjs/locales/es.json.cjs +811 -0
  15. package/dist/cjs/locales/pt-BR.json.cjs +811 -0
  16. package/dist/cjs/locales/pt.json.cjs +811 -0
  17. package/dist/cjs/node/i18nBackend.cjs +13 -0
  18. package/dist/cjs/node/i18nMiddleware.cjs +8 -0
  19. package/dist/cjs/node/index.cjs +4 -0
  20. package/dist/cjs/translations.cjs +16 -0
  21. package/dist/cjs/util.cjs +29 -0
  22. package/dist/index.d.ts +5 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +5 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/locales/en.json +409 -0
  27. package/dist/locales/es.json +398 -0
  28. package/dist/locales/pt-BR.json +398 -0
  29. package/dist/locales/pt.json +398 -0
  30. package/dist/node/i18nBackend.d.ts +3 -0
  31. package/dist/node/i18nBackend.d.ts.map +1 -0
  32. package/dist/node/i18nBackend.js +16 -0
  33. package/dist/node/i18nBackend.js.map +1 -0
  34. package/dist/node/i18nMiddleware.d.ts +4 -0
  35. package/dist/node/i18nMiddleware.d.ts.map +1 -0
  36. package/dist/node/i18nMiddleware.js +7 -0
  37. package/dist/node/i18nMiddleware.js.map +1 -0
  38. package/dist/node/index.d.ts +2 -0
  39. package/dist/node/index.d.ts.map +1 -0
  40. package/dist/node/index.js +2 -0
  41. package/dist/node/index.js.map +1 -0
  42. package/dist/tests/locales.unit.test.d.ts +2 -0
  43. package/dist/tests/locales.unit.test.d.ts.map +1 -0
  44. package/dist/tests/locales.unit.test.js +40 -0
  45. package/dist/tests/locales.unit.test.js.map +1 -0
  46. package/dist/translations.d.ts +1616 -0
  47. package/dist/translations.d.ts.map +1 -0
  48. package/dist/translations.js +13 -0
  49. package/dist/translations.js.map +1 -0
  50. package/dist/util.d.ts +5 -0
  51. package/dist/util.d.ts.map +1 -0
  52. package/dist/util.js +24 -0
  53. package/dist/util.js.map +1 -0
  54. package/package.json +56 -0
  55. package/vite.cjs.config.ts +20 -0
  56. package/vite.test.config.ts +33 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../src/translations.ts"],"names":[],"mappings":"AAaA,OAAO,CAAC,MAAM,KAAK,CAAC;AAMpB,eAAO,MAAM,cAAc,wCAAsC,CAAC;AAElE,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAKxB,CAAC"}
@@ -0,0 +1,13 @@
1
+ import z from "zod";
2
+ import translationsEn from "./locales/en.json" assert { type: "json" };
3
+ import translationsEs from "./locales/es.json" assert { type: "json" };
4
+ import translationsPtBR from "./locales/pt-BR.json" assert { type: "json" };
5
+ import translationsPt from "./locales/pt.json" assert { type: "json" };
6
+ export const LanguageSchema = z.enum(["en", "es", "pt", "pt-BR"]);
7
+ export const translations = {
8
+ [LanguageSchema.enum.en]: { translation: translationsEn },
9
+ [LanguageSchema.enum.es]: { translation: translationsEs },
10
+ [LanguageSchema.enum.pt]: { translation: translationsPt },
11
+ [LanguageSchema.enum["pt-BR"]]: { translation: translationsPtBR },
12
+ };
13
+ //# sourceMappingURL=translations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translations.js","sourceRoot":"","sources":["../src/translations.ts"],"names":[],"mappings":"AAaA,OAAO,CAAC,MAAM,KAAK,CAAC;AACpB,OAAO,cAAc,MAAM,mBAAmB,CAAC,SAAS,IAAI,EAAE,MAAM,EAAE,CAAC;AACvE,OAAO,cAAc,MAAM,mBAAmB,CAAC,SAAS,IAAI,EAAE,MAAM,EAAE,CAAC;AACvE,OAAO,gBAAgB,MAAM,sBAAsB,CAAC,SAAS,IAAI,EAAE,MAAM,EAAE,CAAC;AAC5E,OAAO,cAAc,MAAM,mBAAmB,CAAC,SAAS,IAAI,EAAE,MAAM,EAAE,CAAC;AAEvE,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;AAElE,MAAM,CAAC,MAAM,YAAY,GAAG;IAC3B,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,WAAW,EAAE,cAAc,EAAE;IACzD,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,WAAW,EAAE,cAAc,EAAE;IACzD,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,WAAW,EAAE,cAAc,EAAE;IACzD,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,WAAW,EAAE,gBAAgB,EAAE;CACjE,CAAC"}
package/dist/util.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { z } from "zod";
2
+ export declare function isClientSide(): boolean;
3
+ export declare const TranslationKeysSchema: z.ZodEnum<[string, ...string[]]>;
4
+ export type TranslationKey = z.infer<typeof TranslationKeysSchema>;
5
+ //# sourceMappingURL=util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,wBAAgB,YAAY,IAAI,OAAO,CAMtC;AA4BD,eAAO,MAAM,qBAAqB,kCAEjC,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
package/dist/util.js ADDED
@@ -0,0 +1,24 @@
1
+ import { z } from "zod";
2
+ import translationEn from "./locales/en.json" assert { type: "json" };
3
+ export function isClientSide() {
4
+ return !!(typeof window !== "undefined" &&
5
+ window.document &&
6
+ window.document.createElement);
7
+ }
8
+ function getLeafFieldPath(obj) {
9
+ if (typeof obj === "string") {
10
+ return [];
11
+ }
12
+ return Object.keys(obj).reduce((arr, key) => {
13
+ const value = obj[key];
14
+ if (value === undefined) {
15
+ throw new Error(`Undefined value for key ${key}`);
16
+ }
17
+ const children = getLeafFieldPath(value);
18
+ return arr.concat(children.map((child) => {
19
+ return `${key}.${child}`;
20
+ }));
21
+ }, []);
22
+ }
23
+ export const TranslationKeysSchema = z.enum(getLeafFieldPath(translationEn));
24
+ //# sourceMappingURL=util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,aAAa,MAAM,mBAAmB,CAAC,SAAS,IAAI,EAAE,MAAM,EAAE,CAAC;AAEtE,MAAM,UAAU,YAAY;IAC3B,OAAO,CAAC,CAAC,CACR,OAAO,MAAM,KAAK,WAAW;QAC7B,MAAM,CAAC,QAAQ;QACf,MAAM,CAAC,QAAQ,CAAC,aAAa,CAC7B,CAAC;AACH,CAAC;AAQD,SAAS,gBAAgB,CAAC,GAAS;IAClC,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC7B,OAAO,EAAE,CAAC;IACX,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAC3C,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;QACvB,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,2BAA2B,GAAG,EAAE,CAAC,CAAC;QACnD,CAAC;QACD,MAAM,QAAQ,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;QAEzC,OAAO,GAAG,CAAC,MAAM,CAChB,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YACtB,OAAO,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC;QAC1B,CAAC,CAAC,CACF,CAAC;IACH,CAAC,EAAE,EAAc,CAAC,CAAC;AACpB,CAAC;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,IAAI,CAC1C,gBAAgB,CAAC,aAAa,CAA0B,CACxD,CAAC"}
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@prosopo/locale",
3
+ "version": "2.1.1",
4
+ "description": "Prosopo locale library",
5
+ "main": "./dist/index.js",
6
+ "type": "module",
7
+ "engines": {
8
+ "node": ">=20",
9
+ "npm": ">=9"
10
+ },
11
+ "exports": {
12
+ ".": {
13
+ "import": "./dist/index.js",
14
+ "require": "./dist/cjs/index.cjs"
15
+ }
16
+ },
17
+ "types": "./dist/index.d.ts",
18
+ "scripts": {
19
+ "clean": "tsc --build --clean",
20
+ "build": "tsc --build --verbose",
21
+ "build:cjs": "npx vite --config vite.cjs.config.ts build",
22
+ "test": "NODE_ENV=${NODE_ENV:-test}; npx vitest run --config ./vite.test.config.ts"
23
+ },
24
+ "author": "Prosopo Limited",
25
+ "license": "Apache-2.0",
26
+ "dependencies": {
27
+ "i18next": "21.9.2",
28
+ "i18next-http-backend": "1.4.5",
29
+ "i18next-http-middleware": "3.6.0",
30
+ "zod": "3.23.8"
31
+ },
32
+ "devDependencies": {
33
+ "@prosopo/config": "2.1.1",
34
+ "@vitest/coverage-v8": "2.1.1",
35
+ "dotenv": "16.4.5",
36
+ "npm-run-all": "4.1.5",
37
+ "rimraf": "6.0.1",
38
+ "tslib": "2.7.0",
39
+ "tsx": "4.19.1",
40
+ "typescript": "5.6.2",
41
+ "vite": "5.4.6",
42
+ "vitest": "2.1.1"
43
+ },
44
+ "repository": {
45
+ "type": "git",
46
+ "url": "git+https://github.com/prosopo/captcha.git"
47
+ },
48
+ "bugs": {
49
+ "url": "https://github.com/prosopo/captcha/issues"
50
+ },
51
+ "homepage": "https://github.com/prosopo/captcha#readme",
52
+ "publishConfig": {
53
+ "registry": "https://registry.npmjs.org"
54
+ },
55
+ "sideEffects": false
56
+ }
@@ -0,0 +1,20 @@
1
+ // Copyright 2021-2024 Prosopo (UK) Ltd.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ import path from "node:path";
16
+ import { ViteCommonJSConfig } from "@prosopo/config";
17
+
18
+ export default function () {
19
+ return ViteCommonJSConfig("locale", path.resolve("./tsconfig.cjs.json"));
20
+ }
@@ -0,0 +1,33 @@
1
+ // Copyright 2021-2024 Prosopo (UK) Ltd.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ import fs from "node:fs";
16
+ import path from "node:path";
17
+ import { ViteTestConfig } from "@prosopo/config";
18
+ import dotenv from "dotenv";
19
+ process.env.NODE_ENV = "test";
20
+ // if .env.test exists at this level, use it, otherwise use the one at the root
21
+ const envFile = `.env.${process.env.NODE_ENV || "development"}`;
22
+ let envPath = envFile;
23
+ if (fs.existsSync(envFile)) {
24
+ envPath = path.resolve(envFile);
25
+ } else if (fs.existsSync(`../../${envFile}`)) {
26
+ envPath = path.resolve(`../../${envFile}`);
27
+ } else {
28
+ throw new Error(`No ${envFile} file found`);
29
+ }
30
+
31
+ dotenv.config({ path: envPath });
32
+
33
+ export default ViteTestConfig;