@intlayer/core 1.0.0 → 1.0.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.
- package/dist/cjs/getLocaleName.cjs +8 -13
- package/dist/cjs/getLocaleName.d.ts +1 -1
- package/dist/cjs/index.cjs +20 -27
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.ts +12 -25
- package/dist/cjs/localeList.cjs +9 -14
- package/dist/cjs/localeList.d.ts +1 -1
- package/dist/cjs/transpiler/content_transformers/enumeration/enumeration.cjs +12 -17
- package/dist/cjs/transpiler/content_transformers/enumeration/enumeration.d.ts +6 -15
- package/dist/cjs/transpiler/content_transformers/enumeration/getEnumerationContent.cjs +14 -34
- package/dist/cjs/transpiler/content_transformers/enumeration/getEnumerationContent.d.ts +4 -7
- package/dist/cjs/transpiler/content_transformers/enumeration/index.cjs +11 -23
- package/dist/cjs/transpiler/content_transformers/enumeration/index.d.ts +4 -4
- package/dist/cjs/transpiler/content_transformers/index.cjs +11 -27
- package/dist/cjs/transpiler/content_transformers/index.d.ts +9 -15
- package/dist/cjs/transpiler/content_transformers/translation/getTranslationContent.cjs +9 -15
- package/dist/cjs/transpiler/content_transformers/translation/getTranslationContent.cjs.map +1 -1
- package/dist/cjs/transpiler/content_transformers/translation/getTranslationContent.d.ts +7 -8
- package/dist/cjs/transpiler/content_transformers/translation/index.cjs +13 -23
- package/dist/cjs/transpiler/content_transformers/translation/index.cjs.map +1 -1
- package/dist/cjs/transpiler/content_transformers/translation/index.d.ts +7 -5
- package/dist/cjs/transpiler/content_transformers/translation/{translations.cjs → translation.cjs} +17 -22
- package/dist/cjs/transpiler/content_transformers/translation/translation.cjs.map +1 -0
- package/dist/cjs/transpiler/content_transformers/translation/translation.d.ts +30 -0
- package/dist/cjs/transpiler/content_transformers/translation/types.cjs +17 -0
- package/dist/cjs/transpiler/content_transformers/translation/types.cjs.map +1 -0
- package/dist/cjs/transpiler/content_transformers/translation/types.d.ts +63 -0
- package/dist/cjs/transpiler/index.cjs +9 -22
- package/dist/cjs/transpiler/index.cjs.map +1 -1
- package/dist/cjs/transpiler/index.d.ts +9 -13
- package/dist/cjs/types/contentModule.cjs +4 -8
- package/dist/cjs/types/contentModule.d.ts +14 -28
- package/dist/cjs/types/index.cjs +9 -14
- package/dist/cjs/types/index.d.ts +7 -13
- package/dist/cjs/types/nodeType.cjs +8 -13
- package/dist/cjs/types/nodeType.d.ts +2 -2
- package/dist/cjs/utils/getStackTraceInfo.cjs +9 -14
- package/dist/cjs/utils/getStackTraceInfo.d.ts +3 -3
- package/dist/esm/getLocaleName.d.mts +1 -1
- package/dist/esm/getLocaleName.mjs +4 -2
- package/dist/esm/index.d.mts +12 -25
- package/dist/esm/index.mjs +7 -7
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/localeList.d.mts +1 -1
- package/dist/esm/localeList.mjs +5 -3
- package/dist/esm/transpiler/content_transformers/enumeration/enumeration.d.mts +6 -15
- package/dist/esm/transpiler/content_transformers/enumeration/enumeration.mjs +10 -6
- package/dist/esm/transpiler/content_transformers/enumeration/getEnumerationContent.d.mts +4 -7
- package/dist/esm/transpiler/content_transformers/enumeration/getEnumerationContent.mjs +10 -23
- package/dist/esm/transpiler/content_transformers/enumeration/index.d.mts +4 -4
- package/dist/esm/transpiler/content_transformers/enumeration/index.mjs +3 -3
- package/dist/esm/transpiler/content_transformers/index.d.mts +9 -15
- package/dist/esm/transpiler/content_transformers/index.mjs +3 -3
- package/dist/esm/transpiler/content_transformers/translation/getTranslationContent.d.mts +7 -8
- package/dist/esm/transpiler/content_transformers/translation/getTranslationContent.mjs +8 -5
- package/dist/esm/transpiler/content_transformers/translation/getTranslationContent.mjs.map +1 -1
- package/dist/esm/transpiler/content_transformers/translation/index.d.mts +7 -5
- package/dist/esm/transpiler/content_transformers/translation/index.mjs +4 -3
- package/dist/esm/transpiler/content_transformers/translation/index.mjs.map +1 -1
- package/dist/esm/transpiler/content_transformers/translation/translation.d.mts +30 -0
- package/dist/esm/transpiler/content_transformers/translation/{translations.mjs → translation.mjs} +10 -7
- package/dist/esm/transpiler/content_transformers/translation/translation.mjs.map +1 -0
- package/dist/esm/transpiler/content_transformers/translation/types.d.mts +63 -0
- package/dist/esm/transpiler/content_transformers/translation/types.mjs +1 -0
- package/dist/esm/transpiler/content_transformers/translation/types.mjs.map +1 -0
- package/dist/esm/transpiler/index.d.mts +9 -13
- package/dist/esm/transpiler/index.mjs +2 -3
- package/dist/esm/transpiler/index.mjs.map +1 -1
- package/dist/esm/types/contentModule.d.mts +14 -28
- package/dist/esm/types/contentModule.mjs +1 -1
- package/dist/esm/types/index.d.mts +7 -13
- package/dist/esm/types/index.mjs +5 -3
- package/dist/esm/types/nodeType.d.mts +2 -2
- package/dist/esm/types/nodeType.mjs +4 -2
- package/dist/esm/utils/getStackTraceInfo.d.mts +3 -3
- package/dist/esm/utils/getStackTraceInfo.mjs +5 -3
- package/package.json +8 -5
- package/src/index.ts +2 -0
- package/src/transpiler/content_transformers/translation/getTranslationContent.ts +9 -5
- package/src/transpiler/content_transformers/translation/index.ts +2 -1
- package/src/transpiler/content_transformers/translation/translation.ts +53 -0
- package/src/transpiler/content_transformers/translation/types.ts +72 -0
- package/src/transpiler/index.ts +1 -7
- package/dist/cjs/transpiler/content_transformers/translation/translations.cjs.map +0 -1
- package/dist/cjs/transpiler/content_transformers/translation/translations.d.ts +0 -17
- package/dist/esm/transpiler/content_transformers/translation/translations.d.mts +0 -17
- package/dist/esm/transpiler/content_transformers/translation/translations.mjs.map +0 -1
- package/src/transpiler/content_transformers/translation/translations.ts +0 -42
package/dist/esm/index.mjs
CHANGED
|
@@ -2,11 +2,11 @@ import {
|
|
|
2
2
|
t,
|
|
3
3
|
enu,
|
|
4
4
|
getTranslationContent,
|
|
5
|
-
getEnumerationContent
|
|
6
|
-
} from
|
|
7
|
-
import { NodeType } from
|
|
8
|
-
import { getLocaleName } from
|
|
9
|
-
import { localeList } from
|
|
5
|
+
getEnumerationContent
|
|
6
|
+
} from './transpiler/content_transformers/index.mjs';
|
|
7
|
+
import { NodeType } from './types/index.mjs';
|
|
8
|
+
import { getLocaleName } from './getLocaleName.mjs';
|
|
9
|
+
import { localeList } from './localeList.mjs';
|
|
10
10
|
export {
|
|
11
11
|
NodeType,
|
|
12
12
|
enu,
|
|
@@ -14,6 +14,6 @@ export {
|
|
|
14
14
|
getLocaleName,
|
|
15
15
|
getTranslationContent,
|
|
16
16
|
localeList,
|
|
17
|
-
t
|
|
17
|
+
t
|
|
18
18
|
};
|
|
19
|
-
//# sourceMappingURL=index.mjs.map
|
|
19
|
+
//# sourceMappingURL=index.mjs.map
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export type {\n LanguageContent,\n TranslationContent,\n EnumerationContent,\n QuantityContent,\n} from './transpiler/content_transformers/index';\nexport {\n t,\n enu,\n getTranslationContent,\n getEnumerationContent,\n} from './transpiler/content_transformers/index';\nexport type {\n ContentValue,\n Content,\n FlatContentValue,\n FlatContent,\n TypedNode,\n ContentModule,\n} from './types/index';\nexport { NodeType } from './types/index';\nexport { getLocaleName } from './getLocaleName';\nexport { localeList } from './localeList';\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export type {\n CustomizableLanguageContent,\n LanguageContent,\n TranslationContent,\n EnumerationContent,\n QuantityContent,\n CustomLocales as Locales,\n} from './transpiler/content_transformers/index';\nexport {\n t,\n enu,\n getTranslationContent,\n getEnumerationContent,\n} from './transpiler/content_transformers/index';\nexport type {\n ContentValue,\n Content,\n FlatContentValue,\n FlatContent,\n TypedNode,\n ContentModule,\n} from './types/index';\nexport { NodeType } from './types/index';\nexport { getLocaleName } from './getLocaleName';\nexport { localeList } from './localeList';\n"],"mappings":"AAQA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AASP,SAAS,gBAAgB;AACzB,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;","names":[]}
|
package/dist/esm/localeList.mjs
CHANGED
|
@@ -224,7 +224,9 @@ const localeList = [
|
|
|
224
224
|
Locales.CHINESE_MACAU,
|
|
225
225
|
Locales.CHINESE_SINGAPORE,
|
|
226
226
|
Locales.CHINESE_TRADITIONAL,
|
|
227
|
-
Locales.ZULU_SOUTH_AFRICA
|
|
227
|
+
Locales.ZULU_SOUTH_AFRICA
|
|
228
228
|
];
|
|
229
|
-
export {
|
|
230
|
-
|
|
229
|
+
export {
|
|
230
|
+
localeList
|
|
231
|
+
};
|
|
232
|
+
//# sourceMappingURL=localeList.mjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NoteStackTraceInfo } from
|
|
2
|
-
import { NodeType } from
|
|
1
|
+
import { NoteStackTraceInfo } from '../../../utils/getStackTraceInfo.mjs';
|
|
2
|
+
import { NodeType } from '../../../types/nodeType.mjs';
|
|
3
3
|
|
|
4
4
|
type Positif = number | `${number}`;
|
|
5
5
|
type Negatif = `-${number}`;
|
|
@@ -10,23 +10,14 @@ type Superior = `>${Numbers}`;
|
|
|
10
10
|
type SuperiorOrEqual = `>=${Numbers}`;
|
|
11
11
|
type Inferior = `<${Numbers}`;
|
|
12
12
|
type InferiorOrEqual = `<=${Numbers}`;
|
|
13
|
-
type EnterFormat =
|
|
14
|
-
| Equal
|
|
15
|
-
| EqualString
|
|
16
|
-
| Superior
|
|
17
|
-
| SuperiorOrEqual
|
|
18
|
-
| Inferior
|
|
19
|
-
| InferiorOrEqual;
|
|
13
|
+
type EnterFormat = Equal | EqualString | Superior | SuperiorOrEqual | Inferior | InferiorOrEqual;
|
|
20
14
|
type QuantityContent<Content> = Record<EnterFormat, Content>;
|
|
21
|
-
type EnumerationContent<Content> = Partial<QuantityContent<Content>> &
|
|
22
|
-
NoteStackTraceInfo & {
|
|
15
|
+
type EnumerationContent<Content> = Partial<QuantityContent<Content>> & NoteStackTraceInfo & {
|
|
23
16
|
nodeType: NodeType.Enumeration;
|
|
24
|
-
|
|
17
|
+
};
|
|
25
18
|
/**
|
|
26
19
|
* Create a JSON string with the content and the stack trace information
|
|
27
20
|
*/
|
|
28
|
-
declare const enumeration: <Content>(
|
|
29
|
-
content?: Partial<QuantityContent<Content>>
|
|
30
|
-
) => EnumerationContent<Content>;
|
|
21
|
+
declare const enumeration: <Content>(content?: Partial<QuantityContent<Content>>) => EnumerationContent<Content>;
|
|
31
22
|
|
|
32
23
|
export { type EnumerationContent, type QuantityContent, enumeration as enu };
|
|
@@ -1,21 +1,25 @@
|
|
|
1
|
-
import { NodeType } from
|
|
2
|
-
import {
|
|
1
|
+
import { NodeType } from '../../../types/index.mjs';
|
|
2
|
+
import {
|
|
3
|
+
getStackTraceInfo
|
|
4
|
+
} from '../../../utils/getStackTraceInfo.mjs';
|
|
3
5
|
const enumeration = (content) => {
|
|
4
6
|
const stackTraceInfo = getStackTraceInfo();
|
|
5
7
|
if (typeof content === "string") {
|
|
6
8
|
const result2 = {
|
|
7
9
|
nodeType: NodeType.Enumeration,
|
|
8
10
|
...stackTraceInfo,
|
|
9
|
-
1: content
|
|
11
|
+
1: content
|
|
10
12
|
};
|
|
11
13
|
return result2;
|
|
12
14
|
}
|
|
13
15
|
const result = {
|
|
14
16
|
nodeType: NodeType.Enumeration,
|
|
15
17
|
...stackTraceInfo,
|
|
16
|
-
...content
|
|
18
|
+
...content
|
|
17
19
|
};
|
|
18
20
|
return result;
|
|
19
21
|
};
|
|
20
|
-
export {
|
|
21
|
-
|
|
22
|
+
export {
|
|
23
|
+
enumeration as enu
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=enumeration.mjs.map
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import { QuantityContent } from
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { QuantityContent } from './enumeration.mjs';
|
|
2
|
+
import '../../../utils/getStackTraceInfo.mjs';
|
|
3
|
+
import '../../../types/nodeType.mjs';
|
|
4
4
|
|
|
5
|
-
declare const getEnumerationContent: <Content>(
|
|
6
|
-
enumerationContent: QuantityContent<Content>,
|
|
7
|
-
quantity: number
|
|
8
|
-
) => Content;
|
|
5
|
+
declare const getEnumerationContent: <Content>(enumerationContent: QuantityContent<Content>, quantity: number) => Content;
|
|
9
6
|
|
|
10
7
|
export { getEnumerationContent };
|
|
@@ -1,31 +1,18 @@
|
|
|
1
1
|
const getEnumerationContent = (enumerationContent, quantity) => {
|
|
2
2
|
const numericKeys = Object.keys(enumerationContent);
|
|
3
3
|
for (const key of numericKeys) {
|
|
4
|
-
const isEqual =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const isSuperior =
|
|
11
|
-
key.startsWith(">") && quantity > parseFloat(key.slice(1));
|
|
12
|
-
const isSuperiorOrEqual =
|
|
13
|
-
key.startsWith(">=") && quantity >= parseFloat(key.slice(2));
|
|
14
|
-
const isInferior =
|
|
15
|
-
key.startsWith("<") && quantity < parseFloat(key.slice(1));
|
|
16
|
-
const isInferiorOrEqual =
|
|
17
|
-
key.startsWith("<=") && quantity <= parseFloat(key.slice(2));
|
|
18
|
-
if (
|
|
19
|
-
isEqual ||
|
|
20
|
-
isSuperior ||
|
|
21
|
-
isSuperiorOrEqual ||
|
|
22
|
-
isInferior ||
|
|
23
|
-
isInferiorOrEqual
|
|
24
|
-
) {
|
|
4
|
+
const isEqual = !key.startsWith(">") && !key.startsWith("<") && !key.startsWith("=") && parseFloat(key) === quantity || key.startsWith("=") && parseFloat(key.slice(1)) === quantity;
|
|
5
|
+
const isSuperior = key.startsWith(">") && quantity > parseFloat(key.slice(1));
|
|
6
|
+
const isSuperiorOrEqual = key.startsWith(">=") && quantity >= parseFloat(key.slice(2));
|
|
7
|
+
const isInferior = key.startsWith("<") && quantity < parseFloat(key.slice(1));
|
|
8
|
+
const isInferiorOrEqual = key.startsWith("<=") && quantity <= parseFloat(key.slice(2));
|
|
9
|
+
if (isEqual || isSuperior || isSuperiorOrEqual || isInferior || isInferiorOrEqual) {
|
|
25
10
|
return enumerationContent[key];
|
|
26
11
|
}
|
|
27
12
|
}
|
|
28
13
|
return enumerationContent["1"];
|
|
29
14
|
};
|
|
30
|
-
export {
|
|
31
|
-
|
|
15
|
+
export {
|
|
16
|
+
getEnumerationContent
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=getEnumerationContent.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { EnumerationContent, QuantityContent, enu } from
|
|
2
|
-
export { getEnumerationContent } from
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
export { EnumerationContent, QuantityContent, enu } from './enumeration.mjs';
|
|
2
|
+
export { getEnumerationContent } from './getEnumerationContent.mjs';
|
|
3
|
+
import '../../../utils/getStackTraceInfo.mjs';
|
|
4
|
+
import '../../../types/nodeType.mjs';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
//# sourceMappingURL=index.mjs.map
|
|
1
|
+
export * from './enumeration.mjs';
|
|
2
|
+
export * from './getEnumerationContent.mjs';
|
|
3
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
enu,
|
|
11
|
-
} from "./enumeration/enumeration.mjs";
|
|
12
|
-
export { getEnumerationContent } from "./enumeration/getEnumerationContent.mjs";
|
|
13
|
-
import "@intlayer/config/client";
|
|
14
|
-
import "../../utils/getStackTraceInfo.mjs";
|
|
15
|
-
import "../../types/nodeType.mjs";
|
|
1
|
+
export { t } from './translation/translation.mjs';
|
|
2
|
+
export { getTranslationContent } from './translation/getTranslationContent.mjs';
|
|
3
|
+
export { ConfigLanguageContent, ConfigLocales, CustomLocales, CustomizableLanguageContent, LanguageContent, TranslationContent } from './translation/types.mjs';
|
|
4
|
+
export { EnumerationContent, QuantityContent, enu } from './enumeration/enumeration.mjs';
|
|
5
|
+
export { getEnumerationContent } from './enumeration/getEnumerationContent.mjs';
|
|
6
|
+
import '@intlayer/config/client';
|
|
7
|
+
import 'intlayer';
|
|
8
|
+
import '../../utils/getStackTraceInfo.mjs';
|
|
9
|
+
import '../../types/nodeType.mjs';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
//# sourceMappingURL=index.mjs.map
|
|
1
|
+
export * from './translation/index.mjs';
|
|
2
|
+
export * from './enumeration/index.mjs';
|
|
3
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import { Locales } from '@intlayer/config/client';
|
|
2
|
+
import { CustomizableLanguageContent } from './types.mjs';
|
|
3
|
+
import 'intlayer';
|
|
4
|
+
import '../../../utils/getStackTraceInfo.mjs';
|
|
5
|
+
import '../../../types/nodeType.mjs';
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
locale: Locales
|
|
9
|
-
) => Content;
|
|
7
|
+
type GetTranslationContent = <Content = string>(languageContent: CustomizableLanguageContent<Content>, locale: Locales) => Content;
|
|
8
|
+
declare const getTranslationContent: GetTranslationContent;
|
|
10
9
|
|
|
11
10
|
export { getTranslationContent };
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
intlayerIntlConfiguration
|
|
3
|
+
} from "@intlayer/config/client";
|
|
2
4
|
const defaultLocale = intlayerIntlConfiguration.defaultLocale;
|
|
3
|
-
const getTranslationContent = (languageContent, locale) =>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const getTranslationContent = (languageContent, locale) => languageContent[locale ?? defaultLocale] ?? languageContent[defaultLocale];
|
|
6
|
+
export {
|
|
7
|
+
getTranslationContent
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=getTranslationContent.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/transpiler/content_transformers/translation/getTranslationContent.ts"],"sourcesContent":["import {\n type Locales,\n intlayerIntlConfiguration,\n} from '@intlayer/config/client';\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../../../../src/transpiler/content_transformers/translation/getTranslationContent.ts"],"sourcesContent":["import {\n type Locales,\n intlayerIntlConfiguration,\n} from '@intlayer/config/client';\nimport type { CustomizableLanguageContent } from './types';\n\nconst defaultLocale = intlayerIntlConfiguration.defaultLocale;\n\ntype GetTranslationContent = <Content = string>(\n languageContent: CustomizableLanguageContent<Content>,\n locale: Locales\n) => Content;\n\nexport const getTranslationContent: GetTranslationContent = <Content = string>(\n languageContent: CustomizableLanguageContent<Content>,\n locale: Locales\n) => languageContent[locale ?? defaultLocale] ?? languageContent[defaultLocale];\n"],"mappings":"AAAA;AAAA,EAEE;AAAA,OACK;AAGP,MAAM,gBAAgB,0BAA0B;AAOzC,MAAM,wBAA+C,CAC1D,iBACA,WACG,gBAAgB,UAAU,aAAa,KAAK,gBAAgB,aAAa;","names":[]}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { getTranslationContent } from
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
1
|
+
export { t } from './translation.mjs';
|
|
2
|
+
export { getTranslationContent } from './getTranslationContent.mjs';
|
|
3
|
+
export { ConfigLanguageContent, ConfigLocales, CustomLocales, CustomizableLanguageContent, LanguageContent, TranslationContent } from './types.mjs';
|
|
4
|
+
import '@intlayer/config/client';
|
|
5
|
+
import 'intlayer';
|
|
6
|
+
import '../../../utils/getStackTraceInfo.mjs';
|
|
7
|
+
import '../../../types/nodeType.mjs';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
|
|
1
|
+
export * from './translation.mjs';
|
|
2
|
+
export * from './getTranslationContent.mjs';
|
|
3
|
+
export * from './types.mjs';
|
|
4
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/transpiler/content_transformers/translation/index.ts"],"sourcesContent":["export * from './
|
|
1
|
+
{"version":3,"sources":["../../../../../src/transpiler/content_transformers/translation/index.ts"],"sourcesContent":["export * from './translation';\nexport * from './getTranslationContent';\nexport * from './types';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { CustomizableLanguageContent, TranslationContent } from './types.mjs';
|
|
2
|
+
import '@intlayer/config/client';
|
|
3
|
+
import 'intlayer';
|
|
4
|
+
import '../../../utils/getStackTraceInfo.mjs';
|
|
5
|
+
import '../../../types/nodeType.mjs';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Transpile multilingual dictionary content
|
|
9
|
+
*
|
|
10
|
+
* Usage
|
|
11
|
+
*
|
|
12
|
+
* translation<string>({
|
|
13
|
+
* "en": "test",
|
|
14
|
+
* "fr": "test",
|
|
15
|
+
* // ... any other available locale
|
|
16
|
+
* })
|
|
17
|
+
*
|
|
18
|
+
* translation<number, Locales.ENGLISH>({
|
|
19
|
+
* "en": 1
|
|
20
|
+
* })
|
|
21
|
+
*
|
|
22
|
+
* translation<string, Locales.ENGLISH | Locales.FRENCH>({
|
|
23
|
+
* "fr": "test",
|
|
24
|
+
* "en": "test"
|
|
25
|
+
* })
|
|
26
|
+
*
|
|
27
|
+
*/
|
|
28
|
+
declare const translation: <Content = string>(content?: CustomizableLanguageContent<Content>) => TranslationContent<Content>;
|
|
29
|
+
|
|
30
|
+
export { translation as t };
|
package/dist/esm/transpiler/content_transformers/translation/{translations.mjs → translation.mjs}
RENAMED
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
import { intlayerConfiguration } from "@intlayer/config/client";
|
|
2
|
-
import { NodeType } from
|
|
3
|
-
import { getStackTraceInfo } from
|
|
4
|
-
const
|
|
2
|
+
import { NodeType } from '../../../types/index.mjs';
|
|
3
|
+
import { getStackTraceInfo } from '../../../utils/getStackTraceInfo.mjs';
|
|
4
|
+
const { defaultLocale } = intlayerConfiguration.internationalization;
|
|
5
|
+
const translation = (content) => {
|
|
5
6
|
const stackTraceInfo = getStackTraceInfo();
|
|
6
7
|
if (typeof content === "string") {
|
|
7
8
|
const result2 = {
|
|
8
9
|
nodeType: NodeType.Translation,
|
|
9
10
|
...stackTraceInfo,
|
|
10
|
-
[
|
|
11
|
+
[defaultLocale]: content
|
|
11
12
|
};
|
|
12
13
|
return result2;
|
|
13
14
|
}
|
|
14
15
|
const result = {
|
|
15
16
|
nodeType: NodeType.Translation,
|
|
16
17
|
...stackTraceInfo,
|
|
17
|
-
...content
|
|
18
|
+
...content
|
|
18
19
|
};
|
|
19
20
|
return result;
|
|
20
21
|
};
|
|
21
|
-
export {
|
|
22
|
-
|
|
22
|
+
export {
|
|
23
|
+
translation as t
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=translation.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/transpiler/content_transformers/translation/translation.ts"],"sourcesContent":["import { intlayerConfiguration } from '@intlayer/config/client';\nimport { NodeType } from '../../../types/index';\nimport { getStackTraceInfo } from '../../../utils/getStackTraceInfo';\nimport type { CustomizableLanguageContent, TranslationContent } from './types';\n\nconst { defaultLocale } = intlayerConfiguration.internationalization;\n\n/**\n * Transpile multilingual dictionary content\n *\n * Usage\n *\n * translation<string>({\n * \"en\": \"test\",\n * \"fr\": \"test\",\n * // ... any other available locale\n * })\n *\n * translation<number, Locales.ENGLISH>({\n * \"en\": 1\n * })\n *\n * translation<string, Locales.ENGLISH | Locales.FRENCH>({\n * \"fr\": \"test\",\n * \"en\": \"test\"\n * })\n *\n */\nconst translation = <Content = string>(\n content?: CustomizableLanguageContent<Content>\n) => {\n const stackTraceInfo = getStackTraceInfo();\n\n if (typeof content === 'string') {\n const result: TranslationContent<Content> = {\n nodeType: NodeType.Translation,\n ...stackTraceInfo,\n [defaultLocale]: content,\n } as TranslationContent<Content>;\n\n return result;\n }\n\n const result: TranslationContent<Content> = {\n nodeType: NodeType.Translation,\n ...stackTraceInfo,\n ...(content as unknown as object),\n } as TranslationContent<Content>;\n\n return result;\n};\n\nexport { translation as t };\n"],"mappings":"AAAA,SAAS,6BAA6B;AACtC,SAAS,gBAAgB;AACzB,SAAS,yBAAyB;AAGlC,MAAM,EAAE,cAAc,IAAI,sBAAsB;AAuBhD,MAAM,cAAc,CAClB,YACG;AACH,QAAM,iBAAiB,kBAAkB;AAEzC,MAAI,OAAO,YAAY,UAAU;AAC/B,UAAMA,UAAsC;AAAA,MAC1C,UAAU,SAAS;AAAA,MACnB,GAAG;AAAA,MACH,CAAC,aAAa,GAAG;AAAA,IACnB;AAEA,WAAOA;AAAA,EACT;AAEA,QAAM,SAAsC;AAAA,IAC1C,UAAU,SAAS;AAAA,IACnB,GAAG;AAAA,IACH,GAAI;AAAA,EACN;AAEA,SAAO;AACT;","names":["result"]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { LocalesValues } from '@intlayer/config/client';
|
|
2
|
+
import { IConfigLocales } from 'intlayer';
|
|
3
|
+
import { NoteStackTraceInfo } from '../../../utils/getStackTraceInfo.mjs';
|
|
4
|
+
import { NodeType } from '../../../types/nodeType.mjs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* If module augmented, it will return the configured locales such as Locales.ENGLISH | Locales.FRENCH | Locales.SPANISH | ...
|
|
8
|
+
* If not, it will return never
|
|
9
|
+
*/
|
|
10
|
+
type ConfigLocales = keyof IConfigLocales<unknown>;
|
|
11
|
+
/**
|
|
12
|
+
* If module augmented, it will return the configured locales such as Locales.ENGLISH | Locales.FRENCH | Locales.SPANISH | ...
|
|
13
|
+
* If not, it will return all available locales such as Locales.ENGLISH | Locales.FRENCH | Locales.SPANISH | ...
|
|
14
|
+
*/
|
|
15
|
+
type CustomLocales = ConfigLocales extends never ? LocalesValues : ConfigLocales;
|
|
16
|
+
/**
|
|
17
|
+
* Record of locales and content
|
|
18
|
+
*
|
|
19
|
+
* const myVar1: LanguageContent<string> = {
|
|
20
|
+
* "en": "",
|
|
21
|
+
* "fr": ""
|
|
22
|
+
* }
|
|
23
|
+
*
|
|
24
|
+
* const myVar2: LanguageContent<{age: number, name: string}> = {
|
|
25
|
+
* "en": {age: 1, name: "test"},
|
|
26
|
+
* "fr": {age: 1, name: "test"}
|
|
27
|
+
* }
|
|
28
|
+
*/
|
|
29
|
+
type LanguageContent<Content> = Partial<Record<LocalesValues, Content>>;
|
|
30
|
+
type ConfigLanguageContent<Content> = Record<ConfigLocales, Content>;
|
|
31
|
+
/**
|
|
32
|
+
* Valid
|
|
33
|
+
* const test: CustomizableLanguageContent<string, Locales.ENGLISH | Locales.FRENCH> = {
|
|
34
|
+
* "en": "test",
|
|
35
|
+
* "fr": "test"
|
|
36
|
+
* }
|
|
37
|
+
*
|
|
38
|
+
* const test: CustomizableLanguageContent<number> = {
|
|
39
|
+
* "fr": 1,
|
|
40
|
+
* "en": 1,
|
|
41
|
+
* ... any other available locale
|
|
42
|
+
* }
|
|
43
|
+
*
|
|
44
|
+
* Invalid
|
|
45
|
+
*
|
|
46
|
+
* const test: CustomizableLanguageContent<string> = {
|
|
47
|
+
* "en": "test",
|
|
48
|
+
* "fr": "test",
|
|
49
|
+
* "sss": "test" // Does not exist in Locales
|
|
50
|
+
* }
|
|
51
|
+
*
|
|
52
|
+
* const test: CustomizableLanguageContent<string, Locales.ENGLISH | Locales.FRENCH> = {
|
|
53
|
+
* "fr": "test"
|
|
54
|
+
* // Locales.ENGLISH is missing
|
|
55
|
+
* }
|
|
56
|
+
*
|
|
57
|
+
*/
|
|
58
|
+
type CustomizableLanguageContent<Content = string> = ConfigLocales extends never ? LanguageContent<Content> : ConfigLanguageContent<Content>;
|
|
59
|
+
type TranslationContent<Content> = LanguageContent<Content> & NoteStackTraceInfo & {
|
|
60
|
+
nodeType: NodeType.Translation;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export type { ConfigLanguageContent, ConfigLocales, CustomLocales, CustomizableLanguageContent, LanguageContent, TranslationContent };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} from "./content_transformers/enumeration/enumeration.mjs";
|
|
11
|
-
import "@intlayer/config/client";
|
|
12
|
-
import "../utils/getStackTraceInfo.mjs";
|
|
13
|
-
import "../types/nodeType.mjs";
|
|
1
|
+
export { t } from './content_transformers/translation/translation.mjs';
|
|
2
|
+
export { getTranslationContent } from './content_transformers/translation/getTranslationContent.mjs';
|
|
3
|
+
export { ConfigLanguageContent, ConfigLocales, CustomLocales, CustomizableLanguageContent, LanguageContent, TranslationContent } from './content_transformers/translation/types.mjs';
|
|
4
|
+
export { EnumerationContent, QuantityContent, enu } from './content_transformers/enumeration/enumeration.mjs';
|
|
5
|
+
export { getEnumerationContent } from './content_transformers/enumeration/getEnumerationContent.mjs';
|
|
6
|
+
import '@intlayer/config/client';
|
|
7
|
+
import 'intlayer';
|
|
8
|
+
import '../utils/getStackTraceInfo.mjs';
|
|
9
|
+
import '../types/nodeType.mjs';
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
//# sourceMappingURL=index.mjs.map
|
|
1
|
+
export * from './content_transformers/index.mjs';
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/transpiler/index.ts"],"sourcesContent":["export
|
|
1
|
+
{"version":3,"sources":["../../../src/transpiler/index.ts"],"sourcesContent":["export * from './content_transformers/index';\n"],"mappings":"AAAA,cAAc;","names":[]}
|
|
@@ -1,35 +1,21 @@
|
|
|
1
|
-
import { TranslationContent } from
|
|
2
|
-
import { EnumerationContent } from
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
1
|
+
import { TranslationContent } from '../transpiler/content_transformers/translation/types.mjs';
|
|
2
|
+
import { EnumerationContent } from '../transpiler/content_transformers/enumeration/enumeration.mjs';
|
|
3
|
+
import './nodeType.mjs';
|
|
4
|
+
import '@intlayer/config/client';
|
|
5
|
+
import 'intlayer';
|
|
6
|
+
import '../utils/getStackTraceInfo.mjs';
|
|
6
7
|
|
|
7
8
|
type TypedNode = TranslationContent<unknown> | EnumerationContent<unknown>;
|
|
8
|
-
type ContentValue =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
[key: string]: ContentValue;
|
|
12
|
-
}
|
|
13
|
-
| (() => ContentValue)
|
|
14
|
-
| Promise<ContentValue>
|
|
15
|
-
| TypedNode;
|
|
9
|
+
type ContentValue = string | {
|
|
10
|
+
[key: string]: ContentValue;
|
|
11
|
+
} | (() => ContentValue) | Promise<ContentValue> | TypedNode;
|
|
16
12
|
type Content = Record<string, ContentValue | undefined>;
|
|
17
|
-
type FlatContentValue =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
[key: string]: FlatContentValue;
|
|
21
|
-
}
|
|
22
|
-
| TypedNode;
|
|
13
|
+
type FlatContentValue = string | {
|
|
14
|
+
[key: string]: FlatContentValue;
|
|
15
|
+
} | TypedNode;
|
|
23
16
|
type FlatContent = Record<string, FlatContentValue | undefined>;
|
|
24
17
|
type ContentModule = Content & {
|
|
25
|
-
|
|
18
|
+
id: string;
|
|
26
19
|
};
|
|
27
20
|
|
|
28
|
-
export type {
|
|
29
|
-
Content,
|
|
30
|
-
ContentModule,
|
|
31
|
-
ContentValue,
|
|
32
|
-
FlatContent,
|
|
33
|
-
FlatContentValue,
|
|
34
|
-
TypedNode,
|
|
35
|
-
};
|
|
21
|
+
export type { Content, ContentModule, ContentValue, FlatContent, FlatContentValue, TypedNode };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
//# sourceMappingURL=contentModule.mjs.map
|
|
1
|
+
//# sourceMappingURL=contentModule.mjs.map
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from "./contentModule.mjs";
|
|
9
|
-
export { NodeType } from "./nodeType.mjs";
|
|
10
|
-
import "../transpiler/content_transformers/translation/translations.mjs";
|
|
11
|
-
import "@intlayer/config/client";
|
|
12
|
-
import "../utils/getStackTraceInfo.mjs";
|
|
13
|
-
import "../transpiler/content_transformers/enumeration/enumeration.mjs";
|
|
1
|
+
export { Content, ContentModule, ContentValue, FlatContent, FlatContentValue, TypedNode } from './contentModule.mjs';
|
|
2
|
+
export { NodeType } from './nodeType.mjs';
|
|
3
|
+
import '../transpiler/content_transformers/translation/types.mjs';
|
|
4
|
+
import '@intlayer/config/client';
|
|
5
|
+
import 'intlayer';
|
|
6
|
+
import '../utils/getStackTraceInfo.mjs';
|
|
7
|
+
import '../transpiler/content_transformers/enumeration/enumeration.mjs';
|
package/dist/esm/types/index.mjs
CHANGED
|
@@ -10,10 +10,12 @@ const getStackTraceInfo = () => {
|
|
|
10
10
|
return {
|
|
11
11
|
// file,
|
|
12
12
|
line,
|
|
13
|
-
column
|
|
13
|
+
column
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
return {};
|
|
17
17
|
};
|
|
18
|
-
export {
|
|
19
|
-
|
|
18
|
+
export {
|
|
19
|
+
getStackTraceInfo
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=getStackTraceInfo.mjs.map
|