@nimpl/i18n 0.0.0-experimental-480e42f → 0.0.0-experimental-0308d9d
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/dist/cjs/client-translation.js +15 -0
- package/dist/cjs/client-translation.js.map +1 -0
- package/{initialize.d.ts → dist/cjs/initialize.d.ts} +2 -2
- package/dist/{initialize.js → cjs/initialize.js} +17 -18
- package/dist/cjs/initialize.js.map +1 -0
- package/dist/cjs/lib/client-context.d.ts +7 -0
- package/dist/cjs/lib/client-context.js +9 -0
- package/dist/cjs/lib/client-context.js.map +1 -0
- package/dist/cjs/lib/client-provider.d.ts +10 -0
- package/dist/cjs/lib/client-provider.js +16 -0
- package/dist/cjs/lib/client-provider.js.map +1 -0
- package/dist/cjs/lib/format-translate.d.ts +6 -0
- package/dist/cjs/lib/format-translate.js +18 -0
- package/dist/cjs/lib/format-translate.js.map +1 -0
- package/dist/cjs/lib/get-translation-core.d.ts +11 -0
- package/dist/cjs/lib/get-translation-core.js +27 -0
- package/dist/cjs/lib/get-translation-core.js.map +1 -0
- package/dist/cjs/lib/inject-query.d.ts +8 -0
- package/dist/{lib → cjs/lib}/inject-query.js +4 -3
- package/dist/cjs/lib/inject-query.js.map +1 -0
- package/dist/cjs/lib/parse-entities.d.ts +1 -0
- package/dist/cjs/lib/translation-core.d.ts +13 -0
- package/dist/cjs/lib/translation-core.js +14 -0
- package/dist/cjs/lib/translation-core.js.map +1 -0
- package/dist/cjs/lib/translation.d.ts +11 -0
- package/dist/{lib → cjs/lib}/translation.js +9 -10
- package/dist/cjs/lib/translation.js.map +1 -0
- package/dist/cjs/lib/transmitter-core.d.ts +10 -0
- package/dist/cjs/lib/transmitter-core.js +37 -0
- package/dist/cjs/lib/transmitter-core.js.map +1 -0
- package/dist/{use-translation.js → cjs/use-translation.js} +11 -10
- package/dist/cjs/use-translation.js.map +1 -0
- package/dist/esm/client-translation.d.ts +11 -0
- package/dist/esm/client-translation.mjs +13 -0
- package/dist/esm/client-translation.mjs.map +1 -0
- package/dist/esm/initialize.d.ts +17 -0
- package/dist/esm/initialize.mjs +85 -0
- package/dist/esm/initialize.mjs.map +1 -0
- package/dist/esm/lib/client-context.d.ts +7 -0
- package/dist/esm/lib/client-context.mjs +7 -0
- package/dist/esm/lib/client-context.mjs.map +1 -0
- package/dist/esm/lib/client-provider.d.ts +10 -0
- package/dist/esm/lib/client-provider.mjs +14 -0
- package/dist/esm/lib/client-provider.mjs.map +1 -0
- package/dist/esm/lib/format-translate.d.ts +6 -0
- package/dist/esm/lib/format-translate.mjs +16 -0
- package/dist/esm/lib/format-translate.mjs.map +1 -0
- package/dist/esm/lib/get-translation-core.d.ts +11 -0
- package/dist/esm/lib/get-translation-core.mjs +25 -0
- package/dist/esm/lib/get-translation-core.mjs.map +1 -0
- package/dist/esm/lib/inject-query.d.ts +8 -0
- package/dist/esm/lib/inject-query.mjs +30 -0
- package/dist/esm/lib/inject-query.mjs.map +1 -0
- package/dist/esm/lib/parse-entities.d.ts +1 -0
- package/dist/esm/lib/translation-core.d.ts +13 -0
- package/dist/esm/lib/translation-core.mjs +12 -0
- package/dist/esm/lib/translation-core.mjs.map +1 -0
- package/dist/esm/lib/translation.d.ts +11 -0
- package/dist/esm/lib/translation.mjs +90 -0
- package/dist/esm/lib/translation.mjs.map +1 -0
- package/dist/esm/lib/transmitter-core.d.ts +10 -0
- package/dist/esm/lib/transmitter-core.mjs +35 -0
- package/dist/esm/lib/transmitter-core.mjs.map +1 -0
- package/dist/esm/types.d.ts +32 -0
- package/dist/esm/use-translation.d.ts +9 -0
- package/dist/esm/use-translation.mjs +35 -0
- package/dist/esm/use-translation.mjs.map +1 -0
- package/package.json +43 -15
- package/dist/client-translation.js +0 -16
- package/dist/lib/client-context.js +0 -6
- package/dist/lib/client-provider.js +0 -47
- package/dist/lib/format-translate.js +0 -16
- package/dist/lib/get-translation-core.js +0 -28
- package/dist/lib/parse-entities.js +0 -8
- package/dist/lib/translation-core.js +0 -15
- package/dist/lib/transmitter-core.js +0 -38
- package/dist/types.js +0 -2
- package/env.d.ts +0 -1
- /package/{client-translation.d.ts → dist/cjs/client-translation.d.ts} +0 -0
- /package/{types.d.ts → dist/cjs/types.d.ts} +0 -0
- /package/{use-translation.d.ts → dist/cjs/use-translation.d.ts} +0 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { getTranslationCore } from './lib/get-translation-core.mjs';
|
|
3
|
+
import { TranslationCore } from './lib/translation-core.mjs';
|
|
4
|
+
import { TransmitterCore } from './lib/transmitter-core.mjs';
|
|
5
|
+
|
|
6
|
+
const initialize = (config) => {
|
|
7
|
+
const cache = new Map();
|
|
8
|
+
const loadTranslates = async (language, revalidate) => {
|
|
9
|
+
const item = cache.get(language);
|
|
10
|
+
if (!revalidate && item)
|
|
11
|
+
return item;
|
|
12
|
+
if (item && "then" in item) {
|
|
13
|
+
return item;
|
|
14
|
+
}
|
|
15
|
+
const newData = await config.load(language);
|
|
16
|
+
cache.set(language, newData);
|
|
17
|
+
return newData;
|
|
18
|
+
};
|
|
19
|
+
const getTranslation = async (options) => {
|
|
20
|
+
const { language, ...rest } = options || {};
|
|
21
|
+
const targetLanguage = language || (await config.getLanguage());
|
|
22
|
+
let dictionary;
|
|
23
|
+
if (config.cache) {
|
|
24
|
+
dictionary = await loadTranslates(targetLanguage);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
dictionary = await revalidate(targetLanguage);
|
|
28
|
+
}
|
|
29
|
+
if (!targetLanguage) {
|
|
30
|
+
throw new Error("Unable to get the language in getTranslation. Please check the getLanguage method in the configuration file or pass the language as an argument.");
|
|
31
|
+
}
|
|
32
|
+
return getTranslationCore({ ...rest, language: targetLanguage, dictionary });
|
|
33
|
+
};
|
|
34
|
+
const ServerTranslation = async (props) => {
|
|
35
|
+
const { language, ...rest } = props || {};
|
|
36
|
+
const targetLanguage = language || (await config.getLanguage());
|
|
37
|
+
let dictionary;
|
|
38
|
+
if (config.cache) {
|
|
39
|
+
dictionary = await loadTranslates(targetLanguage);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
dictionary = await revalidate(targetLanguage);
|
|
43
|
+
}
|
|
44
|
+
if (!targetLanguage) {
|
|
45
|
+
throw new Error("Unable to get the language in ServerTranslation. Please check the getLanguage method in the configuration file or pass the language as an argument.");
|
|
46
|
+
}
|
|
47
|
+
return React.createElement(TranslationCore, { ...rest, language: targetLanguage, dictionary: dictionary });
|
|
48
|
+
};
|
|
49
|
+
const Transmitter = async (options) => {
|
|
50
|
+
const { language, ...rest } = options || {};
|
|
51
|
+
const targetLanguage = language || (await config.getLanguage());
|
|
52
|
+
let dictionary;
|
|
53
|
+
if (config.cache) {
|
|
54
|
+
dictionary = await loadTranslates(targetLanguage);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
dictionary = await revalidate(targetLanguage);
|
|
58
|
+
}
|
|
59
|
+
if (!targetLanguage) {
|
|
60
|
+
throw new Error("Unable to get the language in Transmitter. Please check the getLanguage method in the configuration file or pass the language as an argument.");
|
|
61
|
+
}
|
|
62
|
+
return React.createElement(TransmitterCore, { ...rest, language: targetLanguage, dictionary: dictionary });
|
|
63
|
+
};
|
|
64
|
+
const revalidate = async (language, background = false) => {
|
|
65
|
+
const item = cache.get(language);
|
|
66
|
+
if (item && "then" in item)
|
|
67
|
+
return item;
|
|
68
|
+
if (background) {
|
|
69
|
+
const newData = await loadTranslates(language, true);
|
|
70
|
+
return newData;
|
|
71
|
+
}
|
|
72
|
+
const newDataPromise = loadTranslates(language, true);
|
|
73
|
+
cache.set(language, newDataPromise);
|
|
74
|
+
return newDataPromise;
|
|
75
|
+
};
|
|
76
|
+
return {
|
|
77
|
+
Transmitter,
|
|
78
|
+
ServerTranslation,
|
|
79
|
+
getTranslation,
|
|
80
|
+
revalidate,
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export { initialize };
|
|
85
|
+
//# sourceMappingURL=initialize.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initialize.mjs","sources":["../../../src/initialize.tsx"],"sourcesContent":["import React from \"react\";\n\nimport { type Config, type Translates } from \"./types\";\nimport { getTranslationCore, type GetTranslationCoreOptions } from \"./lib/get-translation-core\";\nimport { TranslationCore, type TranslationCoreProps } from \"./lib/translation-core\";\nimport { TransmitterCore, type TransmitterCoreProps } from \"./lib/transmitter-core\";\n\nexport const initialize = (config: Config) => {\n const cache = new Map<string, Translates | Promise<Translates>>();\n\n const loadTranslates = async (language: string, revalidate?: boolean) => {\n const item = cache.get(language);\n\n if (!revalidate && item) return item;\n\n if (item && \"then\" in item) {\n return item;\n }\n\n const newData = await config.load(language);\n cache.set(language, newData);\n return newData;\n };\n\n const getTranslation = async (\n options?: Omit<GetTranslationCoreOptions, \"dictionary\" | \"language\"> & { language?: string },\n ) => {\n const { language, ...rest } = options || {};\n const targetLanguage = language || (await config.getLanguage());\n let dictionary: Translates;\n if (config.cache) {\n dictionary = await loadTranslates(targetLanguage);\n } else {\n dictionary = await revalidate(targetLanguage);\n }\n\n if (!targetLanguage) {\n throw new Error(\n \"Unable to get the language in getTranslation. Please check the getLanguage method in the configuration file or pass the language as an argument.\",\n );\n }\n\n return getTranslationCore({ ...rest, language: targetLanguage, dictionary });\n };\n\n const ServerTranslation = async (\n props: Omit<TranslationCoreProps, \"dictionary\" | \"language\"> & { language?: string },\n ) => {\n const { language, ...rest } = props || {};\n const targetLanguage = language || (await config.getLanguage());\n let dictionary: Translates;\n if (config.cache) {\n dictionary = await loadTranslates(targetLanguage);\n } else {\n dictionary = await revalidate(targetLanguage);\n }\n\n if (!targetLanguage) {\n throw new Error(\n \"Unable to get the language in ServerTranslation. Please check the getLanguage method in the configuration file or pass the language as an argument.\",\n );\n }\n\n return <TranslationCore {...rest} language={targetLanguage} dictionary={dictionary} />;\n };\n\n const Transmitter = async (\n options: Omit<TransmitterCoreProps, \"dictionary\" | \"language\"> & { language?: string },\n ) => {\n const { language, ...rest } = options || {};\n const targetLanguage = language || (await config.getLanguage());\n let dictionary: Translates;\n if (config.cache) {\n dictionary = await loadTranslates(targetLanguage);\n } else {\n dictionary = await revalidate(targetLanguage);\n }\n\n if (!targetLanguage) {\n throw new Error(\n \"Unable to get the language in Transmitter. Please check the getLanguage method in the configuration file or pass the language as an argument.\",\n );\n }\n\n return <TransmitterCore {...rest} language={targetLanguage} dictionary={dictionary} />;\n };\n\n const revalidate = async (language: string, background: boolean = false) => {\n const item = cache.get(language);\n if (item && \"then\" in item) return item;\n\n if (background) {\n const newData = await loadTranslates(language, true);\n return newData;\n }\n\n const newDataPromise = loadTranslates(language, true);\n cache.set(language, newDataPromise);\n return newDataPromise;\n };\n\n return {\n Transmitter,\n ServerTranslation,\n getTranslation,\n revalidate,\n };\n};\n"],"names":[],"mappings":";;;;;AAOO,MAAM,UAAU,GAAG,CAAC,MAAc,KAAI;AACzC,IAAA,MAAM,KAAK,GAAG,IAAI,GAAG,EAA4C;IAEjE,MAAM,cAAc,GAAG,OAAO,QAAgB,EAAE,UAAoB,KAAI;QACpE,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC;QAEhC,IAAI,CAAC,UAAU,IAAI,IAAI;AAAE,YAAA,OAAO,IAAI;AAEpC,QAAA,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI,EAAE;AACxB,YAAA,OAAO,IAAI;QACf;QAEA,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;AAC3C,QAAA,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC;AAC5B,QAAA,OAAO,OAAO;AAClB,IAAA,CAAC;AAED,IAAA,MAAM,cAAc,GAAG,OACnB,OAA4F,KAC5F;QACA,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,IAAI,EAAE;QAC3C,MAAM,cAAc,GAAG,QAAQ,KAAK,MAA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AAW,EAAE,CAAC;AAC/D,QAAA,IAAI,UAAsB;AAC1B,QAAA,IAAI,MAAM,CAAC,KAAK,EAAE;AACd,YAAA,UAAU,GAAG,MAAM,cAAc,CAAC,cAAc,CAAC;QACrD;aAAO;AACH,YAAA,UAAU,GAAG,MAAM,UAAU,CAAC,cAAc,CAAC;QACjD;QAEA,IAAI,CAAC,cAAc,EAAE;AACjB,YAAA,MAAM,IAAI,KAAK,CACX,+IAA+I,CAClJ;QACL;AAEA,QAAA,OAAO,KAAA,CAAA,aAAA,CAAC,eAAe,EAAA,EAAA,GAAK,IAAI,EAAE,QAAQ,EAAE,cAAc,EAAE,UAAU,EAAE,UAAU,GAAI;AAC1F,IAAA,CAAC;IAED,MAAM,UAAU,GAAG,OAAO,QAAgB,EAAE,UAAA,GAAsB,KAAK,KAAI;QACvE,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC;AAChC,QAAA,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI;AAAE,YAAA,OAAO,IAAI;QAEvC,IAAI,UAAU,EAAE;YACZ,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,QAAQ,EAAE,IAAI,CAAC;AACpD,YAAA,OAAO,OAAO;QAClB;QAEA,MAAM,cAAc,GAAG,cAAc,CAAC,QAAQ,EAAE,IAAI,CAAC;AACrD,QAAA,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,cAAc,CAAC;AACnC,QAAA,OAAO,cAAc;AACzB,IAAA,CAAC;IAED,OAAO;QACH,WAAW;QACX,iBAAiB;QACjB,cAAc;QACd,UAAU;KACb;AACL;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-context.mjs","sources":["../../../../src/lib/client-context.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext } from \"react\";\n\nexport type ClientContextType = { language: string; translates: { [key: string]: string } } | null;\n\nexport const ClientContext = createContext<ClientContextType>(null);\n"],"names":[],"mappings":";;;MAMa,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAa,CAAA,CAAA,CAAG,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAa,CAAoB,CAAA,CAAA,CAAA,CAAI,CAAA;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React, { useContext } from 'react';
|
|
3
|
+
import { ClientContext } from './client-context.mjs';
|
|
4
|
+
|
|
5
|
+
const ClientProvider = ({ translates, children, language, cleanThread }) => {
|
|
6
|
+
const prevTranslates = useContext(ClientContext);
|
|
7
|
+
if (cleanThread) {
|
|
8
|
+
Object.assign(translates, prevTranslates === null || prevTranslates === void 0 ? void 0 : prevTranslates.translates);
|
|
9
|
+
}
|
|
10
|
+
return React.createElement(ClientContext.Provider, { value: { language, translates } }, children);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { ClientProvider };
|
|
14
|
+
//# sourceMappingURL=client-provider.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-provider.mjs","sources":["../../../../src/lib/client-provider.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { useContext } from \"react\";\n\nimport { ClientContext } from \"./client-context\";\n\nexport type ClientProviderProps = {\n translates: { [key: string]: string };\n language: string;\n children: React.ReactNode;\n cleanThread?: boolean;\n};\n\nexport const ClientProvider: React.FC<ClientProviderProps> = ({ translates, children, language, cleanThread }) => {\n const prevTranslates = useContext(ClientContext);\n\n if (cleanThread) {\n Object.assign(translates, prevTranslates?.translates);\n }\n\n return <ClientContext.Provider value={{ language, translates }}>{children}</ClientContext.Provider>;\n};\n"],"names":[],"mappings":";;;;AAaO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAc,CAAA,CAAA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,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAa,CAAC,QAAQ,CAAA,GAAC,KAAK,CAAA,CAAE,CAAA,CAAE,QAAQ,CAAA,CAAE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAU,EAAE,CAAA,CAAA,CAAA,CAAG,QAAQ,CAA0B;AACvG,CAAA;;"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type InjectQueryArg } from "./inject-query";
|
|
2
|
+
export interface FormatTranslateOptions extends Omit<InjectQueryArg, "query"> {
|
|
3
|
+
parseEntities?: boolean;
|
|
4
|
+
query?: InjectQueryArg["query"];
|
|
5
|
+
}
|
|
6
|
+
export declare const formatTranslate: ({ term, text, removeUnusedQueries, query, parseEntities }: FormatTranslateOptions) => string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { decode } from 'html-entities';
|
|
2
|
+
import { injectQuery } from './inject-query.mjs';
|
|
3
|
+
|
|
4
|
+
const formatTranslate = ({ term, text, removeUnusedQueries, query, parseEntities }) => {
|
|
5
|
+
let newTranslate = text;
|
|
6
|
+
if (query) {
|
|
7
|
+
newTranslate = injectQuery({ text: newTranslate, query, removeUnusedQueries });
|
|
8
|
+
}
|
|
9
|
+
if (parseEntities === undefined || parseEntities === true) {
|
|
10
|
+
newTranslate = decode(newTranslate, { scope: "strict" });
|
|
11
|
+
}
|
|
12
|
+
return newTranslate;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { formatTranslate };
|
|
16
|
+
//# sourceMappingURL=format-translate.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-translate.mjs","sources":["../../../../src/lib/format-translate.ts"],"sourcesContent":["import { decode } from \"html-entities\";\n\nimport { injectQuery, type InjectQueryArg } from \"./inject-query\";\n\nexport interface FormatTranslateOptions extends Omit<InjectQueryArg, \"query\"> {\n parseEntities?: boolean;\n query?: InjectQueryArg[\"query\"];\n}\n\nexport const formatTranslate = ({ term, text, removeUnusedQueries, query, parseEntities }: FormatTranslateOptions) => {\n let newTranslate = text;\n if (query) {\n newTranslate = injectQuery({ term, text: newTranslate, query, removeUnusedQueries });\n }\n if (parseEntities === undefined || parseEntities === true) {\n newTranslate = decode(newTranslate, { scope: \"strict\" });\n }\n return newTranslate;\n};\n"],"names":[],"mappings":";;;AASO,MAAM,eAAe,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,mBAAmB,EAAE,KAAK,EAAE,aAAa,EAA0B,KAAI;IACjH,IAAI,YAAY,GAAG,IAAI;IACvB,IAAI,KAAK,EAAE;AACP,QAAA,YAAY,GAAG,WAAW,CAAC,EAAQ,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,mBAAmB,EAAE,CAAC;IACxF;IACA,IAAI,aAAa,KAAK,SAAS,IAAI,aAAa,KAAK,IAAI,EAAE;QACvD,YAAY,GAAG,MAAM,CAAC,YAAY,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;IAC5D;AACA,IAAA,OAAO,YAAY;AACvB;;;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Translates, type I18nOptions } from "../types";
|
|
2
|
+
export type GetTranslationCoreOptions = {
|
|
3
|
+
language: string;
|
|
4
|
+
namespace?: string;
|
|
5
|
+
dictionary: Translates;
|
|
6
|
+
};
|
|
7
|
+
export type GetTranslationCoreReturnType = {
|
|
8
|
+
t: (term: string, opts?: I18nOptions) => string;
|
|
9
|
+
language: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const getTranslationCore: (options: GetTranslationCoreOptions) => GetTranslationCoreReturnType;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import op from 'object-path';
|
|
2
|
+
import { formatTranslate } from './format-translate.mjs';
|
|
3
|
+
|
|
4
|
+
const getTranslationCore = (options) => {
|
|
5
|
+
const { language, namespace, dictionary } = options || {};
|
|
6
|
+
const namespaceDictionary = namespace ? op.get(dictionary, namespace) : dictionary;
|
|
7
|
+
const t = (term, opts) => {
|
|
8
|
+
let termDictionary = namespaceDictionary;
|
|
9
|
+
let termNamespace = namespace;
|
|
10
|
+
let termKey = term;
|
|
11
|
+
if (term.includes(":")) {
|
|
12
|
+
[termNamespace, termKey] = term.split(":");
|
|
13
|
+
termDictionary = op.get(dictionary, termNamespace);
|
|
14
|
+
}
|
|
15
|
+
const translation = op.get(termDictionary, termKey);
|
|
16
|
+
const fullTerm = `${termNamespace ? `${termNamespace}.` : ""}${termKey}`;
|
|
17
|
+
if (typeof translation !== "string" || !translation)
|
|
18
|
+
return fullTerm;
|
|
19
|
+
return formatTranslate({ term: fullTerm, text: translation, parseEntities: true, ...opts });
|
|
20
|
+
};
|
|
21
|
+
return { t, language };
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export { getTranslationCore };
|
|
25
|
+
//# sourceMappingURL=get-translation-core.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-translation-core.mjs","sources":["../../../../src/lib/get-translation-core.ts"],"sourcesContent":["import op from \"object-path\";\n\nimport { type Translates, type I18nOptions } from \"../types\";\nimport { formatTranslate } from \"./format-translate\";\n\nexport type GetTranslationCoreOptions = {\n language: string;\n namespace?: string;\n dictionary: Translates;\n};\nexport type GetTranslationCoreReturnType = { t: (term: string, opts?: I18nOptions) => string; language: string };\n\nexport const getTranslationCore = (options: GetTranslationCoreOptions): GetTranslationCoreReturnType => {\n const { language, namespace, dictionary } = options || {};\n\n const namespaceDictionary = namespace ? op.get(dictionary, namespace) : dictionary;\n\n const t: GetTranslationCoreReturnType[\"t\"] = (term, opts) => {\n let termDictionary = namespaceDictionary;\n let termNamespace = namespace;\n let termKey: string = term;\n\n if (term.includes(\":\")) {\n [termNamespace, termKey] = term.split(\":\");\n termDictionary = op.get(dictionary, termNamespace);\n }\n\n const translation = op.get(termDictionary, termKey);\n const fullTerm = `${termNamespace ? `${termNamespace}.` : \"\"}${termKey}`;\n\n if (typeof translation !== \"string\" || !translation) return fullTerm;\n\n return formatTranslate({ term: fullTerm, text: translation, parseEntities: true, ...opts });\n };\n\n return { t, language };\n};\n"],"names":[],"mappings":";;;AAYO,MAAM,kBAAkB,GAAG,CAAC,OAAkC,KAAkC;IACnG,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,OAAO,IAAI,EAAE;AAEzD,IAAA,MAAM,mBAAmB,GAAG,SAAS,GAAG,EAAE,CAAC,GAAG,CAAC,UAAU,EAAE,SAAS,CAAC,GAAG,UAAU;AAElF,IAAA,MAAM,CAAC,GAAsC,CAAC,IAAI,EAAE,IAAI,KAAI;QACxD,IAAI,cAAc,GAAG,mBAAmB;QACxC,IAAI,aAAa,GAAG,SAAS;QAC7B,IAAI,OAAO,GAAW,IAAI;AAE1B,QAAA,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YACpB,CAAC,aAAa,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC;YAC1C,cAAc,GAAG,EAAE,CAAC,GAAG,CAAC,UAAU,EAAE,aAAa,CAAC;QACtD;QAEA,MAAM,WAAW,GAAG,EAAE,CAAC,GAAG,CAAC,cAAc,EAAE,OAAO,CAAC;AACnD,QAAA,MAAM,QAAQ,GAAG,CAAA,EAAG,aAAa,GAAG,CAAA,EAAG,aAAa,CAAA,CAAA,CAAG,GAAG,EAAE,CAAA,EAAG,OAAO,EAAE;AAExE,QAAA,IAAI,OAAO,WAAW,KAAK,QAAQ,IAAI,CAAC,WAAW;AAAE,YAAA,OAAO,QAAQ;AAEpE,QAAA,OAAO,eAAe,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,aAAa,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,CAAC;AAC/F,IAAA,CAAC;AAED,IAAA,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE;AAC1B;;;;"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const injectQuery = ({ text, query, removeUnusedQueries }) => {
|
|
2
|
+
let result = "";
|
|
3
|
+
let i = 0;
|
|
4
|
+
while (i < text.length) {
|
|
5
|
+
if (text[i] === "{" && text[i + 1] === "{") {
|
|
6
|
+
const closeIndex = text.indexOf("}}", i + 2);
|
|
7
|
+
if (closeIndex !== -1) {
|
|
8
|
+
const key = text.slice(i + 2, closeIndex);
|
|
9
|
+
const value = query[key];
|
|
10
|
+
if (value !== undefined) {
|
|
11
|
+
result += value.toString();
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
console.warn(`Query key "${key}" not found in options for "${text}"`);
|
|
15
|
+
if (!removeUnusedQueries) {
|
|
16
|
+
result += text.slice(i, closeIndex + 2);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
i = closeIndex + 2;
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
result += text[i];
|
|
24
|
+
i++;
|
|
25
|
+
}
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { injectQuery };
|
|
30
|
+
//# sourceMappingURL=inject-query.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inject-query.mjs","sources":["../../../../src/lib/inject-query.ts"],"sourcesContent":["import { type Query } from \"../types\";\n\nexport type InjectQueryArg = {\n term: string;\n text: string;\n query: Query;\n removeUnusedQueries?: boolean;\n};\n\nexport const injectQuery = ({ text, query, removeUnusedQueries }: InjectQueryArg): string => {\n let result = \"\";\n let i = 0;\n\n while (i < text.length) {\n if (text[i] === \"{\" && text[i + 1] === \"{\") {\n const closeIndex = text.indexOf(\"}}\", i + 2);\n if (closeIndex !== -1) {\n const key = text.slice(i + 2, closeIndex);\n const value = query[key];\n if (value !== undefined) {\n result += value.toString();\n } else {\n console.warn(`Query key \"${key}\" not found in options for \"${text}\"`);\n if (!removeUnusedQueries) {\n result += text.slice(i, closeIndex + 2);\n }\n }\n i = closeIndex + 2;\n continue;\n }\n }\n result += text[i];\n i++;\n }\n\n return result;\n};\n"],"names":[],"mappings":"AASO,MAAM,WAAW,GAAG,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,mBAAmB,EAAkB,KAAY;IACxF,IAAI,MAAM,GAAG,EAAE;IACf,IAAI,CAAC,GAAG,CAAC;AAET,IAAA,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE;AACpB,QAAA,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE;AACxC,YAAA,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC;AAC5C,YAAA,IAAI,UAAU,KAAK,EAAE,EAAE;AACnB,gBAAA,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,UAAU,CAAC;AACzC,gBAAA,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC;AACxB,gBAAA,IAAI,KAAK,KAAK,SAAS,EAAE;AACrB,oBAAA,MAAM,IAAI,KAAK,CAAC,QAAQ,EAAE;gBAC9B;qBAAO;oBACH,OAAO,CAAC,IAAI,CAAC,CAAA,WAAA,EAAc,GAAG,CAAA,4BAAA,EAA+B,IAAI,CAAA,CAAA,CAAG,CAAC;oBACrE,IAAI,CAAC,mBAAmB,EAAE;wBACtB,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,GAAG,CAAC,CAAC;oBAC3C;gBACJ;AACA,gBAAA,CAAC,GAAG,UAAU,GAAG,CAAC;gBAClB;YACJ;QACJ;AACA,QAAA,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC;AACjB,QAAA,CAAC,EAAE;IACP;AAEA,IAAA,OAAO,MAAM;AACjB;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const parseEntities: (translate: string) => string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type Translates, type I18nOptions } from "../types";
|
|
3
|
+
import { type TranslationProps } from "./translation";
|
|
4
|
+
export type TranslationCoreProps = {
|
|
5
|
+
term: string;
|
|
6
|
+
language: string;
|
|
7
|
+
dictionary: Translates;
|
|
8
|
+
namespace?: string;
|
|
9
|
+
components?: TranslationProps["components"];
|
|
10
|
+
query?: I18nOptions["query"];
|
|
11
|
+
removeUnusedQueries?: I18nOptions["removeUnusedQueries"];
|
|
12
|
+
};
|
|
13
|
+
export declare const TranslationCore: React.FC<TranslationCoreProps>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Translation } from './translation.mjs';
|
|
3
|
+
import { getTranslationCore } from './get-translation-core.mjs';
|
|
4
|
+
|
|
5
|
+
const TranslationCore = ({ dictionary, namespace, term, components, query, removeUnusedQueries, language, }) => {
|
|
6
|
+
const { t } = getTranslationCore({ language, namespace, dictionary });
|
|
7
|
+
const text = t(term, { query, removeUnusedQueries });
|
|
8
|
+
return React.createElement(Translation, { term: term, text: text, components: components });
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { TranslationCore };
|
|
12
|
+
//# sourceMappingURL=translation-core.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"translation-core.mjs","sources":["../../../../src/lib/translation-core.tsx"],"sourcesContent":["import React from \"react\";\n\nimport { type Translates, type I18nOptions } from \"../types\";\nimport { Translation, type TranslationProps } from \"./translation\";\nimport { getTranslationCore } from \"./get-translation-core\";\n\nexport type TranslationCoreProps = {\n term: string;\n language: string;\n dictionary: Translates;\n namespace?: string;\n components?: TranslationProps[\"components\"];\n query?: I18nOptions[\"query\"];\n removeUnusedQueries?: I18nOptions[\"removeUnusedQueries\"];\n};\n\nexport const TranslationCore: React.FC<TranslationCoreProps> = ({\n dictionary,\n namespace,\n term,\n components,\n query,\n removeUnusedQueries,\n language,\n}) => {\n const { t } = getTranslationCore({ language, namespace, dictionary });\n const text = t(term, { query, removeUnusedQueries });\n\n return <Translation term={term} text={text} components={components} />;\n};\n"],"names":[],"mappings":";;;;MAgBa,eAAe,GAAmC,CAAC,EAC5D,UAAU,EACV,SAAS,EACT,IAAI,EACJ,UAAU,EACV,KAAK,EACL,mBAAmB,EACnB,QAAQ,GACX,KAAI;AACD,IAAA,MAAM,EAAE,CAAC,EAAE,GAAG,kBAAkB,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;AACrE,IAAA,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,mBAAmB,EAAE,CAAC;AAEpD,IAAA,OAAO,KAAA,CAAA,aAAA,CAAC,WAAW,EAAA,EAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,GAAI;AAC1E;;;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export type TranslationProps = {
|
|
3
|
+
term: string;
|
|
4
|
+
text: string;
|
|
5
|
+
components?: {
|
|
6
|
+
[key: string]: React.ComponentType<{
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
}>;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export declare const Translation: ({ term, text, components }: TranslationProps) => React.ReactNode[];
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
4
|
+
const parseTag = (tag) => {
|
|
5
|
+
const isSelfClosing = tag.endsWith("/>");
|
|
6
|
+
const isClosing = tag[1] === "/";
|
|
7
|
+
const start = isClosing ? 2 : 1;
|
|
8
|
+
const end = isSelfClosing
|
|
9
|
+
? tag.indexOf(" ") !== -1 && tag.indexOf(" ") < tag.length - 2
|
|
10
|
+
? tag.indexOf(" ")
|
|
11
|
+
: tag.length - 2
|
|
12
|
+
: tag.length - 1;
|
|
13
|
+
return {
|
|
14
|
+
name: tag.slice(start, end),
|
|
15
|
+
type: isSelfClosing ? "self" : isClosing ? "close" : "open",
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
const splitByTags = (text) => {
|
|
19
|
+
const parts = [];
|
|
20
|
+
const tags = [];
|
|
21
|
+
let current = "";
|
|
22
|
+
let i = 0;
|
|
23
|
+
while (i < text.length) {
|
|
24
|
+
if (text[i] === "<") {
|
|
25
|
+
const closeIndex = text.indexOf(">", i);
|
|
26
|
+
if (closeIndex !== -1) {
|
|
27
|
+
parts.push(current);
|
|
28
|
+
current = "";
|
|
29
|
+
tags.push(text.slice(i, closeIndex + 1));
|
|
30
|
+
i = closeIndex + 1;
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
current += text[i];
|
|
35
|
+
i++;
|
|
36
|
+
}
|
|
37
|
+
parts.push(current);
|
|
38
|
+
return { parts, tags };
|
|
39
|
+
};
|
|
40
|
+
const Translation = ({ term, text, components }) => {
|
|
41
|
+
const { parts: textParts, tags } = splitByTags(text);
|
|
42
|
+
const parts = textParts.map((el, i) => React.createElement(React.Fragment, { key: `p-${i}` }, el));
|
|
43
|
+
if (components) {
|
|
44
|
+
const openedTags = [];
|
|
45
|
+
tags.forEach((tag, tagIndex) => {
|
|
46
|
+
const { name: tagName, type: tagType } = parseTag(tag);
|
|
47
|
+
if (tagType === "self") {
|
|
48
|
+
const Component = components[tagName];
|
|
49
|
+
if (Component) {
|
|
50
|
+
parts.splice(tagIndex + 1, 1, React.createElement(Component, { key: `c-${tagIndex}` }));
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
console.warn(`Unknown component for term "${term}" - ${tagName}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else if (tagType === "close") {
|
|
57
|
+
const openedTagIndex = openedTags.findIndex((i) => i.tag === tagName);
|
|
58
|
+
if (openedTagIndex !== -1) {
|
|
59
|
+
const lastOpenedIndex = openedTags.length - 1 - openedTagIndex;
|
|
60
|
+
const openedTagsLength = openedTags.length;
|
|
61
|
+
for (let i = openedTagsLength; i > lastOpenedIndex; i--) {
|
|
62
|
+
const targetIndex = i - 1;
|
|
63
|
+
const targetTag = openedTags[targetIndex];
|
|
64
|
+
const Component = components[targetTag.tag];
|
|
65
|
+
if (Component) {
|
|
66
|
+
const children = parts
|
|
67
|
+
.slice(targetTag.position + 1, tagIndex + 1)
|
|
68
|
+
.filter((child) => Boolean(child &&
|
|
69
|
+
typeof child === "object" &&
|
|
70
|
+
"props" in child &&
|
|
71
|
+
child.props.children));
|
|
72
|
+
parts.splice(targetTag.position + 1, tagIndex - targetTag.position, React.createElement(Component, { key: `${tagIndex}-${targetIndex}` }, children));
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
console.warn(`Unknown component for term "${term}" - ${targetTag}`);
|
|
76
|
+
}
|
|
77
|
+
openedTags.splice(targetIndex, 1);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
openedTags.push({ tag: tagName, position: tagIndex });
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
return parts;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export { Translation };
|
|
90
|
+
//# sourceMappingURL=translation.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"translation.mjs","sources":["../../../../src/lib/translation.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport React from \"react\";\n\nexport type TranslationProps = {\n term: string;\n text: string;\n components?: { [key: string]: React.ComponentType<{ children?: React.ReactNode }> };\n};\n\ntype ParsedTag = {\n name: string;\n type: \"open\" | \"close\" | \"self\";\n};\n\nconst parseTag = (tag: string): ParsedTag => {\n const isSelfClosing = tag.endsWith(\"/>\");\n const isClosing = tag[1] === \"/\";\n const start = isClosing ? 2 : 1;\n const end = isSelfClosing\n ? tag.indexOf(\" \") !== -1 && tag.indexOf(\" \") < tag.length - 2\n ? tag.indexOf(\" \")\n : tag.length - 2\n : tag.length - 1;\n return {\n name: tag.slice(start, end),\n type: isSelfClosing ? \"self\" : isClosing ? \"close\" : \"open\",\n };\n};\n\nconst splitByTags = (text: string): { parts: string[]; tags: string[] } => {\n const parts: string[] = [];\n const tags: string[] = [];\n let current = \"\";\n let i = 0;\n\n while (i < text.length) {\n if (text[i] === \"<\") {\n const closeIndex = text.indexOf(\">\", i);\n if (closeIndex !== -1) {\n parts.push(current);\n current = \"\";\n tags.push(text.slice(i, closeIndex + 1));\n i = closeIndex + 1;\n continue;\n }\n }\n current += text[i];\n i++;\n }\n parts.push(current);\n\n return { parts, tags };\n};\n\nexport const Translation = ({ term, text, components }: TranslationProps): React.ReactNode[] => {\n const { parts: textParts, tags } = splitByTags(text);\n const parts = textParts.map((el, i) => <React.Fragment key={`p-${i}`}>{el}</React.Fragment>);\n\n if (components) {\n const openedTags: { tag: string; position: number }[] = [];\n tags.forEach((tag, tagIndex) => {\n const { name: tagName, type: tagType } = parseTag(tag);\n if (tagType === \"self\") {\n const Component = components[tagName as keyof typeof components];\n if (Component) {\n parts.splice(tagIndex + 1, 1, <Component key={`c-${tagIndex}`} />);\n } else {\n console.warn(`Unknown component for term \"${term}\" - ${tagName}`);\n }\n } else if (tagType === \"close\") {\n const openedTagIndex = openedTags.findIndex((i) => i.tag === tagName);\n if (openedTagIndex !== -1) {\n const lastOpenedIndex = openedTags.length - 1 - openedTagIndex;\n const openedTagsLength = openedTags.length;\n for (let i = openedTagsLength; i > lastOpenedIndex; i--) {\n const targetIndex = i - 1;\n const targetTag = openedTags[targetIndex];\n const Component = components[targetTag.tag as keyof typeof components];\n if (Component) {\n const children = parts\n .slice(targetTag.position + 1, tagIndex + 1)\n .filter((child) =>\n Boolean(\n child &&\n typeof child === \"object\" &&\n \"props\" in child &&\n (child.props as any).children,\n ),\n );\n parts.splice(\n targetTag.position + 1,\n tagIndex - targetTag.position,\n <Component key={`${tagIndex}-${targetIndex}`}>{children}</Component>,\n );\n } else {\n console.warn(`Unknown component for term \"${term}\" - ${targetTag}`);\n }\n openedTags.splice(targetIndex, 1);\n }\n }\n } else {\n openedTags.push({ tag: tagName, position: tagIndex });\n }\n });\n }\n\n return parts;\n};\n"],"names":[],"mappings":";;AAAA;AAeA,MAAM,QAAQ,GAAG,CAAC,GAAW,KAAe;IACxC,MAAM,aAAa,GAAG,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC;IACxC,MAAM,SAAS,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG;IAChC,MAAM,KAAK,GAAG,SAAS,GAAG,CAAC,GAAG,CAAC;IAC/B,MAAM,GAAG,GAAG;UACN,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,MAAM,GAAG;AACzD,cAAE,GAAG,CAAC,OAAO,CAAC,GAAG;AACjB,cAAE,GAAG,CAAC,MAAM,GAAG;AACnB,UAAE,GAAG,CAAC,MAAM,GAAG,CAAC;IACpB,OAAO;QACH,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC;AAC3B,QAAA,IAAI,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM;KAC9D;AACL,CAAC;AAED,MAAM,WAAW,GAAG,CAAC,IAAY,KAAyC;IACtE,MAAM,KAAK,GAAa,EAAE;IAC1B,MAAM,IAAI,GAAa,EAAE;IACzB,IAAI,OAAO,GAAG,EAAE;IAChB,IAAI,CAAC,GAAG,CAAC;AAET,IAAA,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,EAA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AAK,CAAC,KAAa,CAAC,QAAQ,CAChC,CACJ;AACL,4BAAA,KAAK,CAAC,MAAM,CACR,SAAS,CAAC,QAAQ,GAAG,CAAC,EACtB,QAAQ,GAAG,SAAS,CAAC,QAAQ,EAC7B,KAAA,CAAA,aAAA,CAAC,SAAS,EAAA,EAAC,GAAG,EAAE,CAAA,EAAG,QAAQ,CAAA,CAAA,EAAI,WAAW,CAAA,CAAE,EAAA,EAAG,QAAQ,CAAa,CACvE;wBACL;6BAAO;4BACH,OAAO,CAAC,IAAI,CAAC,CAAA,4BAAA,EAA+B,IAAI,CAAA,IAAA,EAAO,SAAS,CAAA,CAAE,CAAC;wBACvE;AACA,wBAAA,UAAU,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;oBACrC;gBACJ;YACJ;iBAAO;AACH,gBAAA,UAAU,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;YACzD;AACJ,QAAA,CAAC,CAAC;IACN;AAEA,IAAA,OAAO,KAAK;AAChB;;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type I18nOptions, type Translates } from "../types";
|
|
3
|
+
export type TransmitterCoreProps = {
|
|
4
|
+
dictionary: Translates;
|
|
5
|
+
language: string;
|
|
6
|
+
terms: (string | [string, I18nOptions])[];
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
cleanThread?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare const TransmitterCore: React.FC<TransmitterCoreProps>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import op from 'object-path';
|
|
3
|
+
import { ClientProvider } from './client-provider.mjs';
|
|
4
|
+
import { formatTranslate } from './format-translate.mjs';
|
|
5
|
+
|
|
6
|
+
const formatTranslates = (result, targetKey, translates, opts = {}) => {
|
|
7
|
+
if (!translates)
|
|
8
|
+
return;
|
|
9
|
+
if (typeof translates === "string") {
|
|
10
|
+
result[targetKey] = formatTranslate({ term: targetKey, text: translates, parseEntities: true, ...opts });
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
Object.entries(translates).forEach(([subKey, translate]) => {
|
|
14
|
+
formatTranslates(result, `${targetKey}.${subKey}`, translate, opts);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const TransmitterCore = async ({ dictionary, language, terms, children, cleanThread, }) => {
|
|
19
|
+
const result = {};
|
|
20
|
+
terms.forEach((term) => {
|
|
21
|
+
if (Array.isArray(term)) {
|
|
22
|
+
const [termKey, opts] = term;
|
|
23
|
+
const translates = op.get(dictionary, termKey);
|
|
24
|
+
formatTranslates(result, termKey, translates, opts);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
const translates = op.get(dictionary, term);
|
|
28
|
+
formatTranslates(result, term, translates);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return (React.createElement(ClientProvider, { language: language, translates: result, cleanThread: cleanThread }, children));
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { TransmitterCore };
|
|
35
|
+
//# sourceMappingURL=transmitter-core.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transmitter-core.mjs","sources":["../../../../src/lib/transmitter-core.tsx"],"sourcesContent":["import React from \"react\";\nimport op from \"object-path\";\n\nimport { type I18nOptions, type Translates } from \"../types\";\nimport { ClientProvider } from \"./client-provider\";\nimport { formatTranslate } from \"./format-translate\";\n\nexport type TransmitterCoreProps = {\n dictionary: Translates;\n language: string;\n terms: (string | [string, I18nOptions])[];\n children: React.ReactNode;\n cleanThread?: boolean;\n};\n\ntype ClientTranslates = { [key: string]: string };\n\nconst formatTranslates = (\n result: ClientTranslates,\n targetKey: string,\n translates: string | Translates,\n opts: I18nOptions = {},\n) => {\n if (!translates) return;\n\n if (typeof translates === \"string\") {\n result[targetKey] = formatTranslate({ term: targetKey, text: translates, parseEntities: true, ...opts });\n } else {\n Object.entries(translates).forEach(([subKey, translate]) => {\n formatTranslates(result, `${targetKey}.${subKey}`, translate, opts);\n });\n }\n};\n\nexport const TransmitterCore: React.FC<TransmitterCoreProps> = async ({\n dictionary,\n language,\n terms,\n children,\n cleanThread,\n}) => {\n const result: { [key: string]: string } = {};\n terms.forEach((term) => {\n if (Array.isArray(term)) {\n const [termKey, opts] = term;\n const translates = op.get(dictionary, termKey) as Translates;\n formatTranslates(result, termKey, translates, opts);\n } else {\n const translates = op.get(dictionary, term) as Translates;\n formatTranslates(result, term, translates);\n }\n });\n\n return (\n <ClientProvider language={language} translates={result} cleanThread={cleanThread}>\n {children}\n </ClientProvider>\n );\n};\n"],"names":[],"mappings":";;;;;AAiBA,MAAM,gBAAgB,GAAG,CACrB,MAAwB,EACxB,SAAiB,EACjB,UAA+B,EAC/B,IAAA,GAAoB,EAAE,KACtB;AACA,IAAA,IAAI,CAAC,UAAU;QAAE;AAEjB,IAAA,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE;QAChC,MAAM,CAAC,SAAS,CAAC,GAAG,eAAe,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,aAAa,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,CAAC;IAC5G;SAAO;AACH,QAAA,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,SAAS,CAAC,KAAI;AACvD,YAAA,gBAAgB,CAAC,MAAM,EAAE,CAAA,EAAG,SAAS,CAAA,CAAA,EAAI,MAAM,CAAA,CAAE,EAAE,SAAS,EAAE,IAAI,CAAC;AACvE,QAAA,CAAC,CAAC;IACN;AACJ,CAAC;AAEM,MAAM,eAAe,GAAmC,OAAO,EAClE,UAAU,EACV,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,WAAW,GACd,KAAI;IACD,MAAM,MAAM,GAA8B,EAAE;AAC5C,IAAA,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,KAAI;AACnB,QAAA,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;AACrB,YAAA,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,IAAI;YAC5B,MAAM,UAAU,GAAG,EAAE,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAe;YAC5D,gBAAgB,CAAC,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,CAAC;QACvD;aAAO;YACH,MAAM,UAAU,GAAG,EAAE,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAe;AACzD,YAAA,gBAAgB,CAAC,MAAM,EAAE,IAAI,EAAE,UAAU,CAAC;QAC9C;AACJ,IAAA,CAAC,CAAC;AAEF,IAAA,QACI,KAAA,CAAA,aAAA,CAAC,cAAc,IAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,IAC3E,QAAQ,CACI;AAEzB;;;;"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type Translates = {
|
|
2
|
+
[key: string]: Translates | string;
|
|
3
|
+
};
|
|
4
|
+
export type GetLangOpts = {
|
|
5
|
+
pathname: string | null;
|
|
6
|
+
params: {
|
|
7
|
+
[key: string]: string | string[];
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export type Query = {
|
|
11
|
+
[key: string]: string | number;
|
|
12
|
+
};
|
|
13
|
+
export type I18nOptions = {
|
|
14
|
+
query?: Query;
|
|
15
|
+
removeUnusedQueries?: boolean;
|
|
16
|
+
};
|
|
17
|
+
export type I18nContextType = {
|
|
18
|
+
lang: string;
|
|
19
|
+
translates: {
|
|
20
|
+
[key: string]: string;
|
|
21
|
+
};
|
|
22
|
+
} | null;
|
|
23
|
+
export type Meta = {
|
|
24
|
+
lastUpdated: number;
|
|
25
|
+
isRevalidated?: boolean;
|
|
26
|
+
} & Record<string, unknown>;
|
|
27
|
+
export type Config = {
|
|
28
|
+
load(key: string, meta?: Meta): Promise<Translates>;
|
|
29
|
+
getLanguage(): Promise<string>;
|
|
30
|
+
languages: string[];
|
|
31
|
+
cache?: boolean;
|
|
32
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type I18nOptions } from "./types";
|
|
2
|
+
type GetTranslationReturnType = {
|
|
3
|
+
t: (term: string, opts?: I18nOptions) => string;
|
|
4
|
+
language: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const useTranslation: ({ namespace }?: {
|
|
7
|
+
namespace?: string;
|
|
8
|
+
}) => GetTranslationReturnType;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { ClientContext } from './lib/client-context.mjs';
|
|
3
|
+
import { injectQuery } from './lib/inject-query.mjs';
|
|
4
|
+
|
|
5
|
+
const useTranslation = ({ namespace } = {}) => {
|
|
6
|
+
const context = useContext(ClientContext);
|
|
7
|
+
if (!context) {
|
|
8
|
+
throw new Error("Please, Init I18nTransmitter for client components - https://nimpl.dev/docs/i18n/usage#client-components");
|
|
9
|
+
}
|
|
10
|
+
const { language, translates } = context;
|
|
11
|
+
const t = (term, opts) => {
|
|
12
|
+
let termKey;
|
|
13
|
+
if (term.includes(":")) {
|
|
14
|
+
termKey = term.replace(":", ".");
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
termKey = `${namespace ? `${namespace}.` : ""}${term}`;
|
|
18
|
+
}
|
|
19
|
+
const translation = translates[termKey];
|
|
20
|
+
if (!translation)
|
|
21
|
+
return termKey;
|
|
22
|
+
if (opts === null || opts === void 0 ? void 0 : opts.query) {
|
|
23
|
+
return injectQuery({
|
|
24
|
+
text: translation,
|
|
25
|
+
query: opts.query,
|
|
26
|
+
removeUnusedQueries: opts.removeUnusedQueries,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return translation;
|
|
30
|
+
};
|
|
31
|
+
return { t, language };
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { useTranslation };
|
|
35
|
+
//# sourceMappingURL=use-translation.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-translation.mjs","sources":["../../../src/use-translation.ts"],"sourcesContent":["import { useContext } from \"react\";\n\nimport { type I18nOptions } from \"./types\";\nimport { ClientContext } from \"./lib/client-context\";\nimport { injectQuery } from \"./lib/inject-query\";\n\ntype GetTranslationReturnType = { t: (term: string, opts?: I18nOptions) => string; language: string };\n\nexport const useTranslation = ({ namespace }: { namespace?: string } = {}): GetTranslationReturnType => {\n const context = useContext(ClientContext);\n\n if (!context) {\n throw new Error(\n \"Please, Init I18nTransmitter for client components - https://nimpl.dev/docs/i18n/usage#client-components\",\n );\n }\n\n const { language, translates } = context;\n\n const t: GetTranslationReturnType[\"t\"] = (term, opts) => {\n let termKey: string;\n if (term.includes(\":\")) {\n termKey = term.replace(\":\", \".\");\n } else {\n termKey = `${namespace ? `${namespace}.` : \"\"}${term}`;\n }\n const translation = translates[termKey];\n\n if (!translation) return termKey;\n\n if (opts?.query) {\n return injectQuery({\n term,\n text: translation,\n query: opts.query,\n removeUnusedQueries: opts.removeUnusedQueries,\n });\n }\n\n return translation;\n };\n\n return { t, language };\n};\n"],"names":[],"mappings":";;;;AAQO,MAAM,cAAc,GAAG,CAAC,EAAE,SAAS,EAAA,GAA6B,EAAE,KAA8B;AACnG,IAAA,MAAM,OAAO,GAAG,UAAU,CAAC,aAAa,CAAC;IAEzC,IAAI,CAAC,OAAO,EAAE;AACV,QAAA,MAAM,IAAI,KAAK,CACX,0GAA0G,CAC7G;IACL;AAEA,IAAA,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,OAAO;AAExC,IAAA,MAAM,CAAC,GAAkC,CAAC,IAAI,EAAE,IAAI,KAAI;AACpD,QAAA,IAAI,OAAe;AACnB,QAAA,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YACpB,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC;QACpC;aAAO;AACH,YAAA,OAAO,GAAG,CAAA,EAAG,SAAS,GAAG,CAAA,EAAG,SAAS,CAAA,CAAA,CAAG,GAAG,EAAE,CAAA,EAAG,IAAI,EAAE;QAC1D;AACA,QAAA,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,CAAC;AAEvC,QAAA,IAAI,CAAC,WAAW;AAAE,YAAA,OAAO,OAAO;QAEhC,IAAI,IAAI,aAAJ,IAAI,KAAA,MAAA,GAAA,MAAA,GAAJ,IAAI,CAAE,KAAK,EAAE;AACb,YAAA,OAAO,WAAW,CAAC;gBAEf,IAAI,EAAE,WAAW;gBACjB,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,mBAAmB,EAAE,IAAI,CAAC,mBAAmB;AAChD,aAAA,CAAC;QACN;AAEA,QAAA,OAAO,WAAW;AACtB,IAAA,CAAC;AAED,IAAA,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE;AAC1B;;;;"}
|