@intlayer/docs 8.7.9 → 8.7.11-canary.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/docs/ar/dictionary/insertion.md +0 -52
- package/docs/ar/intlayer_with_astro.md +55 -6
- package/docs/ar/per_locale_file.md +0 -46
- package/docs/de/dictionary/insertion.md +0 -92
- package/docs/de/intlayer_with_astro.md +55 -6
- package/docs/de/intlayer_with_nextjs_16.md +0 -23
- package/docs/de/per_locale_file.md +0 -44
- package/docs/en/dictionary/insertion.md +0 -55
- package/docs/en/intlayer_with_astro.md +2 -1
- package/docs/en/per_locale_file.md +0 -43
- package/docs/en-GB/dictionary/insertion.md +0 -56
- package/docs/en-GB/intlayer_with_astro.md +55 -6
- package/docs/en-GB/per_locale_file.md +0 -43
- package/docs/es/dictionary/insertion.md +0 -52
- package/docs/es/intlayer_with_astro.md +55 -7
- package/docs/es/intlayer_with_nextjs_14.md +0 -23
- package/docs/es/intlayer_with_nextjs_16.md +0 -23
- package/docs/es/packages/next-intlayer/index.md +0 -52
- package/docs/es/packages/react-intlayer/index.md +0 -52
- package/docs/es/per_locale_file.md +0 -43
- package/docs/fr/dictionary/insertion.md +0 -52
- package/docs/fr/intlayer_with_astro.md +55 -7
- package/docs/fr/packages/react-intlayer/index.md +0 -52
- package/docs/fr/per_locale_file.md +0 -46
- package/docs/hi/dictionary/insertion.md +0 -91
- package/docs/hi/intlayer_with_astro.md +55 -6
- package/docs/hi/packages/intlayer/index.md +0 -52
- package/docs/hi/per_locale_file.md +0 -43
- package/docs/id/dictionary/insertion.md +0 -91
- package/docs/id/intlayer_with_astro.md +55 -6
- package/docs/id/intlayer_with_nextjs_14.md +0 -24
- package/docs/id/per_locale_file.md +0 -44
- package/docs/it/dictionary/insertion.md +0 -52
- package/docs/it/intlayer_with_astro.md +55 -6
- package/docs/it/per_locale_file.md +0 -44
- package/docs/ja/dictionary/insertion.md +0 -56
- package/docs/ja/intlayer_with_astro.md +55 -7
- package/docs/ja/intlayer_with_nextjs_14.md +0 -23
- package/docs/ja/per_locale_file.md +0 -43
- package/docs/ko/dictionary/insertion.md +0 -56
- package/docs/ko/intlayer_with_astro.md +55 -7
- package/docs/ko/per_locale_file.md +0 -43
- package/docs/pl/dictionary/insertion.md +0 -85
- package/docs/pl/intlayer_with_astro.md +55 -6
- package/docs/pl/per_locale_file.md +0 -44
- package/docs/pt/dictionary/insertion.md +0 -93
- package/docs/pt/intlayer_with_astro.md +55 -6
- package/docs/pt/intlayer_with_nextjs_page_router.md +0 -23
- package/docs/pt/per_locale_file.md +0 -44
- package/docs/ru/dictionary/insertion.md +0 -52
- package/docs/ru/intlayer_with_astro.md +55 -7
- package/docs/ru/per_locale_file.md +0 -44
- package/docs/tr/dictionary/insertion.md +0 -52
- package/docs/tr/intlayer_with_astro.md +55 -6
- package/docs/tr/per_locale_file.md +0 -43
- package/docs/uk/dictionary/insertion.md +0 -52
- package/docs/uk/intlayer_with_astro.md +55 -6
- package/docs/uk/per_locale_file.md +0 -43
- package/docs/vi/dictionary/insertion.md +0 -85
- package/docs/vi/intlayer_with_astro.md +55 -6
- package/docs/vi/per_locale_file.md +0 -46
- package/docs/zh/dictionary/insertion.md +0 -54
- package/docs/zh/intlayer_with_astro.md +55 -7
- package/docs/zh/per_locale_file.md +0 -44
- package/package.json +6 -6
|
@@ -54,34 +54,6 @@ Aby skonfigurować treść wstawiania w swoim projekcie Intlayer, utwórz moduł
|
|
|
54
54
|
export default myInsertionContent;
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
```javascript fileName="**/*.content.mjs" contentDeclarationFormat="esm"
|
|
58
|
-
import { insert } from "intlayer";
|
|
59
|
-
|
|
60
|
-
/** @type {import('intlayer').Dictionary} */
|
|
61
|
-
const myInsertionContent = {
|
|
62
|
-
key: "my_key",
|
|
63
|
-
content: {
|
|
64
|
-
myInsertion: insert("Cześć, mam na imię {{name}} i mam {{age}} lat!"),
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export default myInsertionContent;
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
```javascript fileName="**/*.content.cjs" contentDeclarationFormat="commonjs"
|
|
72
|
-
const { insert } = require("intlayer");
|
|
73
|
-
|
|
74
|
-
/** @type {import('intlayer').Dictionary} */
|
|
75
|
-
const myInsertionContent = {
|
|
76
|
-
key: "my_key",
|
|
77
|
-
content: {
|
|
78
|
-
myInsertion: insert("Cześć, mam na imię {{name}} i mam {{age}} lat!"),
|
|
79
|
-
},
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
module.exports = myInsertionContent;
|
|
83
|
-
```
|
|
84
|
-
|
|
85
57
|
```json5 fileName="**/*.content.json" contentDeclarationFormat="json"
|
|
86
58
|
{
|
|
87
59
|
"$schema": "https://intlayer.org/schema.json",
|
|
@@ -112,30 +84,6 @@ Aby skonfigurować treść wstawiania w swoim projekcie Intlayer, utwórz moduł
|
|
|
112
84
|
export default myInsertionContent;
|
|
113
85
|
```
|
|
114
86
|
|
|
115
|
-
```javascript fileName="**/*.content.mjs" contentDeclarationFormat="esm"
|
|
116
|
-
/** @type {import('intlayer').Dictionary} */
|
|
117
|
-
const myInsertionContent = {
|
|
118
|
-
key: "my_key",
|
|
119
|
-
content: {
|
|
120
|
-
myInsertion: "Cześć, mam na imię {{name}} i mam {{age}} lat!",
|
|
121
|
-
},
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
export default myInsertionContent;
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
```javascript fileName="**/*.content.cjs" contentDeclarationFormat="commonjs"
|
|
128
|
-
/** @type {import('intlayer').Dictionary} */
|
|
129
|
-
const myInsertionContent = {
|
|
130
|
-
key: "my_key",
|
|
131
|
-
content: {
|
|
132
|
-
myInsertion: "Cześć, mam na imię {{name}} i mam {{age}} lat!",
|
|
133
|
-
},
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
module.exports = myInsertionContent;
|
|
137
|
-
```
|
|
138
|
-
|
|
139
87
|
```json5 fileName="**/*.content.json" contentDeclarationFormat="json"
|
|
140
88
|
{
|
|
141
89
|
"$schema": "https://intlayer.org/schema.json",
|
|
@@ -149,39 +97,6 @@ Aby skonfigurować treść wstawiania w swoim projekcie Intlayer, utwórz moduł
|
|
|
149
97
|
</Tab>
|
|
150
98
|
</Tabs>
|
|
151
99
|
|
|
152
|
-
```javascript fileName="**/*.content.mjs" contentDeclarationFormat="esm"
|
|
153
|
-
import { insert } from "intlayer";
|
|
154
|
-
|
|
155
|
-
/** @type {import('intlayer').Dictionary} */
|
|
156
|
-
const myInsertionContent = {
|
|
157
|
-
key: "my_key",
|
|
158
|
-
content: {
|
|
159
|
-
myInsertion: insert("Cześć, mam na imię {{name}} i mam {{age}} lat!"),
|
|
160
|
-
myInsertion2: "Cześć, mam na imię {{name}} i mam {{age}} lat!", // Since intlayer v8, insertion function is not required anymore. The content will be automatically decorated.
|
|
161
|
-
},
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
export default myInsertionContent;
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
```javascript fileName="**/*.content.cjs" contentDeclarationFormat="commonjs"
|
|
168
|
-
javascript fileName="**/*.content.cjs" contentDeclarationFormat="commonjs"
|
|
169
|
-
const { insert } = require("intlayer");
|
|
170
|
-
|
|
171
|
-
/** @type {import('intlayer').Dictionary} */
|
|
172
|
-
const myInsertionContent = {
|
|
173
|
-
key: "my_key",
|
|
174
|
-
content: {
|
|
175
|
-
myInsertion: insert(
|
|
176
|
-
"Cześć, mam na imię {{name}} i mam {{age}} lat!"
|
|
177
|
-
),
|
|
178
|
-
myInsertion2: "Cześć, mam na imię {{name}} i mam {{age}} lat!", // Since intlayer v8, insertion function is not required anymore. The content will be automatically decorated.
|
|
179
|
-
},
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
module.exports = myInsertionContent;
|
|
183
|
-
```
|
|
184
|
-
|
|
185
100
|
```json5 fileName="**/*.content.json" contentDeclarationFormat="json"
|
|
186
101
|
{
|
|
187
102
|
"$schema": "https://intlayer.org/schema.json",
|
|
@@ -178,20 +178,69 @@ Możesz konsumować słowniki bezpośrednio w swoich plikach `.astro`, używają
|
|
|
178
178
|
|
|
179
179
|
```astro fileName="src/pages/index.astro"
|
|
180
180
|
---
|
|
181
|
-
import {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
181
|
+
import {
|
|
182
|
+
getIntlayer,
|
|
183
|
+
getLocaleFromPath,
|
|
184
|
+
getLocalizedUrl,
|
|
185
|
+
defaultLocale,
|
|
186
|
+
localeMap,
|
|
187
|
+
getHTMLTextDir,
|
|
188
|
+
type LocalesValues,
|
|
189
|
+
} from "intlayer";
|
|
190
|
+
import LocaleSwitcher from "../components/LocaleSwitcher.astro";
|
|
191
|
+
|
|
192
|
+
// Get the current locale from the URL (e.g. /es/about -> 'es')
|
|
193
|
+
const locale = getLocaleFromPath(Astro.url.pathname) as LocalesValues;
|
|
194
|
+
|
|
195
|
+
// Get the content for the 'app' dictionary
|
|
196
|
+
const { title } = getIntlayer("app", locale);
|
|
185
197
|
---
|
|
186
198
|
|
|
187
|
-
|
|
199
|
+
<!doctype html>
|
|
200
|
+
<html lang={locale} dir={getHTMLTextDir(locale)}>
|
|
188
201
|
<head>
|
|
189
202
|
<meta charset="utf-8" />
|
|
190
203
|
<meta name="viewport" content="width=device-width" />
|
|
204
|
+
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
191
205
|
<title>{title}</title>
|
|
206
|
+
|
|
207
|
+
<!-- Canonical link: Tells search engines which is the primary version of this page -->
|
|
208
|
+
<link
|
|
209
|
+
rel="canonical"
|
|
210
|
+
href={new URL(getLocalizedUrl(Astro.url.pathname, locale), Astro.site)}
|
|
211
|
+
/>
|
|
212
|
+
|
|
213
|
+
<!-- Hreflang: Tell Google about all localized versions -->
|
|
214
|
+
{
|
|
215
|
+
localeMap(({ locale: mapLocale }) => (
|
|
216
|
+
<link
|
|
217
|
+
rel="alternate"
|
|
218
|
+
hreflang={mapLocale}
|
|
219
|
+
href={new URL(
|
|
220
|
+
getLocalizedUrl(Astro.url.pathname, mapLocale),
|
|
221
|
+
Astro.site
|
|
222
|
+
)}
|
|
223
|
+
/>
|
|
224
|
+
))
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
<!-- x-default: Fallback for users in unmatched languages -->
|
|
228
|
+
<link
|
|
229
|
+
rel="alternate"
|
|
230
|
+
hreflang="x-default"
|
|
231
|
+
href={new URL(
|
|
232
|
+
getLocalizedUrl(Astro.url.pathname, defaultLocale),
|
|
233
|
+
Astro.site
|
|
234
|
+
)}
|
|
235
|
+
/>
|
|
192
236
|
</head>
|
|
193
237
|
<body>
|
|
194
|
-
<
|
|
238
|
+
<header>
|
|
239
|
+
<LocaleSwitcher />
|
|
240
|
+
</header>
|
|
241
|
+
<main>
|
|
242
|
+
<h1>{title}</h1>
|
|
243
|
+
</main>
|
|
195
244
|
</body>
|
|
196
245
|
</html>
|
|
197
246
|
```
|
|
@@ -144,50 +144,6 @@ const helloWorldContent = {
|
|
|
144
144
|
export default helloWorldContent;
|
|
145
145
|
```
|
|
146
146
|
|
|
147
|
-
```tsx fileName="hello-world.es.content.mjs" contentDeclarationFormat="esm"
|
|
148
|
-
import { t, Locales } from "intlayer";
|
|
149
|
-
|
|
150
|
-
/** @type {import('intlayer').Dictionary} */
|
|
151
|
-
// Definicja słownika treści dla komponentu "hello-world" w języku hiszpańskim
|
|
152
|
-
const helloWorldContent = {
|
|
153
|
-
key: "hello-world",
|
|
154
|
-
locale: Locales.SPANISH, // Ważne
|
|
155
|
-
content: { multilingualContent: "Título de mi componente" },
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
export default helloWorldContent;
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
```js fileName="hello-world.en.content.cjs" contentDeclarationFormat="commonjs"
|
|
162
|
-
const { t, Locales } = require("intlayer");
|
|
163
|
-
|
|
164
|
-
/** @type {import('intlayer').Dictionary} */
|
|
165
|
-
const helloWorldContent = {
|
|
166
|
-
key: "hello-world",
|
|
167
|
-
locale: Locales.ENGLISH, // Ważne
|
|
168
|
-
content: {
|
|
169
|
-
multilingualContent: "Title of my component",
|
|
170
|
-
},
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
module.exports = helloWorldContent;
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
```tsx fileName="hello-world.es.content.cjs" contentDeclarationFormat="commonjs"
|
|
177
|
-
const { t, Locales } = require("intlayer");
|
|
178
|
-
|
|
179
|
-
/** @type {import('intlayer').Dictionary} */
|
|
180
|
-
const helloWorldContent = {
|
|
181
|
-
key: "hello-world",
|
|
182
|
-
locale: Locales.SPANISH, // Ważne
|
|
183
|
-
content: {
|
|
184
|
-
multilingualContent: "Título de mi componente",
|
|
185
|
-
},
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
module.exports = helloWorldContent;
|
|
189
|
-
```
|
|
190
|
-
|
|
191
147
|
```json5 fileName="hello-world.en.content.json" contentDeclarationFormat="json"
|
|
192
148
|
{
|
|
193
149
|
"$schema": "https://intlayer.org/schema.json",
|
|
@@ -56,38 +56,6 @@ Para configurar conteúdo de inserção no seu projeto Intlayer, crie um módulo
|
|
|
56
56
|
export default myInsertionContent;
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
```javascript fileName="**/*.content.mjs" contentDeclarationFormat="esm"
|
|
60
|
-
import { insert } from "intlayer";
|
|
61
|
-
|
|
62
|
-
/** @type {import('intlayer').Dictionary} */
|
|
63
|
-
const myInsertionContent = {
|
|
64
|
-
key: "my_key",
|
|
65
|
-
content: {
|
|
66
|
-
myInsertion: insert(
|
|
67
|
-
"Hello, my name is {{name}} and I am {{age}} years old!"
|
|
68
|
-
),
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export default myInsertionContent;
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
```javascript fileName="**/*.content.cjs" contentDeclarationFormat="commonjs"
|
|
76
|
-
const { insert } = require("intlayer");
|
|
77
|
-
|
|
78
|
-
/** @type {import('intlayer').Dictionary} */
|
|
79
|
-
const myInsertionContent = {
|
|
80
|
-
key: "my_key",
|
|
81
|
-
content: {
|
|
82
|
-
myInsertion: insert(
|
|
83
|
-
"Hello, my name is {{name}} and I am {{age}} years old!"
|
|
84
|
-
),
|
|
85
|
-
},
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
module.exports = myInsertionContent;
|
|
89
|
-
```
|
|
90
|
-
|
|
91
59
|
```json5 fileName="**/*.content.json" contentDeclarationFormat="json"
|
|
92
60
|
{
|
|
93
61
|
"$schema": "https://intlayer.org/schema.json",
|
|
@@ -118,30 +86,6 @@ Para configurar conteúdo de inserção no seu projeto Intlayer, crie um módulo
|
|
|
118
86
|
export default myInsertionContent;
|
|
119
87
|
```
|
|
120
88
|
|
|
121
|
-
```javascript fileName="**/*.content.mjs" contentDeclarationFormat="esm"
|
|
122
|
-
/** @type {import('intlayer').Dictionary} */
|
|
123
|
-
const myInsertionContent = {
|
|
124
|
-
key: "my_key",
|
|
125
|
-
content: {
|
|
126
|
-
myInsertion: "Hello, my name is {{name}} and I am {{age}} years old!",
|
|
127
|
-
},
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
export default myInsertionContent;
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
```javascript fileName="**/*.content.cjs" contentDeclarationFormat="commonjs"
|
|
134
|
-
/** @type {import('intlayer').Dictionary} */
|
|
135
|
-
const myInsertionContent = {
|
|
136
|
-
key: "my_key",
|
|
137
|
-
content: {
|
|
138
|
-
myInsertion: "Hello, my name is {{name}} and I am {{age}} years old!",
|
|
139
|
-
},
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
module.exports = myInsertionContent;
|
|
143
|
-
```
|
|
144
|
-
|
|
145
89
|
```json5 fileName="**/*.content.json" contentDeclarationFormat="json"
|
|
146
90
|
{
|
|
147
91
|
"$schema": "https://intlayer.org/schema.json",
|
|
@@ -155,43 +99,6 @@ Para configurar conteúdo de inserção no seu projeto Intlayer, crie um módulo
|
|
|
155
99
|
</Tab>
|
|
156
100
|
</Tabs>
|
|
157
101
|
|
|
158
|
-
```javascript fileName="**/*.content.mjs" contentDeclarationFormat="esm"
|
|
159
|
-
import { insert } from "intlayer";
|
|
160
|
-
|
|
161
|
-
/** @type {import('intlayer').Dictionary} */
|
|
162
|
-
const myInsertionContent = {
|
|
163
|
-
key: "my_key",
|
|
164
|
-
content: {
|
|
165
|
-
myInsertion: insert(
|
|
166
|
-
// Inserção com placeholders para nome e idade
|
|
167
|
-
"Hello, my name is {{name}} and I am {{age}} years old!"
|
|
168
|
-
),
|
|
169
|
-
myInsertion2: "Hello, my name is {{name}} and I am {{age}} years old!", // Since intlayer v8, insertion function is not required anymore. The content will be automatically decorated.
|
|
170
|
-
},
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
export default myInsertionContent;
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
```javascript fileName="**/*.content.cjs" contentDeclarationFormat="commonjs"
|
|
177
|
-
javascript fileName="**/*.content.cjs" contentDeclarationFormat="commonjs"
|
|
178
|
-
const { insert } = require("intlayer");
|
|
179
|
-
|
|
180
|
-
/** @type {import('intlayer').Dictionary} */
|
|
181
|
-
const myInsertionContent = {
|
|
182
|
-
key: "my_key",
|
|
183
|
-
content: {
|
|
184
|
-
myInsertion: insert(
|
|
185
|
-
// Inserção com placeholders para nome e idade
|
|
186
|
-
"Hello, my name is {{name}} and I am {{age}} years old!"
|
|
187
|
-
),
|
|
188
|
-
myInsertion2: "Hello, my name is {{name}} and I am {{age}} years old!", // Since intlayer v8, insertion function is not required anymore. The content will be automatically decorated.
|
|
189
|
-
},
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
module.exports = myInsertionContent;
|
|
193
|
-
```
|
|
194
|
-
|
|
195
102
|
```json5 fileName="**/*.content.json" contentDeclarationFormat="json"
|
|
196
103
|
{
|
|
197
104
|
"$schema": "https://intlayer.org/schema.json",
|
|
@@ -178,20 +178,69 @@ Você pode consumir os dicionários diretamente nos seus arquivos `.astro` usand
|
|
|
178
178
|
|
|
179
179
|
```astro fileName="src/pages/index.astro"
|
|
180
180
|
---
|
|
181
|
-
import {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
181
|
+
import {
|
|
182
|
+
getIntlayer,
|
|
183
|
+
getLocaleFromPath,
|
|
184
|
+
getLocalizedUrl,
|
|
185
|
+
defaultLocale,
|
|
186
|
+
localeMap,
|
|
187
|
+
getHTMLTextDir,
|
|
188
|
+
type LocalesValues,
|
|
189
|
+
} from "intlayer";
|
|
190
|
+
import LocaleSwitcher from "../components/LocaleSwitcher.astro";
|
|
191
|
+
|
|
192
|
+
// Get the current locale from the URL (e.g. /es/about -> 'es')
|
|
193
|
+
const locale = getLocaleFromPath(Astro.url.pathname) as LocalesValues;
|
|
194
|
+
|
|
195
|
+
// Get the content for the 'app' dictionary
|
|
196
|
+
const { title } = getIntlayer("app", locale);
|
|
185
197
|
---
|
|
186
198
|
|
|
187
|
-
|
|
199
|
+
<!doctype html>
|
|
200
|
+
<html lang={locale} dir={getHTMLTextDir(locale)}>
|
|
188
201
|
<head>
|
|
189
202
|
<meta charset="utf-8" />
|
|
190
203
|
<meta name="viewport" content="width=device-width" />
|
|
204
|
+
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
191
205
|
<title>{title}</title>
|
|
206
|
+
|
|
207
|
+
<!-- Canonical link: Tells search engines which is the primary version of this page -->
|
|
208
|
+
<link
|
|
209
|
+
rel="canonical"
|
|
210
|
+
href={new URL(getLocalizedUrl(Astro.url.pathname, locale), Astro.site)}
|
|
211
|
+
/>
|
|
212
|
+
|
|
213
|
+
<!-- Hreflang: Tell Google about all localized versions -->
|
|
214
|
+
{
|
|
215
|
+
localeMap(({ locale: mapLocale }) => (
|
|
216
|
+
<link
|
|
217
|
+
rel="alternate"
|
|
218
|
+
hreflang={mapLocale}
|
|
219
|
+
href={new URL(
|
|
220
|
+
getLocalizedUrl(Astro.url.pathname, mapLocale),
|
|
221
|
+
Astro.site
|
|
222
|
+
)}
|
|
223
|
+
/>
|
|
224
|
+
))
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
<!-- x-default: Fallback for users in unmatched languages -->
|
|
228
|
+
<link
|
|
229
|
+
rel="alternate"
|
|
230
|
+
hreflang="x-default"
|
|
231
|
+
href={new URL(
|
|
232
|
+
getLocalizedUrl(Astro.url.pathname, defaultLocale),
|
|
233
|
+
Astro.site
|
|
234
|
+
)}
|
|
235
|
+
/>
|
|
192
236
|
</head>
|
|
193
237
|
<body>
|
|
194
|
-
<
|
|
238
|
+
<header>
|
|
239
|
+
<LocaleSwitcher />
|
|
240
|
+
</header>
|
|
241
|
+
<main>
|
|
242
|
+
<h1>{title}</h1>
|
|
243
|
+
</main>
|
|
195
244
|
</body>
|
|
196
245
|
</html>
|
|
197
246
|
```
|
|
@@ -453,29 +453,6 @@ const metadataContent = {
|
|
|
453
453
|
export default metadataContent;
|
|
454
454
|
```
|
|
455
455
|
|
|
456
|
-
```javascript fileName="src/pages/[locale]/metadata.content.cjs" contentDeclarationFormat="commonjs"
|
|
457
|
-
const { t } = require("intlayer");
|
|
458
|
-
|
|
459
|
-
/** @type {import('intlayer').Dictionary<import('next').Metadata>} */
|
|
460
|
-
const metadataContent = {
|
|
461
|
-
key: "page-metadata",
|
|
462
|
-
content: {
|
|
463
|
-
title: t({
|
|
464
|
-
en: "Create Next App",
|
|
465
|
-
fr: "Créer une application Next.js",
|
|
466
|
-
es: "Crear una aplicación Next.js",
|
|
467
|
-
}),
|
|
468
|
-
description: t({
|
|
469
|
-
en: "Generated by create next app",
|
|
470
|
-
fr: "Généré par create next app",
|
|
471
|
-
es: "Generado por create next app",
|
|
472
|
-
}),
|
|
473
|
-
},
|
|
474
|
-
};
|
|
475
|
-
|
|
476
|
-
module.exports = metadataContent;
|
|
477
|
-
```
|
|
478
|
-
|
|
479
456
|
```json fileName="src/pages/[locale]/metadata.content.json" contentDeclarationFormat="json"
|
|
480
457
|
{
|
|
481
458
|
"key": "page-metadata",
|
|
@@ -145,50 +145,6 @@ const helloWorldContent = {
|
|
|
145
145
|
export default helloWorldContent;
|
|
146
146
|
```
|
|
147
147
|
|
|
148
|
-
```tsx fileName="hello-world.es.content.mjs" contentDeclarationFormat="esm"
|
|
149
|
-
import { t, Locales } from "intlayer";
|
|
150
|
-
|
|
151
|
-
/** @type {import('intlayer').Dictionary} */
|
|
152
|
-
// Conteúdo para o componente "hello-world" em espanhol
|
|
153
|
-
const helloWorldContent = {
|
|
154
|
-
key: "hello-world",
|
|
155
|
-
locale: Locales.SPANISH, // Importante
|
|
156
|
-
content: { multilingualContent: "Título de mi componente" },
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
export default helloWorldContent;
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
```js fileName="hello-world.en.content.cjs" contentDeclarationFormat="commonjs"
|
|
163
|
-
const { t, Locales } = require("intlayer");
|
|
164
|
-
|
|
165
|
-
/** @type {import('intlayer').Dictionary} */
|
|
166
|
-
const helloWorldContent = {
|
|
167
|
-
key: "hello-world",
|
|
168
|
-
locale: Locales.ENGLISH, // Importante
|
|
169
|
-
content: {
|
|
170
|
-
multilingualContent: "Título do meu componente",
|
|
171
|
-
},
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
module.exports = helloWorldContent;
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
```tsx fileName="hello-world.es.content.cjs" contentDeclarationFormat="commonjs"
|
|
178
|
-
const { t, Locales } = require("intlayer");
|
|
179
|
-
|
|
180
|
-
/** @type {import('intlayer').Dictionary} */
|
|
181
|
-
const helloWorldContent = {
|
|
182
|
-
key: "hello-world",
|
|
183
|
-
locale: Locales.SPANISH, // Importante
|
|
184
|
-
content: {
|
|
185
|
-
multilingualContent: "Título de mi componente",
|
|
186
|
-
},
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
module.exports = helloWorldContent;
|
|
190
|
-
```
|
|
191
|
-
|
|
192
148
|
```json5 fileName="hello-world.en.content.json" contentDeclarationFormat="json"
|
|
193
149
|
{
|
|
194
150
|
"$schema": "https://intlayer.org/schema.json",
|
|
@@ -54,34 +54,6 @@ history:
|
|
|
54
54
|
export default myInsertionContent;
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
```javascript fileName="**/*.content.mjs" contentDeclarationFormat="esm"
|
|
58
|
-
import { insert } from "intlayer";
|
|
59
|
-
|
|
60
|
-
/** @type {import('intlayer').Dictionary} */
|
|
61
|
-
const myInsertionContent = {
|
|
62
|
-
key: "my_key",
|
|
63
|
-
content: {
|
|
64
|
-
myInsertion: insert("Привет, меня зовут {{name}} и мне {{age}} лет!"),
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export default myInsertionContent;
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
```javascript fileName="**/*.content.cjs" contentDeclarationFormat="commonjs"
|
|
72
|
-
const { insert } = require("intlayer");
|
|
73
|
-
|
|
74
|
-
/** @type {import('intlayer').Dictionary} */
|
|
75
|
-
const myInsertionContent = {
|
|
76
|
-
key: "my_key",
|
|
77
|
-
content: {
|
|
78
|
-
myInsertion: insert("Привет, меня зовут {{name}} и мне {{age}} лет!"),
|
|
79
|
-
},
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
module.exports = myInsertionContent;
|
|
83
|
-
```
|
|
84
|
-
|
|
85
57
|
```json5 fileName="**/*.content.json" contentDeclarationFormat="json"
|
|
86
58
|
{
|
|
87
59
|
"$schema": "https://intlayer.org/schema.json",
|
|
@@ -112,30 +84,6 @@ history:
|
|
|
112
84
|
export default myInsertionContent;
|
|
113
85
|
```
|
|
114
86
|
|
|
115
|
-
```javascript fileName="**/*.content.mjs" contentDeclarationFormat="esm"
|
|
116
|
-
/** @type {import('intlayer').Dictionary} */
|
|
117
|
-
const myInsertionContent = {
|
|
118
|
-
key: "my_key",
|
|
119
|
-
content: {
|
|
120
|
-
myInsertion: "Привет, меня зовут {{name}} и мне {{age}} лет!",
|
|
121
|
-
},
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
export default myInsertionContent;
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
```javascript fileName="**/*.content.cjs" contentDeclarationFormat="commonjs"
|
|
128
|
-
/** @type {import('intlayer').Dictionary} */
|
|
129
|
-
const myInsertionContent = {
|
|
130
|
-
key: "my_key",
|
|
131
|
-
content: {
|
|
132
|
-
myInsertion: "Привет, меня зовут {{name}} и мне {{age}} лет!",
|
|
133
|
-
},
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
module.exports = myInsertionContent;
|
|
137
|
-
```
|
|
138
|
-
|
|
139
87
|
```json5 fileName="**/*.content.json" contentDeclarationFormat="json"
|
|
140
88
|
{
|
|
141
89
|
"$schema": "https://intlayer.org/schema.json",
|
|
@@ -176,22 +176,70 @@ export default appContent;
|
|
|
176
176
|
Вы можете использовать словари напрямую в файлах `.astro`, используя основные хелперы, экспортируемые из `intlayer`.
|
|
177
177
|
|
|
178
178
|
```astro fileName="src/pages/index.astro"
|
|
179
|
-
<!-- astro -->
|
|
180
179
|
---
|
|
181
|
-
import {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
180
|
+
import {
|
|
181
|
+
getIntlayer,
|
|
182
|
+
getLocaleFromPath,
|
|
183
|
+
getLocalizedUrl,
|
|
184
|
+
defaultLocale,
|
|
185
|
+
localeMap,
|
|
186
|
+
getHTMLTextDir,
|
|
187
|
+
type LocalesValues,
|
|
188
|
+
} from "intlayer";
|
|
189
|
+
import LocaleSwitcher from "../components/LocaleSwitcher.astro";
|
|
190
|
+
|
|
191
|
+
// Get the current locale from the URL (e.g. /es/about -> 'es')
|
|
192
|
+
const locale = getLocaleFromPath(Astro.url.pathname) as LocalesValues;
|
|
193
|
+
|
|
194
|
+
// Get the content for the 'app' dictionary
|
|
195
|
+
const { title } = getIntlayer("app", locale);
|
|
185
196
|
---
|
|
186
197
|
|
|
187
|
-
|
|
198
|
+
<!doctype html>
|
|
199
|
+
<html lang={locale} dir={getHTMLTextDir(locale)}>
|
|
188
200
|
<head>
|
|
189
201
|
<meta charset="utf-8" />
|
|
190
202
|
<meta name="viewport" content="width=device-width" />
|
|
203
|
+
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
191
204
|
<title>{title}</title>
|
|
205
|
+
|
|
206
|
+
<!-- Canonical link: Tells search engines which is the primary version of this page -->
|
|
207
|
+
<link
|
|
208
|
+
rel="canonical"
|
|
209
|
+
href={new URL(getLocalizedUrl(Astro.url.pathname, locale), Astro.site)}
|
|
210
|
+
/>
|
|
211
|
+
|
|
212
|
+
<!-- Hreflang: Tell Google about all localized versions -->
|
|
213
|
+
{
|
|
214
|
+
localeMap(({ locale: mapLocale }) => (
|
|
215
|
+
<link
|
|
216
|
+
rel="alternate"
|
|
217
|
+
hreflang={mapLocale}
|
|
218
|
+
href={new URL(
|
|
219
|
+
getLocalizedUrl(Astro.url.pathname, mapLocale),
|
|
220
|
+
Astro.site
|
|
221
|
+
)}
|
|
222
|
+
/>
|
|
223
|
+
))
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
<!-- x-default: Fallback for users in unmatched languages -->
|
|
227
|
+
<link
|
|
228
|
+
rel="alternate"
|
|
229
|
+
hreflang="x-default"
|
|
230
|
+
href={new URL(
|
|
231
|
+
getLocalizedUrl(Astro.url.pathname, defaultLocale),
|
|
232
|
+
Astro.site
|
|
233
|
+
)}
|
|
234
|
+
/>
|
|
192
235
|
</head>
|
|
193
236
|
<body>
|
|
194
|
-
<
|
|
237
|
+
<header>
|
|
238
|
+
<LocaleSwitcher />
|
|
239
|
+
</header>
|
|
240
|
+
<main>
|
|
241
|
+
<h1>{title}</h1>
|
|
242
|
+
</main>
|
|
195
243
|
</body>
|
|
196
244
|
</html>
|
|
197
245
|
```
|