intlayer 1.0.0 → 1.2.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/README.md +176 -0
- package/dist/cjs/index.cjs +20 -22
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.ts +14 -18
- package/dist/esm/index.d.mts +14 -18
- package/dist/esm/index.mjs +10 -8
- package/dist/esm/index.mjs.map +1 -1
- package/package.json +13 -7
- package/src/index.ts +34 -11
package/README.md
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
# Intlayer: Next-Level Content Management in JavaScript
|
|
2
|
+
|
|
3
|
+
**Intlayer** is an innovative Content Management System (CMS) designed specifically for JavaScript developers. It enables seamless transpilation of JavaScript content into structured dictionaries, making integration into your codebase straightforward and efficient.
|
|
4
|
+
|
|
5
|
+
## Why Choose Intlayer?
|
|
6
|
+
|
|
7
|
+
- **JavaScript-Powered Content Management**: Harness the flexibility of JavaScript to define and manage your content efficiently.
|
|
8
|
+
- **Type-Safe Environment**: Leverage TypeScript to ensure all your content definitions are precise and error-free.
|
|
9
|
+
- **Integrated Content Files**: Keep your translations close to their respective components, enhancing maintainability and clarity.
|
|
10
|
+
|
|
11
|
+
## intlayer package
|
|
12
|
+
|
|
13
|
+
`intlayer` package intend to declare your content in a structured way, using JavaScript.
|
|
14
|
+
|
|
15
|
+
To build dictionaries from this declaration, you can use [intlayer-cli](https://github.com/aypineau/intlayer/blob/main/packages/intlayer-cli/readme.md).
|
|
16
|
+
And to interpret intlayer dictionaries you can interpreters, such as [react-intlayer](https://github.com/aypineau/intlayer/blob/main/packages/react-intlayer/readme.md), or [next-intlayer](https://github.com/aypineau/intlayer/blob/main/packages/next-intlayer/readme.md)
|
|
17
|
+
|
|
18
|
+
## Getting Started with Intlayer
|
|
19
|
+
|
|
20
|
+
[See how to use intlayer with NextJS](https://github.com/aypineau/intlayer/blob/main/readme.md)
|
|
21
|
+
|
|
22
|
+
### Install Package
|
|
23
|
+
|
|
24
|
+
Install the necessary packages using npm:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install intlayer
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
yarn install intlayer
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pnpm install intlayer
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Manage Your Content
|
|
39
|
+
|
|
40
|
+
Create and manage your content dictionaries:
|
|
41
|
+
|
|
42
|
+
#### Using typescript
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
// src/app/[locale]/page.content.ts
|
|
46
|
+
import { t, enu, type ContentModule } from "intlayer";
|
|
47
|
+
|
|
48
|
+
const pageContent: ContentModule = {
|
|
49
|
+
id: "page",
|
|
50
|
+
getStarted: {
|
|
51
|
+
main: t({
|
|
52
|
+
en: "Get started by editing",
|
|
53
|
+
fr: "Commencez par éditer",
|
|
54
|
+
es: "Comience por editar",
|
|
55
|
+
}),
|
|
56
|
+
pageLink: "src/app/page.tsx",
|
|
57
|
+
},
|
|
58
|
+
nestedContent: {
|
|
59
|
+
id: "enumeration",
|
|
60
|
+
numberOfCar: enu({
|
|
61
|
+
"<-1": "Less than minus one car",
|
|
62
|
+
"-1": "Minus one car",
|
|
63
|
+
"0": "No cars",
|
|
64
|
+
"1": "One car",
|
|
65
|
+
">5": "Some cars",
|
|
66
|
+
">19": "Many cars",
|
|
67
|
+
}),
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// Content should be exported as default
|
|
72
|
+
export default pageContent;
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
#### Using ECMAScript modules
|
|
76
|
+
|
|
77
|
+
```javascript
|
|
78
|
+
// src/app/[locale]/page.content.mjs
|
|
79
|
+
|
|
80
|
+
import { t } from "intlayer";
|
|
81
|
+
|
|
82
|
+
/** @type {import('intlayer').ContentModule} */
|
|
83
|
+
const pageContent = {
|
|
84
|
+
id: "page",
|
|
85
|
+
getStarted: {
|
|
86
|
+
main: t({
|
|
87
|
+
en: "Get started by editing",
|
|
88
|
+
fr: "Commencez par éditer",
|
|
89
|
+
es: "Comience por editar",
|
|
90
|
+
}),
|
|
91
|
+
pageLink: "src/app/page.tsx",
|
|
92
|
+
},
|
|
93
|
+
nestedContent: {
|
|
94
|
+
id: "enumeration",
|
|
95
|
+
numberOfCar: enu({
|
|
96
|
+
"<-1": "Less than minus one car",
|
|
97
|
+
"-1": "Minus one car",
|
|
98
|
+
"0": "No cars",
|
|
99
|
+
"1": "One car",
|
|
100
|
+
">5": "Some cars",
|
|
101
|
+
">19": "Many cars",
|
|
102
|
+
}),
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
// Content should be exported as default
|
|
107
|
+
export default pageContent;
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
#### Using CommonJS modules
|
|
111
|
+
|
|
112
|
+
```javascript
|
|
113
|
+
// src/app/[locale]/page.content.cjs
|
|
114
|
+
|
|
115
|
+
const { t } = require("intlayer");
|
|
116
|
+
|
|
117
|
+
/** @type {import('intlayer').ContentModule} */
|
|
118
|
+
const pageContent = {
|
|
119
|
+
id: "page",
|
|
120
|
+
getStarted: {
|
|
121
|
+
main: t({
|
|
122
|
+
en: "Get started by editing",
|
|
123
|
+
fr: "Commencez par éditer",
|
|
124
|
+
es: "Comience por editar",
|
|
125
|
+
}),
|
|
126
|
+
pageLink: "src/app/page.tsx",
|
|
127
|
+
},
|
|
128
|
+
nestedContent: {
|
|
129
|
+
id: "enumeration",
|
|
130
|
+
numberOfCar: enu({
|
|
131
|
+
"<-1": "Less than minus one car",
|
|
132
|
+
"-1": "Minus one car",
|
|
133
|
+
"0": "No cars",
|
|
134
|
+
"1": "One car",
|
|
135
|
+
">5": "Some cars",
|
|
136
|
+
">19": "Many cars",
|
|
137
|
+
}),
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
// Content should be exported as default
|
|
142
|
+
module.exports = pageContent;
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
#### Using CommonJS modules
|
|
146
|
+
|
|
147
|
+
```json
|
|
148
|
+
// src/app/[locale]/page.content.json
|
|
149
|
+
|
|
150
|
+
{
|
|
151
|
+
"id": "page",
|
|
152
|
+
"getStarted": {
|
|
153
|
+
"main": {
|
|
154
|
+
"nodeType": "translation",
|
|
155
|
+
"en": "Get started by editing",
|
|
156
|
+
"fr": "Commencez par éditer",
|
|
157
|
+
"es": "Comience por editar",
|
|
158
|
+
},
|
|
159
|
+
"pageLink": "src/app/page.tsx",
|
|
160
|
+
},
|
|
161
|
+
"nestedContent": {
|
|
162
|
+
"id": "enumeration",
|
|
163
|
+
"nodeType": "enumeration",
|
|
164
|
+
"numberOfCar": {
|
|
165
|
+
"<-1": "Less than minus one car",
|
|
166
|
+
"-1": "Minus one car",
|
|
167
|
+
"0": "No cars",
|
|
168
|
+
"1": "One car",
|
|
169
|
+
">5": "Some cars",
|
|
170
|
+
">19": "Many cars",
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
This version emphasizes ease of use, practical steps, and the professional application of Intlayer in a Next.js environment.
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -8,38 +8,36 @@ var __export = (target, all) => {
|
|
|
8
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
9
|
};
|
|
10
10
|
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
12
|
for (let key of __getOwnPropNames(from))
|
|
13
13
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, {
|
|
15
|
-
get: () => from[key],
|
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
17
|
-
});
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
15
|
}
|
|
19
16
|
return to;
|
|
20
17
|
};
|
|
21
|
-
var __toCommonJS = (mod) =>
|
|
22
|
-
__copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
19
|
var src_exports = {};
|
|
24
20
|
__export(src_exports, {
|
|
25
21
|
Locales: () => import_client.Locales,
|
|
26
|
-
enu: () =>
|
|
27
|
-
getEnumerationContent: () =>
|
|
28
|
-
getLocaleName: () =>
|
|
29
|
-
getTranslationContent: () =>
|
|
30
|
-
t: () =>
|
|
22
|
+
enu: () => import_core2.enu,
|
|
23
|
+
getEnumerationContent: () => import_core2.getEnumerationContent,
|
|
24
|
+
getLocaleName: () => import_core2.getLocaleName,
|
|
25
|
+
getTranslationContent: () => getTranslationContent,
|
|
26
|
+
t: () => t
|
|
31
27
|
});
|
|
32
28
|
module.exports = __toCommonJS(src_exports);
|
|
33
29
|
var import_core = require("@intlayer/core");
|
|
30
|
+
var import_core2 = require("@intlayer/core");
|
|
34
31
|
var import_client = require("@intlayer/config/client");
|
|
32
|
+
const t = import_core.t;
|
|
33
|
+
const getTranslationContent = import_core.getTranslationContent;
|
|
35
34
|
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
-
0 &&
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
//# sourceMappingURL=index.cjs.map
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
Locales,
|
|
37
|
+
enu,
|
|
38
|
+
getEnumerationContent,
|
|
39
|
+
getLocaleName,
|
|
40
|
+
getTranslationContent,
|
|
41
|
+
t
|
|
42
|
+
});
|
|
43
|
+
//# sourceMappingURL=index.cjs.map
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport {\n type TranslationContent,\n t as tCore,\n getTranslationContent as getTranslationContentCore,\n type LanguageContent,\n} from '@intlayer/core';\n\n/* eslint-disable @typescript-eslint/no-unused-vars */\n/* eslint-disable @typescript-eslint/no-empty-interface */\nexport interface IConfigLocales<Content> {\n // This interface should be augmented in the consuming app\n}\n\ntype ConfigLocales = keyof IConfigLocales<unknown>;\n\ntype ConfigLanguageContent<Content> = Record<ConfigLocales, Content>;\n\nexport type CustomizableLanguageContent<Content = string> =\n ConfigLocales extends never\n ? LanguageContent<Content>\n : ConfigLanguageContent<Content>;\n\n// Re-exporting the following functions from the core package: to use module augmentation\nexport const t: <Content = string>(\n content?: CustomizableLanguageContent<Content>\n) => TranslationContent<Content> = tCore;\nexport const getTranslationContent: <Content = string>(\n languageContent: CustomizableLanguageContent<Content>,\n locale: Locales\n) => Content = getTranslationContentCore;\n\nexport type {\n LanguageContent,\n QuantityContent,\n ContentValue,\n ContentModule,\n} from '@intlayer/core';\nexport { getLocaleName, enu, getEnumerationContent } from '@intlayer/core';\nexport {\n type CustomIntlayerConfig as IntlayerConfig,\n Locales,\n} from '@intlayer/config/client';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAKO;AAgCP,IAAAA,eAA0D;AAC1D,oBAGO;AAlBA,MAAM,IAEsB,YAAAC;AAC5B,MAAM,wBAGE,YAAAC;","names":["import_core","tCore","getTranslationContentCore"]}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export {
|
|
16
|
-
CustomIntlayerConfig as IntlayerConfig,
|
|
17
|
-
Locales,
|
|
18
|
-
} from "@intlayer/config/client";
|
|
1
|
+
import { Locales } from '@intlayer/config/client';
|
|
2
|
+
export { CustomIntlayerConfig as IntlayerConfig, Locales } from '@intlayer/config/client';
|
|
3
|
+
import { LanguageContent, TranslationContent } from '@intlayer/core';
|
|
4
|
+
export { ContentModule, ContentValue, LanguageContent, QuantityContent, enu, getEnumerationContent, getLocaleName } from '@intlayer/core';
|
|
5
|
+
|
|
6
|
+
interface IConfigLocales<Content> {
|
|
7
|
+
}
|
|
8
|
+
type ConfigLocales = keyof IConfigLocales<unknown>;
|
|
9
|
+
type ConfigLanguageContent<Content> = Record<ConfigLocales, Content>;
|
|
10
|
+
type CustomizableLanguageContent<Content = string> = ConfigLocales extends never ? LanguageContent<Content> : ConfigLanguageContent<Content>;
|
|
11
|
+
declare const t: <Content = string>(content?: CustomizableLanguageContent<Content>) => TranslationContent<Content>;
|
|
12
|
+
declare const getTranslationContent: <Content = string>(languageContent: CustomizableLanguageContent<Content>, locale: Locales) => Content;
|
|
13
|
+
|
|
14
|
+
export { type CustomizableLanguageContent, type IConfigLocales, getTranslationContent, t };
|
package/dist/esm/index.d.mts
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export {
|
|
16
|
-
CustomIntlayerConfig as IntlayerConfig,
|
|
17
|
-
Locales,
|
|
18
|
-
} from "@intlayer/config/client";
|
|
1
|
+
import { Locales } from '@intlayer/config/client';
|
|
2
|
+
export { CustomIntlayerConfig as IntlayerConfig, Locales } from '@intlayer/config/client';
|
|
3
|
+
import { LanguageContent, TranslationContent } from '@intlayer/core';
|
|
4
|
+
export { ContentModule, ContentValue, LanguageContent, QuantityContent, enu, getEnumerationContent, getLocaleName } from '@intlayer/core';
|
|
5
|
+
|
|
6
|
+
interface IConfigLocales<Content> {
|
|
7
|
+
}
|
|
8
|
+
type ConfigLocales = keyof IConfigLocales<unknown>;
|
|
9
|
+
type ConfigLanguageContent<Content> = Record<ConfigLocales, Content>;
|
|
10
|
+
type CustomizableLanguageContent<Content = string> = ConfigLocales extends never ? LanguageContent<Content> : ConfigLanguageContent<Content>;
|
|
11
|
+
declare const t: <Content = string>(content?: CustomizableLanguageContent<Content>) => TranslationContent<Content>;
|
|
12
|
+
declare const getTranslationContent: <Content = string>(languageContent: CustomizableLanguageContent<Content>, locale: Locales) => Content;
|
|
13
|
+
|
|
14
|
+
export { type CustomizableLanguageContent, type IConfigLocales, getTranslationContent, t };
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
|
-
t,
|
|
3
|
-
|
|
4
|
-
enu,
|
|
5
|
-
getEnumerationContent,
|
|
6
|
-
getTranslationContent,
|
|
2
|
+
t as tCore,
|
|
3
|
+
getTranslationContent as getTranslationContentCore
|
|
7
4
|
} from "@intlayer/core";
|
|
8
|
-
|
|
5
|
+
const t = tCore;
|
|
6
|
+
const getTranslationContent = getTranslationContentCore;
|
|
7
|
+
import { getLocaleName, enu, getEnumerationContent } from "@intlayer/core";
|
|
8
|
+
import {
|
|
9
|
+
Locales
|
|
10
|
+
} from "@intlayer/config/client";
|
|
9
11
|
export {
|
|
10
12
|
Locales,
|
|
11
13
|
enu,
|
|
12
14
|
getEnumerationContent,
|
|
13
15
|
getLocaleName,
|
|
14
16
|
getTranslationContent,
|
|
15
|
-
t
|
|
17
|
+
t
|
|
16
18
|
};
|
|
17
|
-
//# 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":["
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport {\n type TranslationContent,\n t as tCore,\n getTranslationContent as getTranslationContentCore,\n type LanguageContent,\n} from '@intlayer/core';\n\n/* eslint-disable @typescript-eslint/no-unused-vars */\n/* eslint-disable @typescript-eslint/no-empty-interface */\nexport interface IConfigLocales<Content> {\n // This interface should be augmented in the consuming app\n}\n\ntype ConfigLocales = keyof IConfigLocales<unknown>;\n\ntype ConfigLanguageContent<Content> = Record<ConfigLocales, Content>;\n\nexport type CustomizableLanguageContent<Content = string> =\n ConfigLocales extends never\n ? LanguageContent<Content>\n : ConfigLanguageContent<Content>;\n\n// Re-exporting the following functions from the core package: to use module augmentation\nexport const t: <Content = string>(\n content?: CustomizableLanguageContent<Content>\n) => TranslationContent<Content> = tCore;\nexport const getTranslationContent: <Content = string>(\n languageContent: CustomizableLanguageContent<Content>,\n locale: Locales\n) => Content = getTranslationContentCore;\n\nexport type {\n LanguageContent,\n QuantityContent,\n ContentValue,\n ContentModule,\n} from '@intlayer/core';\nexport { getLocaleName, enu, getEnumerationContent } from '@intlayer/core';\nexport {\n type CustomIntlayerConfig as IntlayerConfig,\n Locales,\n} from '@intlayer/config/client';\n"],"mappings":"AACA;AAAA,EAEE,KAAK;AAAA,EACL,yBAAyB;AAAA,OAEpB;AAkBA,MAAM,IAEsB;AAC5B,MAAM,wBAGE;AAQf,SAAS,eAAe,KAAK,6BAA6B;AAC1D;AAAA,EAEE;AAAA,OACK;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "intlayer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "IntLayer is a layer of abstraction between the business logic and the data access layer. Manage internationalization in a simple way, through TypeScript, JavaScript or JSON declaration file.",
|
|
6
6
|
"keywords": [
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"homepage": "https://github.com/aypineau/intlayer",
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
18
|
-
"url": "https://github.com/aypineau/intlayer"
|
|
18
|
+
"url": "git+https://github.com/aypineau/intlayer.git"
|
|
19
19
|
},
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"author": {
|
|
@@ -28,6 +28,11 @@
|
|
|
28
28
|
"require": "./dist/cjs/index.cjs",
|
|
29
29
|
"import": "./dist/esm/index.mjs"
|
|
30
30
|
},
|
|
31
|
+
"./augmentation": {
|
|
32
|
+
"types": "./dist/esm/augmentation.d.mts",
|
|
33
|
+
"require": "./dist/cjs/augmentation.cjs",
|
|
34
|
+
"import": "./dist/esm/augmentation.mjs"
|
|
35
|
+
},
|
|
31
36
|
"./package.json": "./package.json"
|
|
32
37
|
},
|
|
33
38
|
"main": "src/index.ts",
|
|
@@ -46,8 +51,9 @@
|
|
|
46
51
|
],
|
|
47
52
|
"dependencies": {
|
|
48
53
|
"webpack": "^5.91.0",
|
|
49
|
-
"@intlayer/
|
|
50
|
-
"@intlayer/
|
|
54
|
+
"@intlayer/config": "^1.2.0",
|
|
55
|
+
"@intlayer/core": "^1.2.0",
|
|
56
|
+
"intlayer": "^1.2.0"
|
|
51
57
|
},
|
|
52
58
|
"devDependencies": {
|
|
53
59
|
"@changesets/changelog-github": "0.5.0",
|
|
@@ -55,9 +61,9 @@
|
|
|
55
61
|
"@types/node": "^20.12.7",
|
|
56
62
|
"rimraf": "5.0.5",
|
|
57
63
|
"tsup": "^8.0.2",
|
|
58
|
-
"typescript": "^5.
|
|
59
|
-
"@utils/eslint-config": "^1.0.
|
|
60
|
-
"@utils/ts-config": "^1.0.
|
|
64
|
+
"typescript": "^5.4.5",
|
|
65
|
+
"@utils/eslint-config": "^1.0.1",
|
|
66
|
+
"@utils/ts-config": "^1.0.1"
|
|
61
67
|
},
|
|
62
68
|
"engines": {
|
|
63
69
|
"node": ">=14.18"
|
package/src/index.ts
CHANGED
|
@@ -1,19 +1,42 @@
|
|
|
1
|
+
import type { Locales } from '@intlayer/config/client';
|
|
2
|
+
import {
|
|
3
|
+
type TranslationContent,
|
|
4
|
+
t as tCore,
|
|
5
|
+
getTranslationContent as getTranslationContentCore,
|
|
6
|
+
type LanguageContent,
|
|
7
|
+
} from '@intlayer/core';
|
|
8
|
+
|
|
9
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
10
|
+
/* eslint-disable @typescript-eslint/no-empty-interface */
|
|
11
|
+
export interface IConfigLocales<Content> {
|
|
12
|
+
// This interface should be augmented in the consuming app
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
type ConfigLocales = keyof IConfigLocales<unknown>;
|
|
16
|
+
|
|
17
|
+
type ConfigLanguageContent<Content> = Record<ConfigLocales, Content>;
|
|
18
|
+
|
|
19
|
+
export type CustomizableLanguageContent<Content = string> =
|
|
20
|
+
ConfigLocales extends never
|
|
21
|
+
? LanguageContent<Content>
|
|
22
|
+
: ConfigLanguageContent<Content>;
|
|
23
|
+
|
|
24
|
+
// Re-exporting the following functions from the core package: to use module augmentation
|
|
25
|
+
export const t: <Content = string>(
|
|
26
|
+
content?: CustomizableLanguageContent<Content>
|
|
27
|
+
) => TranslationContent<Content> = tCore;
|
|
28
|
+
export const getTranslationContent: <Content = string>(
|
|
29
|
+
languageContent: CustomizableLanguageContent<Content>,
|
|
30
|
+
locale: Locales
|
|
31
|
+
) => Content = getTranslationContentCore;
|
|
32
|
+
|
|
1
33
|
export type {
|
|
2
34
|
LanguageContent,
|
|
3
|
-
|
|
35
|
+
QuantityContent,
|
|
4
36
|
ContentValue,
|
|
5
|
-
Content,
|
|
6
|
-
FlatContentValue,
|
|
7
|
-
FlatContent,
|
|
8
37
|
ContentModule,
|
|
9
38
|
} from '@intlayer/core';
|
|
10
|
-
export {
|
|
11
|
-
t,
|
|
12
|
-
getLocaleName,
|
|
13
|
-
enu,
|
|
14
|
-
getEnumerationContent,
|
|
15
|
-
getTranslationContent,
|
|
16
|
-
} from '@intlayer/core';
|
|
39
|
+
export { getLocaleName, enu, getEnumerationContent } from '@intlayer/core';
|
|
17
40
|
export {
|
|
18
41
|
type CustomIntlayerConfig as IntlayerConfig,
|
|
19
42
|
Locales,
|