@prosopo/locale 2.5.3 → 3.1.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 +40 -0
- package/dist/cjs/i18SharedOptions.cjs +11 -0
- package/dist/cjs/i18nBackend.cjs +32 -0
- package/dist/cjs/i18nFrontend.cjs +60 -0
- package/dist/cjs/i18nMiddleware.cjs +8 -0
- package/dist/cjs/index.cjs +15 -0
- package/dist/cjs/loadI18next.cjs +28 -0
- package/dist/cjs/locales/en/translation.json.cjs +47 -0
- package/dist/cjs/translationKey.cjs +25 -0
- package/dist/cjs/translations.cjs +42 -0
- package/dist/cjs/useTranslation.cjs +8 -0
- package/dist/cjs/util.cjs +10 -0
- package/dist/i18SharedOptions.d.ts +8 -0
- package/dist/i18SharedOptions.d.ts.map +1 -0
- package/dist/i18SharedOptions.js +11 -0
- package/dist/i18nBackend.d.ts +2 -1
- package/dist/i18nBackend.d.ts.map +1 -1
- package/dist/i18nBackend.js +27 -25
- package/dist/i18nFrontend.d.ts +2 -1
- package/dist/i18nFrontend.d.ts.map +1 -1
- package/dist/i18nFrontend.js +48 -38
- package/dist/i18nMiddleware.js +5 -4
- package/dist/index.js +15 -7
- package/dist/loadI18next.d.ts.map +1 -1
- package/dist/loadI18next.js +26 -25
- package/dist/locales/ar/translation.json +442 -0
- package/dist/locales/az/translation.json +442 -0
- package/dist/locales/cs/translation.json +442 -0
- package/dist/locales/de/translation.json +440 -404
- package/dist/locales/el/translation.json +442 -0
- package/dist/locales/en/translation.json +440 -404
- package/dist/locales/en/translation.json.js +47 -0
- package/dist/locales/es/translation.json +440 -404
- package/dist/locales/fi/translation.json +442 -0
- package/dist/locales/fr/translation.json +440 -404
- package/dist/locales/hi/translation.json +442 -0
- package/dist/locales/hu/translation.json +442 -0
- package/dist/locales/id/translation.json +442 -0
- package/dist/locales/it/translation.json +440 -404
- package/dist/locales/ja/translation.json +442 -0
- package/dist/locales/jv/translation.json +442 -0
- package/dist/locales/ko/translation.json +442 -0
- package/dist/locales/ml/translation.json +442 -0
- package/dist/locales/ms/translation.json +442 -0
- package/dist/locales/nl/translation.json +442 -0
- package/dist/locales/no/translation.json +442 -0
- package/dist/locales/pl/translation.json +442 -0
- package/dist/locales/pt/translation.json +440 -404
- package/dist/locales/pt-BR/translation.json +440 -404
- package/dist/locales/ro/translation.json +442 -0
- package/dist/locales/ru/translation.json +442 -0
- package/dist/locales/sr/translation.json +442 -0
- package/dist/locales/sv/translation.json +442 -0
- package/dist/locales/th/translation.json +442 -0
- package/dist/locales/tr/translation.json +442 -0
- package/dist/locales/uk/translation.json +442 -0
- package/dist/locales/vi/translation.json +442 -0
- package/dist/locales/zh-CN/translation.json +442 -0
- package/dist/translationKey.js +21 -17
- package/dist/translations.d.ts +35 -2
- package/dist/translations.d.ts.map +1 -1
- package/dist/translations.js +41 -3
- package/dist/useTranslation.js +7 -6
- package/dist/util.js +8 -7
- package/package.json +26 -14
- package/vite.cjs.config.ts +5 -3
- package/vite.esm.config.ts +20 -0
- package/vite.test.config.ts +3 -4
- package/dist/i18nBackend.js.map +0 -1
- package/dist/i18nFrontend.js.map +0 -1
- package/dist/i18nMiddleware.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/loadI18next.js.map +0 -1
- package/dist/tests/locales.unit.test.js +0 -48
- package/dist/tests/locales.unit.test.js.map +0 -1
- package/dist/translationKey.js.map +0 -1
- package/dist/translations.js.map +0 -1
- package/dist/useTranslation.js.map +0 -1
- package/dist/util.js.map +0 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# @prosopo/locale
|
|
2
|
+
|
|
3
|
+
## 3.1.0
|
|
4
|
+
### Minor Changes
|
|
5
|
+
|
|
6
|
+
- f29fc7e: Refining API error handling. Adding more language strings
|
|
7
|
+
|
|
8
|
+
### Patch Changes
|
|
9
|
+
|
|
10
|
+
- 93d5e50: ensure packages have @prosopo/config as dep for vite configs
|
|
11
|
+
- 3573f0b: build using vite, typecheck using tsc
|
|
12
|
+
- efd8102: Add tests for unwrap error helper
|
|
13
|
+
- 93d5e50: fix missing dep for @prosopo/config
|
|
14
|
+
- 3573f0b: standardise all vite based npm scripts for bundling
|
|
15
|
+
- Updated dependencies [3573f0b]
|
|
16
|
+
- Updated dependencies [3573f0b]
|
|
17
|
+
- Updated dependencies [3573f0b]
|
|
18
|
+
- Updated dependencies [2d0dd8a]
|
|
19
|
+
- @prosopo/config@3.1.1
|
|
20
|
+
|
|
21
|
+
## 3.0.2
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- f682f0c: Moving type and fixing i18n config
|
|
25
|
+
|
|
26
|
+
## 3.0.1
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- 87bd9bc: Allow non-explicit languages
|
|
30
|
+
|
|
31
|
+
## 3.0.0
|
|
32
|
+
### Major Changes
|
|
33
|
+
|
|
34
|
+
- 64b5bcd: Access Controls
|
|
35
|
+
|
|
36
|
+
## 2.6.0
|
|
37
|
+
|
|
38
|
+
### Minor Changes
|
|
39
|
+
|
|
40
|
+
- a0bfc8a: bump all pkg versions since independent versioning applied
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const translations = require("./translations.cjs");
|
|
4
|
+
const i18nSharedOptions = {
|
|
5
|
+
debug: process.env.PROSOPO_LOG_LEVEL === "debug",
|
|
6
|
+
fallbackLng: translations.LanguageSchema.enum.en,
|
|
7
|
+
namespace: "translation",
|
|
8
|
+
supportedLngs: Object.values(translations.Languages),
|
|
9
|
+
nonExplicitSupportedLngs: false
|
|
10
|
+
};
|
|
11
|
+
exports.i18nSharedOptions = i18nSharedOptions;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const path = require("node:path");
|
|
4
|
+
const i18n = require("i18next");
|
|
5
|
+
const FSBackend = require("i18next-fs-backend/cjs");
|
|
6
|
+
const i18nextHttpMiddleware = require("i18next-http-middleware");
|
|
7
|
+
const i18SharedOptions = require("./i18SharedOptions.cjs");
|
|
8
|
+
const util = require("./util.cjs");
|
|
9
|
+
const loadPath = `${path.dirname(module)}/locales/{{lng}}/{{ns}}.json`.replace(
|
|
10
|
+
"file://",
|
|
11
|
+
""
|
|
12
|
+
);
|
|
13
|
+
function initializeI18n(i18nLoadedCallback) {
|
|
14
|
+
if (!i18n.isInitialized && util.isServerSide()) {
|
|
15
|
+
const lngDetector = new i18nextHttpMiddleware.LanguageDetector(null, {
|
|
16
|
+
order: ["header", "query", "cookie"]
|
|
17
|
+
});
|
|
18
|
+
i18n.use(FSBackend).use(lngDetector).init({
|
|
19
|
+
...i18SharedOptions.i18nSharedOptions,
|
|
20
|
+
ns: ["translation"],
|
|
21
|
+
backend: {
|
|
22
|
+
loadPath
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
i18n.on("loaded", () => {
|
|
26
|
+
i18nLoadedCallback?.(i18n);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return i18n;
|
|
30
|
+
}
|
|
31
|
+
exports.default = initializeI18n;
|
|
32
|
+
exports.initializeI18n = initializeI18n;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const i18n = require("i18next");
|
|
4
|
+
const I18nextBrowserLanguageDetector = require("i18next-browser-languagedetector");
|
|
5
|
+
const ChainedBackend = require("i18next-chained-backend");
|
|
6
|
+
const HttpBackend = require("i18next-http-backend");
|
|
7
|
+
const resourcesToBackend = require("i18next-resources-to-backend");
|
|
8
|
+
const reactI18next = require("react-i18next");
|
|
9
|
+
const i18SharedOptions = require("./i18SharedOptions.cjs");
|
|
10
|
+
var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
|
|
11
|
+
const reactOptions = {
|
|
12
|
+
react: {
|
|
13
|
+
useSuspense: true
|
|
14
|
+
},
|
|
15
|
+
detection: {
|
|
16
|
+
order: ["navigator", "htmlTag", "path", "subdomain"],
|
|
17
|
+
caches: ["localStorage", "cookie"]
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const getLoadPath = (language, namespace) => {
|
|
21
|
+
const filename = (typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("i18nFrontend.cjs", document.baseURI).href).split("/").pop();
|
|
22
|
+
return `${(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("i18nFrontend.cjs", document.baseURI).href).replace(`/${filename}`, "")}/locales/${language}/${namespace}.json`;
|
|
23
|
+
};
|
|
24
|
+
function initializeI18n(i18nLoadedCallback) {
|
|
25
|
+
if (!i18n.isInitialized) {
|
|
26
|
+
i18n.use(ChainedBackend).use(
|
|
27
|
+
new I18nextBrowserLanguageDetector(null, {
|
|
28
|
+
order: ["cookie", "localStorage", "navigator"],
|
|
29
|
+
lookupQuerystring: "lng",
|
|
30
|
+
lookupCookie: "i18next",
|
|
31
|
+
lookupLocalStorage: "i18nextLng",
|
|
32
|
+
caches: ["localStorage", "cookie"]
|
|
33
|
+
})
|
|
34
|
+
).use(reactI18next.initReactI18next).init({
|
|
35
|
+
...i18SharedOptions.i18nSharedOptions,
|
|
36
|
+
backend: {
|
|
37
|
+
backends: [
|
|
38
|
+
HttpBackend,
|
|
39
|
+
// if a namespace can't be loaded via normal http-backend loadPath, then the inMemoryLocalBackend will try to return the correct resources
|
|
40
|
+
// with dynamic import, you have to use the "default" key of the module ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#importing_defaults )
|
|
41
|
+
resourcesToBackend(
|
|
42
|
+
(language, namespace) => import(getLoadPath(language, namespace))
|
|
43
|
+
)
|
|
44
|
+
],
|
|
45
|
+
backendOptions: [
|
|
46
|
+
{
|
|
47
|
+
loadPath: getLoadPath("{{lng}}", "{{ns}}")
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
...reactOptions
|
|
52
|
+
});
|
|
53
|
+
i18n.on("loaded", () => {
|
|
54
|
+
i18nLoadedCallback?.(i18n);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return i18n;
|
|
58
|
+
}
|
|
59
|
+
exports.default = initializeI18n;
|
|
60
|
+
exports.initializeI18n = initializeI18n;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const i18nextHttpMiddleware = require("i18next-http-middleware");
|
|
3
|
+
const loadI18next = require("./loadI18next.cjs");
|
|
4
|
+
async function i18nMiddleware(options) {
|
|
5
|
+
const i18n = await loadI18next(true);
|
|
6
|
+
return i18nextHttpMiddleware.handle(i18n, { ...options });
|
|
7
|
+
}
|
|
8
|
+
module.exports = i18nMiddleware;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const i18nMiddleware = require("./i18nMiddleware.cjs");
|
|
4
|
+
const loadI18next = require("./loadI18next.cjs");
|
|
5
|
+
const translations = require("./translations.cjs");
|
|
6
|
+
const util = require("./util.cjs");
|
|
7
|
+
const translationKey = require("./translationKey.cjs");
|
|
8
|
+
const useTranslation = require("./useTranslation.cjs");
|
|
9
|
+
exports.i18nMiddleware = i18nMiddleware;
|
|
10
|
+
exports.loadI18next = loadI18next;
|
|
11
|
+
exports.LanguageSchema = translations.LanguageSchema;
|
|
12
|
+
exports.Languages = translations.Languages;
|
|
13
|
+
exports.isClientSide = util.isClientSide;
|
|
14
|
+
exports.TranslationKeysSchema = translationKey.TranslationKeysSchema;
|
|
15
|
+
exports.useTranslation = useTranslation;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
let i18nInstance;
|
|
3
|
+
async function loadI18next(backend) {
|
|
4
|
+
return new Promise((resolve, reject) => {
|
|
5
|
+
try {
|
|
6
|
+
if (backend) {
|
|
7
|
+
Promise.resolve().then(() => require("./i18nBackend.cjs")).then(({ default: initializeI18n }) => {
|
|
8
|
+
if (!i18nInstance) {
|
|
9
|
+
i18nInstance = initializeI18n(resolve);
|
|
10
|
+
} else {
|
|
11
|
+
resolve(i18nInstance);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
} else {
|
|
15
|
+
Promise.resolve().then(() => require("./i18nFrontend.cjs")).then(({ default: initializeI18n }) => {
|
|
16
|
+
if (!i18nInstance) {
|
|
17
|
+
i18nInstance = initializeI18n(resolve);
|
|
18
|
+
} else {
|
|
19
|
+
resolve(i18nInstance);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
} catch (e) {
|
|
24
|
+
reject(e);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
module.exports = loadI18next;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const ACCOUNT = { "NO_POLKADOT_EXTENSION": "Polkadot extension not found" };
|
|
4
|
+
const WIDGET = { "SELECT_ALL": "Select all containing the following", "IF_NONE_CLICK_NEXT": "If there are none, click Next", "NEXT": "Next", "SUBMIT": "Submit", "CANCEL": "Cancel", "I_AM_HUMAN": "I am human", "NO_ACCOUNTS_FOUND": "No accounts found", "ACCOUNT_NOT_FOUND": "Account not found", "NO_EXTENSION_FOUND": "No extension found" };
|
|
5
|
+
const GENERAL = { "JSON_LOAD_FAILED": "Failed to load JSON file", "MNEMONIC_UNDEFINED": "Mnemonic Undefined. Please set the mnemonic in environment variables", "NO_MNEMONIC_OR_SEED": "No secret provided", "CANT_FIND_KEYRINGPAIR": "Can't find the keyringpair for {{address}}", "ENVIRONMENT_NOT_READY": "Environment not ready", "INVALID_SIGNATURE": "Invalid signature", "SITE_KEY_MISSING": "SITE KEY missing", "ACCOUNT_NOT_FOUND": "Account not found", "SITE_KEY_NOT_FOUND": "Site key not found", "INVALID_TIMESTAMP": "Invalid timestamp", "MISSING_SECRET_KEY": "Missing secret key" };
|
|
6
|
+
const CONTRACT = { "INVALID_ADDRESS": "Failed to encode invalid address", "CAPTCHA_SOLUTION_COMMITMENT_DOES_NOT_EXIST": "Captcha solution commitment does not exist", "SIGNER_UNDEFINED": "Signer undefined", "CANNOT_FIND_KEYPAIR": "Cannot find keypair", "INVALID_DATA_FORMAT": "Invalid data format" };
|
|
7
|
+
const CONFIG = { "UNKNOWN_ENVIRONMENT": "Unknown environment requested", "INVALID_CAPTCHA_NUMBER": "Please configure captchas configurations correctly", "INVALID_LOG_LEVEL": "Invalid log level", "INVALID_PACKAGE_DIR": "Invalid package directory" };
|
|
8
|
+
const DATASET = { "DATASET_PARSE_ERROR": "Error parsing dataset", "SOLUTION_PARSE_ERROR": "Error parsing dataset", "HASH_ERROR": "Error hashing dataset", "DATASET_ID_UNDEFINED": "Dataset id undefined", "NOT_ENOUGH_LABELS": "Not enough labels", "NOT_ENOUGH_IMAGES": "Not enough images", "CAPTCHAS_COUNT_LESS_THAN_CONFIGURED": "Number of captchas in dataset is less than configured number of captchas", "SOLUTIONS_COUNT_LESS_THAN_CONFIGURED": "Number of solutions in dataset is less than configured number of solutions", "DUPLICATE_IMAGE": "duplicate image detected", "MERKLE_ERROR": "Error creating merkle tree" };
|
|
9
|
+
const DATABASE = { "DATABASE_IMPORT_FAILED": "Failed to import database engine", "DATABASE_UNDEFINED": "Database client is not connected", "DATABASE_HOST_UNDEFINED": "Database host address is not defined", "DATASET_LOAD_FAILED": "Data set load failed", "DATASET_GET_FAILED": "Failed to get dataset", "CAPTCHA_GET_FAILED": "Failed to get captcha", "CAPTCHA_UPDATE_FAILED": "Failed to update captcha", "IMAGE_GET_FAILED": "Failed to get image", "PENDING_RECORD_NOT_FOUND": "No pending record found", "INVALID_HASH": "Invalid hash", "SOLUTION_GET_FAILED": "Failed to get solution", "DATASET_WITH_SOLUTIONS_GET_FAILED": "No datasets found with required number of solutions", "SOLUTION_APPROVE_FAILED": "Failed to approve solution", "SOLUTION_FLAG_FAILED": "Failed to flag solution as processed", "TABLES_UNDEFINED": "Tables undefined", "CONNECTION_UNDEFINED": "Connection undefined", "COMMITMENT_FLAG_FAILED": "Failed to flag commitment as processed", "UNKNOWN": "Unknown database error" };
|
|
10
|
+
const CAPTCHA = { "PARSE_ERROR": "Error parsing captcha", "INVALID_CAPTCHA_ID": "Invalid captcha id", "INVALID_ITEM_FORMAT": "Only image and text item types allowed", "INVALID_SOLUTION_TYPE": "Invalid solution type", "INVALID_ITEM_HASH": "Invalid item hash", "DIFFERENT_DATASET_IDS": "Dataset ids do not match", "ID_MISMATCH": "captcha id mismatch", "MISSING_ITEM_HASH": "missing item hash", "INVALID_CAPTCHA_CHALLENGE": "Invalid captcha challenge", "DAPP_USER_SOLUTION_NOT_FOUND": "Dapp user solution not found", "NO_CAPTCHA": "No captcha found", "NO_SESSION_FOUND": "No session found", "INVALID_TOKEN": "Invalid token", "INVALID_SOLUTION": "Invalid solution", "DECRYPTION_ERROR": "Error decrypting" };
|
|
11
|
+
const API = { "CAPTCHA_FAILED": "You answered one or more captchas incorrectly. Please try again", "CAPTCHA_PASSED": "You correctly answered the captchas", "BAD_REQUEST": "BadRequest", "USER_VERIFIED": "User verified", "USER_NOT_VERIFIED": "User not verified", "USER_NOT_VERIFIED_TIME_EXPIRED": "User not verified. Captcha solution has expired.", "USER_NOT_VERIFIED_NO_SOLUTION": "User not verified. No captcha solution found.", "USER_ALREADY_VERIFIED": "This solution has already been verified. User should complete a new captcha.", "UNKNOWN": "Unknown API error", "SITE_KEY_NOT_REGISTERED": "Site key not registered", "INCORRECT_CAPTCHA_TYPE": "Incorrect CAPTCHA type", "INSUFFICIENT_PERMISSIONS": "Insufficient permissions to perform this action", "INVALID_SITE_KEY": "Invalid site key", "UNAUTHORIZED_ORIGIN_URL": "Unauthorized origin URL", "UNAUTHORIZED": "Unauthorized", "INVALID_IP": "Invalid IP", "INVALID_URL": "Invalid URL", "INVALID_BODY": "Invalid body", "MISSING_BODY": "Missing body", "MISSING_QUERY_PARAMETERS": "Missing query parameters", "MISSING_AUTHORIZATION_HEADER": "Missing authorization header", "PARSE_ERROR": "Error parsing request", "NO_CONTENT_TYPE_HEADER": "No content-type header. Assumed JSON encoded body but failed to parse.", "TIMESTAMP_TOO_OLD": "Timestamp too old", "FORBIDDEN": "Forbidden", "PROVIDER_VERIFY_FAILED": "Provider verification failed" };
|
|
12
|
+
const PORTAL = { "CANNOT_MODIFY_OWNER_USER": "Cannot modify owner user", "CANNOT_DELETE_OWN_USER": "Cannot delete your own account", "CANNOT_DELETE_LAST_USER": "Cannot delete last user", "USER_ALREADY_EXISTS": "User already exists", "NO_SUGGESTIONS_FOUND": "No suggestions found", "CANNOT_DEACTIVATE_LAST_SITE": "Cannot deactivate the last active site" };
|
|
13
|
+
const CLI = { "PARAMETER_ERROR": "Invalid parameter" };
|
|
14
|
+
const DEVELOPER = { "PROSOPO_SITE_KEY_MISSING": "PROSOPO_SITE_KEY is not set in .env file.", "PROVIDER_NO_CAPTCHA": "No captchas returned from provider", "MISSING_PROVIDER_PAIR": "Missing provider pair", "MISSING_ENV_VARIABLE": "Missing environment variable", "GENERAL": "General Dev Error, see context", "METHOD_NOT_IMPLEMENTED": "Method not implemented" };
|
|
15
|
+
const FS = { "FILE_NOT_FOUND": "File not found", "FILE_ALREADY_EXISTS": "File already exists", "INVALID_DIR_FORMAT": "Invalid directory format" };
|
|
16
|
+
const TARGET = { "bird": "bird", "bus": "bus", "car": "car", "cat": "cat", "deer": "deer", "dog": "dog", "horse": "horse", "plane": "plane", "train": "train", "animals": "animals", "antelope": "antelope", "backpack": "backpack", "badger": "badger", "baseball-bat": "baseball bat", "baseball-glove": "baseball glove", "basketball-hoop": "basketball hoop", "bat": "bat", "bathtub": "bathtub", "bear": "bear", "bee": "bee", "beer-mug": "beer mug", "beetle": "beetle", "billiards": "billiards", "binoculars": "binoculars", "birdbath": "birdbath", "bison": "bison", "blimp": "blimp", "boar": "boar", "bonsai-tree": "bonsai tree", "boom-box": "boom box", "bowling-ball": "bowling ball", "bowling-pin": "bowling pin", "boxing-glove": "boxing glove", "breadmaker": "breadmaker", "bulldozer": "bulldozer", "butterfly": "butterfly", "cactus": "cactus", "cake": "cake", "calculator": "calculator", "camel": "camel", "canoe": "canoe", "car-tire": "car tire", "caterpillar": "caterpillar", "cd": "CD", "cereal-box": "cereal box", "chandelier": "chandelier", "chess-board": "chess board", "chimpanzee": "chimpanzee", "chopsticks": "chopsticks", "cockroach": "cockroach", "coffin": "coffin", "coin": "coin", "comet": "comet", "computer-keyboard": "computer keyboard", "computer-monitor": "computer monitor", "computer-mouse": "computer mouse", "conch": "conch", "cormorant": "cormorant", "covered-wagon": "covered wagon", "cow": "cow", "cowboy-hat": "cowboy hat", "coyote": "coyote", "crab": "crab", "crow": "crow", "desk-globe": "desk globe", "diamond-ring": "diamond ring", "dice": "dice", "dolphin": "dolphin", "donkey": "donkey", "doorknob": "doorknob", "dragonfly": "dragonfly", "drinking-straw": "drinking straw", "duck": "duck", "dumb-bell": "dumbbell", "eagle": "eagle", "eiffel-tower": "Eiffel Tower", "electric-guitar": "electric guitar", "elephant": "elephant", "elk": "elk", "eyeglasses": "eyeglasses", "fern": "fern", "fire-extinguisher": "fire extinguisher", "fire-hydrant": "fire hydrant", "fire-truck": "fire truck", "fireworks": "fireworks", "flamingo": "flamingo", "fly": "fly", "fox": "fox", "french-horn": "French horn", "fried-egg": "fried egg", "frisbee": "frisbee", "frog": "frog", "frying-pan": "frying pan", "galaxy": "galaxy", "gas-pump": "gas pump", "giraffe": "giraffe", "goat": "goat", "golden-gate-bridge": "Golden Gate Bridge", "goldfish": "goldfish", "golf-ball": "golf ball", "goose": "goose", "gorilla": "gorilla", "grapes": "grapes", "grasshopper": "grasshopper", "greyhound": "greyhound", "guitar-pick": "guitar pick", "hamburger": "hamburger", "hammock": "hammock", "hamster": "hamster", "hare": "hare", "harmonica": "harmonica", "harp": "harp", "harpsichord": "harpsichord", "head-phones": "headphones", "hedgehog": "hedgehog", "helicopter": "helicopter", "hibiscus": "hibiscus", "hippopotamus": "hippopotamus", "homer-simpson": "Homer Simpson", "hornbill": "hornbill", "horseshoe-crab": "horseshoe crab", "hot-air-balloon": "hot air balloon", "hot-dog": "hot dog", "hot-tub": "hot tub", "hourglass": "hourglass", "house-fly": "house fly", "hummingbird": "hummingbird", "hyena": "hyena", "ice-cream-cone": "ice cream cone", "iguana": "iguana", "ipod": "iPod", "jellyfish": "jellyfish", "joy-stick": "joystick", "kangaroo": "kangaroo", "kayak": "kayak", "killer-whale": "killer whale", "koala": "koala", "ladder": "ladder", "ladybugs": "ladybugs", "laptop": "laptop", "leopard": "leopard", "license-plate": "license plate", "light-house": "lighthouse", "lightbulb": "lightbulb", "lightning": "lightning", "lion": "lion", "lizard": "lizard", "llama": "llama", "lobster": "lobster", "mailbox": "mailbox", "mandolin": "mandolin", "mars": "Mars", "mattress": "mattress", "megaphone": "megaphone", "microscope": "microscope", "microwave": "microwave", "minaret": "minaret", "minotaur": "minotaur", "mosquito": "mosquito", "moth": "moth", "motorbikes": "motorbikes", "mountain-bike": "mountain bike", "mouse": "mouse", "mushroom": "mushroom", "mussels": "mussels", "necktie": "necktie", "octopus": "octopus", "okapi": "okapi", "orangutan": "orangutan", "ostrich": "ostrich", "otter": "otter", "owl": "owl", "ox": "ox", "oyster": "oyster", "palm-pilot": "Palm Pilot", "palm-tree": "palm tree", "panda": "panda", "paper-shredder": "paper shredder", "paperclip": "paperclip", "parrot": "parrot", "pci-card": "PCI card", "pelecaniformes": "pelecaniformes", "penguin": "penguin", "photocopier": "photocopier", "piano": "piano", "picnic-table": "picnic table", "pig": "pig", "pigeon": "pigeon", "playing-card": "playing card", "porcupine": "porcupine", "possum": "possum", "pram": "pram", "pyramid": "pyramid", "raccoon": "raccoon", "radio-telescope": "radio telescope", "rainbow": "rainbow", "rat": "rat", "refrigerator": "refrigerator", "reindeer": "reindeer", "rhinoceros": "rhinoceros", "rotary-phone": "rotary phone", "roulette-wheel": "roulette wheel", "saddle": "saddle", "sandpiper": "sandpiper", "saturn": "Saturn", "school-bus": "school bus", "screwdriver": "screwdriver", "seahorse": "seahorse", "seal": "seal", "segway": "Segway", "self-propelled-lawn-mower": "self propelled lawn mower", "shark": "shark", "sheep": "sheep", "sheet-music": "sheet music", "skateboard": "skateboard", "skunk": "skunk", "skyscraper": "skyscraper", "smokestack": "smokestack", "snail": "snail", "snake": "snake", "sneaker": "sneaker", "snowmobile": "snowmobile", "soccer-ball": "soccer ball", "socks": "socks", "soda-can": "soda can", "spaghetti": "spaghetti", "sparrow": "sparrow", "speed-boat": "speedboat", "spoon": "spoon", "squid": "squid", "squirrel": "squirrel", "stained-glass": "stained glass", "starfish": "starfish", "steering-wheel": "steering wheel", "stirrups": "stirrups", "sunflower": "sunflower", "superman": "Superman", "sushi": "sushi", "swan": "swan", "t-shirt": "T-shirt", "teapot": "teapot", "teddy-bear": "teddy bear", "telephone-box": "telephone box", "tennis-ball": "tennis ball", "tennis-court": "tennis court", "tennis-racket": "tennis racket", "tiger": "tiger", "toad": "toad", "toaster": "toaster", "tomato": "tomato", "tombstone": "tombstone", "top-hat": "top hat", "touring-bike": "touring bike", "tower-pisa": "Tower of Pisa", "traffic-light": "traffic light", "treadmill": "treadmill", "triceratops": "triceratops", "tricycle": "tricycle", "tripod": "tripod", "tuning-fork": "tuning fork", "turkey": "turkey", "turtle": "turtle", "tweezer": "tweezers", "umbrella": "umbrella", "unicorn": "unicorn", "video-projector": "video projector", "washing-machine": "washing machine", "watch": "watch", "waterfall": "waterfall", "watermelon": "watermelon", "welding-mask": "welding mask", "whale": "whale", "wheelbarrow": "wheelbarrow", "windmill": "windmill", "wine-bottle": "wine bottle", "wolf": "wolf", "wombat": "wombat", "woodpecker": "woodpecker", "xylophone": "xylophone", "yo-yo": "yo-yo", "zebra": "zebra", "airplanes": "airplanes", "american-flag": "American flag", "bonsai": "bonsai", "buddha": "Buddha", "cannon": "cannon", "coffee-mug": "coffee mug", "flashlight": "flashlight", "floppy-disk": "floppy disk", "football-helmet": "football helmet", "grand-piano": "grand piano", "jesus-christ": "Jesus Christ", "knife": "knife", "leopards": "leopards", "sword": "sword", "syringe": "syringe", "tambourine": "tambourine" };
|
|
17
|
+
const translationEn = {
|
|
18
|
+
ACCOUNT,
|
|
19
|
+
WIDGET,
|
|
20
|
+
GENERAL,
|
|
21
|
+
CONTRACT,
|
|
22
|
+
CONFIG,
|
|
23
|
+
DATASET,
|
|
24
|
+
DATABASE,
|
|
25
|
+
CAPTCHA,
|
|
26
|
+
API,
|
|
27
|
+
PORTAL,
|
|
28
|
+
CLI,
|
|
29
|
+
DEVELOPER,
|
|
30
|
+
FS,
|
|
31
|
+
TARGET
|
|
32
|
+
};
|
|
33
|
+
exports.ACCOUNT = ACCOUNT;
|
|
34
|
+
exports.API = API;
|
|
35
|
+
exports.CAPTCHA = CAPTCHA;
|
|
36
|
+
exports.CLI = CLI;
|
|
37
|
+
exports.CONFIG = CONFIG;
|
|
38
|
+
exports.CONTRACT = CONTRACT;
|
|
39
|
+
exports.DATABASE = DATABASE;
|
|
40
|
+
exports.DATASET = DATASET;
|
|
41
|
+
exports.DEVELOPER = DEVELOPER;
|
|
42
|
+
exports.FS = FS;
|
|
43
|
+
exports.GENERAL = GENERAL;
|
|
44
|
+
exports.PORTAL = PORTAL;
|
|
45
|
+
exports.TARGET = TARGET;
|
|
46
|
+
exports.WIDGET = WIDGET;
|
|
47
|
+
exports.default = translationEn;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const z = require("zod");
|
|
4
|
+
const translation = require("./locales/en/translation.json.cjs");
|
|
5
|
+
function getLeafFieldPath(obj) {
|
|
6
|
+
if (typeof obj === "string") {
|
|
7
|
+
return [];
|
|
8
|
+
}
|
|
9
|
+
return Object.keys(obj).reduce((arr, key) => {
|
|
10
|
+
const value = obj[key];
|
|
11
|
+
if (value === void 0) {
|
|
12
|
+
throw new Error(`Undefined value for key ${key}`);
|
|
13
|
+
}
|
|
14
|
+
const children = getLeafFieldPath(value);
|
|
15
|
+
return arr.concat(
|
|
16
|
+
children.map((child) => {
|
|
17
|
+
return `${key}.${child}`;
|
|
18
|
+
})
|
|
19
|
+
);
|
|
20
|
+
}, []);
|
|
21
|
+
}
|
|
22
|
+
const TranslationKeysSchema = z.z.enum(
|
|
23
|
+
getLeafFieldPath(translation.default)
|
|
24
|
+
);
|
|
25
|
+
exports.TranslationKeysSchema = TranslationKeysSchema;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const z = require("zod");
|
|
4
|
+
const Languages = {
|
|
5
|
+
arabic: "ar",
|
|
6
|
+
azerbaijani: "az",
|
|
7
|
+
czech: "cs",
|
|
8
|
+
german: "de",
|
|
9
|
+
greek: "el",
|
|
10
|
+
english: "en",
|
|
11
|
+
spanish: "es",
|
|
12
|
+
finnish: "fi",
|
|
13
|
+
french: "fr",
|
|
14
|
+
hindi: "hi",
|
|
15
|
+
hungarian: "hu",
|
|
16
|
+
indonesian: "id",
|
|
17
|
+
italian: "it",
|
|
18
|
+
japanese: "ja",
|
|
19
|
+
javanese: "jv",
|
|
20
|
+
korean: "ko",
|
|
21
|
+
malayalam: "ml",
|
|
22
|
+
malay: "ms",
|
|
23
|
+
dutch: "nl",
|
|
24
|
+
norwegian: "no",
|
|
25
|
+
polish: "pl",
|
|
26
|
+
portugeseBrazil: "pt-BR",
|
|
27
|
+
portuguese: "pt",
|
|
28
|
+
romanian: "ro",
|
|
29
|
+
russian: "ru",
|
|
30
|
+
serbian: "sr",
|
|
31
|
+
swedish: "sv",
|
|
32
|
+
thai: "th",
|
|
33
|
+
turkish: "tr",
|
|
34
|
+
ukrainian: "uk",
|
|
35
|
+
vietnamese: "vi",
|
|
36
|
+
chinese: "zh-CN"
|
|
37
|
+
};
|
|
38
|
+
const LanguageSchema = z.enum(
|
|
39
|
+
Object.values(Languages)
|
|
40
|
+
);
|
|
41
|
+
exports.LanguageSchema = LanguageSchema;
|
|
42
|
+
exports.Languages = Languages;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const reactI18next = require("react-i18next");
|
|
3
|
+
const i18nFrontend = require("./i18nFrontend.cjs");
|
|
4
|
+
function useTranslation(options) {
|
|
5
|
+
const i18n = i18nFrontend.initializeI18n();
|
|
6
|
+
return reactI18next.useTranslation("translation", { i18n, ...options });
|
|
7
|
+
}
|
|
8
|
+
module.exports = useTranslation;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const isClientSide = () => {
|
|
4
|
+
return !!(typeof window !== "undefined" && window.document && window.document.createElement);
|
|
5
|
+
};
|
|
6
|
+
const isServerSide = () => {
|
|
7
|
+
return !isClientSide();
|
|
8
|
+
};
|
|
9
|
+
exports.isClientSide = isClientSide;
|
|
10
|
+
exports.isServerSide = isServerSide;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const i18nSharedOptions: {
|
|
2
|
+
debug: boolean;
|
|
3
|
+
fallbackLng: string | undefined;
|
|
4
|
+
namespace: string;
|
|
5
|
+
supportedLngs: ("ar" | "az" | "cs" | "de" | "el" | "en" | "es" | "fi" | "fr" | "hi" | "hu" | "id" | "it" | "ja" | "jv" | "ko" | "ml" | "ms" | "nl" | "no" | "pl" | "pt-BR" | "pt" | "ro" | "ru" | "sr" | "sv" | "th" | "tr" | "uk" | "vi" | "zh-CN")[];
|
|
6
|
+
nonExplicitSupportedLngs: boolean;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=i18SharedOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18SharedOptions.d.ts","sourceRoot":"","sources":["../src/i18SharedOptions.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,iBAAiB;;;;;;CAM7B,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Languages, LanguageSchema } from "./translations.js";
|
|
2
|
+
const i18nSharedOptions = {
|
|
3
|
+
debug: process.env.PROSOPO_LOG_LEVEL === "debug",
|
|
4
|
+
fallbackLng: LanguageSchema.enum.en,
|
|
5
|
+
namespace: "translation",
|
|
6
|
+
supportedLngs: Object.values(Languages),
|
|
7
|
+
nonExplicitSupportedLngs: false
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
i18nSharedOptions
|
|
11
|
+
};
|
package/dist/i18nBackend.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import i18n from "i18next";
|
|
2
|
+
export declare function initializeI18n(i18nLoadedCallback?: (value: typeof i18n) => void): import("i18next").i18n;
|
|
2
3
|
export default initializeI18n;
|
|
3
4
|
//# sourceMappingURL=i18nBackend.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18nBackend.d.ts","sourceRoot":"","sources":["../src/i18nBackend.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"i18nBackend.d.ts","sourceRoot":"","sources":["../src/i18nBackend.ts"],"names":[],"mappings":"AAeA,OAAO,IAAI,MAAM,SAAS,CAAC;AAY3B,wBAAgB,cAAc,CAC7B,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,IAAI,KAAK,IAAI,0BAsBjD;AAED,eAAe,cAAc,CAAC"}
|
package/dist/i18nBackend.js
CHANGED
|
@@ -1,30 +1,32 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import i18n from "i18next";
|
|
3
3
|
import FSBackend from "i18next-fs-backend/cjs";
|
|
4
|
-
import { LanguageDetector
|
|
5
|
-
import {
|
|
4
|
+
import { LanguageDetector } from "i18next-http-middleware";
|
|
5
|
+
import { i18nSharedOptions } from "./i18SharedOptions.js";
|
|
6
6
|
import { isServerSide } from "./util.js";
|
|
7
|
-
const loadPath = `${path.dirname(import.meta.url)}/locales/{{lng}}/{{ns}}.json`.replace(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
7
|
+
const loadPath = `${path.dirname(import.meta.url)}/locales/{{lng}}/{{ns}}.json`.replace(
|
|
8
|
+
"file://",
|
|
9
|
+
""
|
|
10
|
+
);
|
|
11
|
+
function initializeI18n(i18nLoadedCallback) {
|
|
12
|
+
if (!i18n.isInitialized && isServerSide()) {
|
|
13
|
+
const lngDetector = new LanguageDetector(null, {
|
|
14
|
+
order: ["header", "query", "cookie"]
|
|
15
|
+
});
|
|
16
|
+
i18n.use(FSBackend).use(lngDetector).init({
|
|
17
|
+
...i18nSharedOptions,
|
|
18
|
+
ns: ["translation"],
|
|
19
|
+
backend: {
|
|
20
|
+
loadPath
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
i18n.on("loaded", () => {
|
|
24
|
+
i18nLoadedCallback?.(i18n);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return i18n;
|
|
28
28
|
}
|
|
29
|
-
export
|
|
30
|
-
|
|
29
|
+
export {
|
|
30
|
+
initializeI18n as default,
|
|
31
|
+
initializeI18n
|
|
32
|
+
};
|
package/dist/i18nFrontend.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import i18n from "i18next";
|
|
2
|
+
export declare function initializeI18n(i18nLoadedCallback?: (value: typeof i18n) => void): import("i18next").i18n;
|
|
2
3
|
export default initializeI18n;
|
|
3
4
|
//# sourceMappingURL=i18nFrontend.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18nFrontend.d.ts","sourceRoot":"","sources":["../src/i18nFrontend.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"i18nFrontend.d.ts","sourceRoot":"","sources":["../src/i18nFrontend.ts"],"names":[],"mappings":"AAcA,OAAO,IAA0B,MAAM,SAAS,CAAC;AAuBjD,wBAAgB,cAAc,CAC7B,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,IAAI,KAAK,IAAI,0BAwCjD;AAED,eAAe,cAAc,CAAC"}
|
package/dist/i18nFrontend.js
CHANGED
|
@@ -4,46 +4,56 @@ import ChainedBackend from "i18next-chained-backend";
|
|
|
4
4
|
import HttpBackend from "i18next-http-backend";
|
|
5
5
|
import resourcesToBackend from "i18next-resources-to-backend";
|
|
6
6
|
import { initReactI18next } from "react-i18next";
|
|
7
|
-
import {
|
|
7
|
+
import { i18nSharedOptions } from "./i18SharedOptions.js";
|
|
8
8
|
const reactOptions = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
react: {
|
|
10
|
+
useSuspense: true
|
|
11
|
+
},
|
|
12
|
+
detection: {
|
|
13
|
+
order: ["navigator", "htmlTag", "path", "subdomain"],
|
|
14
|
+
caches: ["localStorage", "cookie"]
|
|
15
|
+
}
|
|
16
16
|
};
|
|
17
17
|
const getLoadPath = (language, namespace) => {
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
const filename = import.meta.url.split("/").pop();
|
|
19
|
+
return `${import.meta.url.replace(`/${filename}`, "")}/locales/${language}/${namespace}.json`;
|
|
20
20
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
21
|
+
function initializeI18n(i18nLoadedCallback) {
|
|
22
|
+
if (!i18n.isInitialized) {
|
|
23
|
+
i18n.use(ChainedBackend).use(
|
|
24
|
+
new I18nextBrowserLanguageDetector(null, {
|
|
25
|
+
order: ["cookie", "localStorage", "navigator"],
|
|
26
|
+
lookupQuerystring: "lng",
|
|
27
|
+
lookupCookie: "i18next",
|
|
28
|
+
lookupLocalStorage: "i18nextLng",
|
|
29
|
+
caches: ["localStorage", "cookie"]
|
|
30
|
+
})
|
|
31
|
+
).use(initReactI18next).init({
|
|
32
|
+
...i18nSharedOptions,
|
|
33
|
+
backend: {
|
|
34
|
+
backends: [
|
|
35
|
+
HttpBackend,
|
|
36
|
+
// if a namespace can't be loaded via normal http-backend loadPath, then the inMemoryLocalBackend will try to return the correct resources
|
|
37
|
+
// with dynamic import, you have to use the "default" key of the module ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#importing_defaults )
|
|
38
|
+
resourcesToBackend(
|
|
39
|
+
(language, namespace) => import(getLoadPath(language, namespace))
|
|
40
|
+
)
|
|
41
|
+
],
|
|
42
|
+
backendOptions: [
|
|
43
|
+
{
|
|
44
|
+
loadPath: getLoadPath("{{lng}}", "{{ns}}")
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
...reactOptions
|
|
49
|
+
});
|
|
50
|
+
i18n.on("loaded", () => {
|
|
51
|
+
i18nLoadedCallback?.(i18n);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
return i18n;
|
|
47
55
|
}
|
|
48
|
-
export
|
|
49
|
-
|
|
56
|
+
export {
|
|
57
|
+
initializeI18n as default,
|
|
58
|
+
initializeI18n
|
|
59
|
+
};
|
package/dist/i18nMiddleware.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { handle } from "i18next-http-middleware";
|
|
2
2
|
import loadI18next from "./loadI18next.js";
|
|
3
3
|
async function i18nMiddleware(options) {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const i18n = await loadI18next(true);
|
|
5
|
+
return handle(i18n, { ...options });
|
|
6
6
|
}
|
|
7
|
-
export
|
|
8
|
-
|
|
7
|
+
export {
|
|
8
|
+
i18nMiddleware as default
|
|
9
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { default as default2 } from "./i18nMiddleware.js";
|
|
2
|
+
import { default as default3 } from "./loadI18next.js";
|
|
3
|
+
import { LanguageSchema, Languages } from "./translations.js";
|
|
4
|
+
import { isClientSide } from "./util.js";
|
|
5
|
+
import { TranslationKeysSchema } from "./translationKey.js";
|
|
6
|
+
import { default as default4 } from "./useTranslation.js";
|
|
7
|
+
export {
|
|
8
|
+
LanguageSchema,
|
|
9
|
+
Languages,
|
|
10
|
+
TranslationKeysSchema,
|
|
11
|
+
default2 as i18nMiddleware,
|
|
12
|
+
isClientSide,
|
|
13
|
+
default3 as loadI18next,
|
|
14
|
+
default4 as useTranslation
|
|
15
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadI18next.d.ts","sourceRoot":"","sources":["../src/loadI18next.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAEpC,iBAAe,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"loadI18next.d.ts","sourceRoot":"","sources":["../src/loadI18next.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAEpC,iBAAe,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CA4B1D;AAED,YAAY,EAAE,IAAI,IAAI,KAAK,EAAE,CAAC;AAE9B,eAAe,WAAW,CAAC"}
|