@intlayer/api 4.0.0 → 4.0.3
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 +22 -204
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -17,224 +17,42 @@
|
|
|
17
17
|
</a>
|
|
18
18
|
</div>
|
|
19
19
|
|
|
20
|
-
#
|
|
20
|
+
# @intlayer/api: interact with Intlayer API
|
|
21
21
|
|
|
22
|
-
**Intlayer** is
|
|
22
|
+
**Intlayer** is a suite of packages designed specifically for JavaScript developers. It is compatible with frameworks like React, React, and Express.js.
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
The **`@intlayer/api`** package is a SDK (Software Development Kit) to interact with the Intlayer API. It provides a set of functions to audit content declaration, interact with organizations, projects, and user, etc.
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
.
|
|
28
|
-
├── ClientComponent
|
|
29
|
-
│ ├── index.content.ts
|
|
30
|
-
│ └── index.tsx
|
|
31
|
-
└── ServerComponent
|
|
32
|
-
├── index.content.ts
|
|
33
|
-
└── index.tsx
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
```tsx
|
|
37
|
-
// ./ClientComponent/index.content.ts
|
|
38
|
-
|
|
39
|
-
import { type DeclarationContent, t } from "intlayer";
|
|
26
|
+
## Usage
|
|
40
27
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
content: {
|
|
44
|
-
myTranslatedContent: t({
|
|
45
|
-
en: "Hello World",
|
|
46
|
-
fr: "Bonjour le monde",
|
|
47
|
-
es: "Hola Mundo",
|
|
48
|
-
}),
|
|
49
|
-
},
|
|
50
|
-
} satisfies DeclarationContent;
|
|
28
|
+
```ts
|
|
29
|
+
import { intlayerAPI } from "@intlayer/api";
|
|
51
30
|
|
|
52
|
-
|
|
31
|
+
intlayerAPI.user.getUser({
|
|
32
|
+
ids: ["user-id-1", "user-id-2"],
|
|
33
|
+
});
|
|
53
34
|
```
|
|
54
35
|
|
|
55
|
-
|
|
56
|
-
// ./ClientComponent/index.tsx
|
|
57
|
-
"use client";
|
|
58
|
-
|
|
59
|
-
import { useIntlayer } from "next-intlayer";
|
|
60
|
-
|
|
61
|
-
export const ClientComponent = () => {
|
|
62
|
-
const { myTranslatedContent } = useIntlayer("client-component");
|
|
63
|
-
|
|
64
|
-
return <span>{myTranslatedContent}</span>;
|
|
65
|
-
};
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## Why Choose Intlayer?
|
|
69
|
-
|
|
70
|
-
- **JavaScript-Powered Content Management**: Harness the flexibility of JavaScript to define and manage your content efficiently.
|
|
71
|
-
- **Type-Safe Environment**: Leverage TypeScript to ensure all your content definitions are precise and error-free.
|
|
72
|
-
- **Integrated Content Files**: Keep your translations close to their respective components, enhancing maintainability and clarity.
|
|
36
|
+
## Installation
|
|
73
37
|
|
|
74
|
-
|
|
38
|
+
Install the necessary package using your preferred package manager:
|
|
75
39
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
To build dictionaries from this declaration, you can use [intlayer-cli](https://github.com/aymericzip/intlayer/blob/main/packages/intlayer-cli/readme.md).
|
|
79
|
-
And to interpret intlayer dictionaries you can interpreters, such as [react-intlayer](https://github.com/aymericzip/intlayer/blob/main/packages/react-intlayer/README.md) [next-intlayer](https://github.com/aymericzip/intlayer/blob/main/packages/next-intlayer/README.md)
|
|
80
|
-
|
|
81
|
-
## Getting Started with Intlayer
|
|
82
|
-
|
|
83
|
-
[See how to use intlayer with NextJS](https://github.com/aymericzip/intlayer/blob/main/README.md)
|
|
84
|
-
|
|
85
|
-
### Install Package
|
|
86
|
-
|
|
87
|
-
Install the necessary packages using npm:
|
|
88
|
-
|
|
89
|
-
```bash
|
|
90
|
-
npm install intlayer
|
|
40
|
+
```bash packageManager="npm"
|
|
41
|
+
npm install @intlayer/api
|
|
91
42
|
```
|
|
92
43
|
|
|
93
|
-
```bash
|
|
94
|
-
|
|
44
|
+
```bash packageManager="pnpm"
|
|
45
|
+
pnpm add @intlayer/api
|
|
95
46
|
```
|
|
96
47
|
|
|
97
|
-
```bash
|
|
98
|
-
|
|
48
|
+
```bash packageManager="yarn"
|
|
49
|
+
yarn add @intlayer/api
|
|
99
50
|
```
|
|
100
51
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
Create and manage your content dictionaries:
|
|
104
|
-
|
|
105
|
-
#### Using typescript
|
|
106
|
-
|
|
107
|
-
```typescript
|
|
108
|
-
// src/app/[locale]/page.content.ts
|
|
109
|
-
import { t, enu, type DeclarationContent } from "intlayer";
|
|
52
|
+
## Read about Intlayer
|
|
110
53
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
getStarted: {
|
|
115
|
-
main: t({
|
|
116
|
-
en: "Get started by editing",
|
|
117
|
-
fr: "Commencez par éditer",
|
|
118
|
-
es: "Comience por editar",
|
|
119
|
-
}),
|
|
120
|
-
pageLink: "src/app/page.tsx",
|
|
121
|
-
},
|
|
122
|
-
nestedContent: {
|
|
123
|
-
id: "enumeration",
|
|
124
|
-
numberOfCar: enu({
|
|
125
|
-
"<-1": "Less than minus one car",
|
|
126
|
-
"-1": "Minus one car",
|
|
127
|
-
"0": "No cars",
|
|
128
|
-
"1": "One car",
|
|
129
|
-
">5": "Some cars",
|
|
130
|
-
">19": "Many cars",
|
|
131
|
-
}),
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
} satisfies DeclarationContent;
|
|
135
|
-
|
|
136
|
-
// Content should be exported as default
|
|
137
|
-
export default pageContent;
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
#### Using ECMAScript modules
|
|
141
|
-
|
|
142
|
-
```javascript
|
|
143
|
-
// src/app/[locale]/page.content.mjs
|
|
144
|
-
|
|
145
|
-
import { t } from "intlayer";
|
|
146
|
-
|
|
147
|
-
/** @type {import('intlayer').DeclarationContent} */
|
|
148
|
-
const pageContent = {
|
|
149
|
-
"key": "page",
|
|
150
|
-
getStarted: {
|
|
151
|
-
main: t({
|
|
152
|
-
en: "Get started by editing",
|
|
153
|
-
fr: "Commencez par éditer",
|
|
154
|
-
es: "Comience por editar",
|
|
155
|
-
}),
|
|
156
|
-
pageLink: "src/app/page.tsx",
|
|
157
|
-
},
|
|
158
|
-
nestedContent: {
|
|
159
|
-
id: "enumeration",
|
|
160
|
-
numberOfCar: enu({
|
|
161
|
-
"<-1": "Less than minus one car",
|
|
162
|
-
"-1": "Minus one car",
|
|
163
|
-
0: "No cars",
|
|
164
|
-
1: "One car",
|
|
165
|
-
">5": "Some cars",
|
|
166
|
-
">19": "Many cars",
|
|
167
|
-
}),
|
|
168
|
-
},
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
// Content should be exported as default
|
|
172
|
-
export default pageContent;
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
#### Using CommonJS modules
|
|
176
|
-
|
|
177
|
-
```javascript
|
|
178
|
-
// src/app/[locale]/page.content.cjs
|
|
179
|
-
|
|
180
|
-
const { t } = require("intlayer");
|
|
181
|
-
|
|
182
|
-
/** @type {import('intlayer').DeclarationContent} */
|
|
183
|
-
const pageContent = {
|
|
184
|
-
"key": "page",
|
|
185
|
-
getStarted: {
|
|
186
|
-
main: t({
|
|
187
|
-
en: "Get started by editing",
|
|
188
|
-
fr: "Commencez par éditer",
|
|
189
|
-
es: "Comience por editar",
|
|
190
|
-
}),
|
|
191
|
-
pageLink: "src/app/page.tsx",
|
|
192
|
-
},
|
|
193
|
-
nestedContent: {
|
|
194
|
-
id: "enumeration",
|
|
195
|
-
numberOfCar: enu({
|
|
196
|
-
"<-1": "Less than minus one car",
|
|
197
|
-
"-1": "Minus one car",
|
|
198
|
-
0: "No cars",
|
|
199
|
-
1: "One car",
|
|
200
|
-
">5": "Some cars",
|
|
201
|
-
">19": "Many cars",
|
|
202
|
-
}),
|
|
203
|
-
},
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
// Content should be exported as default
|
|
207
|
-
module.exports = pageContent;
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
#### Using JSON
|
|
211
|
-
|
|
212
|
-
```json5
|
|
213
|
-
// src/app/[locale]/page.content.json
|
|
214
|
-
{
|
|
215
|
-
"key": "page",
|
|
216
|
-
getStarted: {
|
|
217
|
-
main: {
|
|
218
|
-
nodeType: "translation",
|
|
219
|
-
en: "Get started by editing",
|
|
220
|
-
fr: "Commencez par éditer",
|
|
221
|
-
es: "Comience por editar",
|
|
222
|
-
},
|
|
223
|
-
pageLink: "src/app/page.tsx",
|
|
224
|
-
},
|
|
225
|
-
nestedContent: {
|
|
226
|
-
id: "enumeration",
|
|
227
|
-
nodeType: "enumeration",
|
|
228
|
-
numberOfCar: {
|
|
229
|
-
"<-1": "Less than minus one car",
|
|
230
|
-
"-1": "Minus one car",
|
|
231
|
-
"0": "No cars",
|
|
232
|
-
"1": "One car",
|
|
233
|
-
">5": "Some cars",
|
|
234
|
-
">19": "Many cars",
|
|
235
|
-
},
|
|
236
|
-
},
|
|
237
|
-
}
|
|
238
|
-
```
|
|
54
|
+
- [Intlayer Website](https://intlayer.org)
|
|
55
|
+
- [Intlayer Documentation](https://intlayer.org/docs)
|
|
56
|
+
- [Intlayer GitHub](https://github.com/aymericzip/intlayer)
|
|
239
57
|
|
|
240
|
-
|
|
58
|
+
- [Ask your questions to our smart documentation](https://intlayer.org/docs/chat)
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/api",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"private": false,
|
|
5
|
-
"description": "API",
|
|
5
|
+
"description": "SDK for interacting with the Intlayer API, enabling content auditing, and managing organizations, projects, and users.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"intlayer",
|
|
8
8
|
"application",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"./package.json"
|
|
58
58
|
],
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@intlayer/config": "4.0.
|
|
60
|
+
"@intlayer/config": "4.0.3"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@changesets/changelog-github": "0.5.0",
|
|
@@ -71,14 +71,14 @@
|
|
|
71
71
|
"tsc-alias": "^1.8.10",
|
|
72
72
|
"tsup": "^8.3.5",
|
|
73
73
|
"typescript": "^5.7.3",
|
|
74
|
-
"@
|
|
75
|
-
"@utils/tsup-config": "1.0.4",
|
|
74
|
+
"@intlayer/backend": "4.0.3",
|
|
76
75
|
"@utils/eslint-config": "1.0.4",
|
|
77
|
-
"@
|
|
76
|
+
"@utils/tsup-config": "1.0.4",
|
|
77
|
+
"@utils/ts-config-types": "1.0.4",
|
|
78
78
|
"@utils/ts-config": "1.0.4"
|
|
79
79
|
},
|
|
80
80
|
"peerDependencies": {
|
|
81
|
-
"@intlayer/config": "4.0.
|
|
81
|
+
"@intlayer/config": "4.0.3"
|
|
82
82
|
},
|
|
83
83
|
"engines": {
|
|
84
84
|
"node": ">=14.18"
|