@intlayer/docs 6.1.5 → 6.1.6-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/blog/ar/next-i18next_vs_next-intl_vs_intlayer.md +404 -173
- package/blog/de/next-i18next_vs_next-intl_vs_intlayer.md +262 -113
- package/blog/en/intlayer_with_next-i18next.mdx +431 -0
- package/blog/en/intlayer_with_next-intl.mdx +335 -0
- package/blog/en/next-i18next_vs_next-intl_vs_intlayer.md +403 -140
- package/blog/en-GB/next-i18next_vs_next-intl_vs_intlayer.md +38 -28
- package/blog/es/next-i18next_vs_next-intl_vs_intlayer.md +185 -71
- package/blog/fr/next-i18next_vs_next-intl_vs_intlayer.md +38 -28
- package/blog/it/next-i18next_vs_next-intl_vs_intlayer.md +38 -28
- package/blog/ja/next-i18next_vs_next-intl_vs_intlayer.md +38 -28
- package/blog/ko/next-i18next_vs_next-intl_vs_intlayer.md +38 -28
- package/blog/pt/next-i18next_vs_next-intl_vs_intlayer.md +38 -28
- package/blog/ru/next-i18next_vs_next-intl_vs_intlayer.md +36 -28
- package/blog/tr/next-i18next_vs_next-intl_vs_intlayer.md +2 -0
- package/blog/zh/next-i18next_vs_next-intl_vs_intlayer.md +38 -28
- package/dist/cjs/generated/docs.entry.cjs +16 -0
- package/dist/cjs/generated/docs.entry.cjs.map +1 -1
- package/dist/esm/generated/docs.entry.mjs +16 -0
- package/dist/esm/generated/docs.entry.mjs.map +1 -1
- package/dist/types/generated/docs.entry.d.ts +1 -0
- package/dist/types/generated/docs.entry.d.ts.map +1 -1
- package/docs/ar/component_i18n.md +186 -0
- package/docs/ar/vs_code_extension.md +48 -109
- package/docs/de/component_i18n.md +186 -0
- package/docs/de/vs_code_extension.md +46 -107
- package/docs/en/component_i18n.md +186 -0
- package/docs/en/intlayer_with_nextjs_14.md +18 -1
- package/docs/en/intlayer_with_nextjs_15.md +18 -1
- package/docs/en/vs_code_extension.md +24 -114
- package/docs/en-GB/component_i18n.md +186 -0
- package/docs/en-GB/vs_code_extension.md +42 -103
- package/docs/es/component_i18n.md +182 -0
- package/docs/es/vs_code_extension.md +53 -114
- package/docs/fr/component_i18n.md +186 -0
- package/docs/fr/vs_code_extension.md +50 -111
- package/docs/hi/component_i18n.md +186 -0
- package/docs/hi/vs_code_extension.md +49 -110
- package/docs/it/component_i18n.md +186 -0
- package/docs/it/vs_code_extension.md +50 -111
- package/docs/ja/component_i18n.md +186 -0
- package/docs/ja/vs_code_extension.md +50 -111
- package/docs/ko/component_i18n.md +186 -0
- package/docs/ko/vs_code_extension.md +48 -109
- package/docs/pt/component_i18n.md +186 -0
- package/docs/pt/vs_code_extension.md +46 -107
- package/docs/ru/component_i18n.md +186 -0
- package/docs/ru/vs_code_extension.md +48 -109
- package/docs/tr/component_i18n.md +186 -0
- package/docs/tr/vs_code_extension.md +54 -115
- package/docs/zh/component_i18n.md +186 -0
- package/docs/zh/vs_code_extension.md +51 -105
- package/package.json +11 -11
- package/src/generated/docs.entry.ts +16 -0
|
@@ -19,6 +19,8 @@ slugs:
|
|
|
19
19
|
|
|
20
20
|
# next-i18next VS next-intl VS intlayer | Next.js Uluslararasılaştırma (i18n)
|
|
21
21
|
|
|
22
|
+

|
|
23
|
+
|
|
22
24
|
Bu rehber, **Next.js** için yaygın olarak kullanılan üç i18n seçeneğini karşılaştırır: **next-intl**, **next-i18next** ve **Intlayer**.
|
|
23
25
|
**Next.js 13+ App Router**'a (React Server Components ile) odaklanıyoruz ve şunları değerlendiriyoruz:
|
|
24
26
|
|
|
@@ -19,6 +19,8 @@ slugs:
|
|
|
19
19
|
|
|
20
20
|
# next-i18next VS next-intl VS intlayer | Next.js 国际化 (i18n)
|
|
21
21
|
|
|
22
|
+

|
|
23
|
+
|
|
22
24
|
让我们来看看 Next.js 的三种 i18n 方案:next-i18next、next-intl 和 Intlayer 之间的相似点和差异。
|
|
23
25
|
|
|
24
26
|
这不是一个完整的教程,而是一个帮助你选择的比较。
|
|
@@ -173,9 +175,9 @@ Next.js 为你内置了国际化路由支持(例如区域段)。但该功能
|
|
|
173
175
|
|
|
174
176
|
下面是使用 `intlayer` 在 vite + react 应用中进行包大小优化的影响示例:
|
|
175
177
|
|
|
176
|
-
| 优化后的包
|
|
177
|
-
|
|
|
178
|
-
|  |  |
|
|
178
|
+
| 优化后的包 | 未优化的包 |
|
|
179
|
+
| ----------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
|
|
180
|
+
|  |  |
|
|
179
181
|
|
|
180
182
|
---
|
|
181
183
|
|
|
@@ -348,25 +350,25 @@ Next.js 为你内置了国际化路由支持(例如区域段)。但该功能
|
|
|
348
350
|
|
|
349
351
|
```bash
|
|
350
352
|
.
|
|
351
|
-
├──
|
|
352
|
-
│ └── locales
|
|
353
|
-
│ ├── en
|
|
354
|
-
│ │ ├── home.json
|
|
355
|
-
│ │ └── navbar.json
|
|
356
|
-
│ ├── fr
|
|
357
|
-
│ │ ├── home.json
|
|
358
|
-
│ │ └── navbar.json
|
|
359
|
-
│ └── es
|
|
360
|
-
│ ├── home.json
|
|
361
|
-
│ └── navbar.json
|
|
362
|
-
├── next-i18next.config.js
|
|
353
|
+
├── i18n.config.ts
|
|
363
354
|
└── src
|
|
364
|
-
├──
|
|
355
|
+
├── locales
|
|
356
|
+
│ ├── en
|
|
357
|
+
│ │ ├── common.json
|
|
358
|
+
│ │ └── about.json
|
|
359
|
+
│ └── fr
|
|
360
|
+
│ ├── common.json
|
|
361
|
+
│ └── about.json
|
|
365
362
|
├── app
|
|
366
|
-
│
|
|
363
|
+
│ ├── i18n
|
|
364
|
+
│ │ └── server.ts
|
|
365
|
+
│ └── [locale]
|
|
366
|
+
│ ├── layout.tsx
|
|
367
|
+
│ └── about.tsx
|
|
367
368
|
└── components
|
|
368
|
-
|
|
369
|
-
|
|
369
|
+
├── I18nProvider.tsx
|
|
370
|
+
├── ClientComponent.tsx
|
|
371
|
+
└── ServerComponent.tsx
|
|
370
372
|
```
|
|
371
373
|
|
|
372
374
|
</TabItem>
|
|
@@ -374,6 +376,7 @@ Next.js 为你内置了国际化路由支持(例如区域段)。但该功能
|
|
|
374
376
|
|
|
375
377
|
```bash
|
|
376
378
|
.
|
|
379
|
+
├── i18n.ts
|
|
377
380
|
├── locales
|
|
378
381
|
│ ├── en
|
|
379
382
|
│ │ ├── home.json
|
|
@@ -384,11 +387,13 @@ Next.js 为你内置了国际化路由支持(例如区域段)。但该功能
|
|
|
384
387
|
│ └── es
|
|
385
388
|
│ ├── home.json
|
|
386
389
|
│ └── navbar.json
|
|
387
|
-
├── i18n.ts
|
|
388
390
|
└── src
|
|
389
391
|
├── middleware.ts
|
|
390
392
|
├── app
|
|
391
|
-
│
|
|
393
|
+
│ ├── i18n
|
|
394
|
+
│ │ └── server.ts
|
|
395
|
+
│ └── [locale]
|
|
396
|
+
│ └── home.tsx
|
|
392
397
|
└── components
|
|
393
398
|
└── Navbar
|
|
394
399
|
└── index.tsx
|
|
@@ -403,9 +408,11 @@ Next.js 为你内置了国际化路由支持(例如区域段)。但该功能
|
|
|
403
408
|
└── src
|
|
404
409
|
├── middleware.ts
|
|
405
410
|
├── app
|
|
406
|
-
│ └──
|
|
407
|
-
│
|
|
408
|
-
│ └──
|
|
411
|
+
│ └── [locale]
|
|
412
|
+
│ ├── layout.tsx
|
|
413
|
+
│ └── home
|
|
414
|
+
│ ├── index.tsx
|
|
415
|
+
│ └── index.content.ts
|
|
409
416
|
└── components
|
|
410
417
|
└── Navbar
|
|
411
418
|
├── index.tsx
|
|
@@ -533,8 +540,10 @@ export default async function LocaleLayout({
|
|
|
533
540
|
const messages = await getMessages();
|
|
534
541
|
const clientMessages = pick(messages, ["common", "about"]);
|
|
535
542
|
|
|
543
|
+
const rtlLocales = ["ar", "he", "fa", "ur"];
|
|
544
|
+
|
|
536
545
|
return (
|
|
537
|
-
<html lang={locale}>
|
|
546
|
+
<html lang={locale} dir={rtlLocales.includes(locale) ? "rtl" : "ltr"}>
|
|
538
547
|
<body>
|
|
539
548
|
<NextIntlClientProvider locale={locale} messages={clientMessages}>
|
|
540
549
|
{children}
|
|
@@ -851,10 +860,11 @@ const ServerComponent = ({ count }: ServerComponentProps) => {
|
|
|
851
860
|
type ServerComponentProps = {
|
|
852
861
|
count: number;
|
|
853
862
|
t: (key: string) => string;
|
|
863
|
+
formatter: Intl.NumberFormat;
|
|
854
864
|
};
|
|
855
865
|
|
|
856
|
-
const ServerComponent = ({ t, count }: ServerComponentProps) => {
|
|
857
|
-
const formatted =
|
|
866
|
+
const ServerComponent = ({ t, count, formatter }: ServerComponentProps) => {
|
|
867
|
+
const formatted = formatter.format(count);
|
|
858
868
|
|
|
859
869
|
return (
|
|
860
870
|
<div>
|
|
@@ -868,7 +878,7 @@ const ServerComponent = ({ t, count }: ServerComponentProps) => {
|
|
|
868
878
|
> 由于服务器组件不能是异步的,因此需要将翻译函数和格式化函数作为属性传递。
|
|
869
879
|
>
|
|
870
880
|
> - `const t = await getTranslations("about.counter");`
|
|
871
|
-
> - `const
|
|
881
|
+
> - `const formatter = await getFormatter().then((formatter) => formatter.number());`
|
|
872
882
|
|
|
873
883
|
</TabItem>
|
|
874
884
|
<TabItem label="intlayer" value="intlayer">
|
|
@@ -75,6 +75,22 @@ const docsEntry = {
|
|
|
75
75
|
hi: readLocale("autoFill.md", "hi"),
|
|
76
76
|
tr: readLocale("autoFill.md", "tr")
|
|
77
77
|
},
|
|
78
|
+
"./docs/en/component_i18n.md": {
|
|
79
|
+
en: readLocale("component_i18n.md", "en"),
|
|
80
|
+
fr: readLocale("component_i18n.md", "fr"),
|
|
81
|
+
ru: readLocale("component_i18n.md", "ru"),
|
|
82
|
+
ja: readLocale("component_i18n.md", "ja"),
|
|
83
|
+
ko: readLocale("component_i18n.md", "ko"),
|
|
84
|
+
zh: readLocale("component_i18n.md", "zh"),
|
|
85
|
+
es: readLocale("component_i18n.md", "es"),
|
|
86
|
+
de: readLocale("component_i18n.md", "de"),
|
|
87
|
+
ar: readLocale("component_i18n.md", "ar"),
|
|
88
|
+
pt: readLocale("component_i18n.md", "pt"),
|
|
89
|
+
"en-GB": readLocale("component_i18n.md", "en-GB"),
|
|
90
|
+
it: readLocale("component_i18n.md", "it"),
|
|
91
|
+
hi: readLocale("component_i18n.md", "hi"),
|
|
92
|
+
tr: readLocale("component_i18n.md", "tr")
|
|
93
|
+
},
|
|
78
94
|
"./docs/en/configuration.md": {
|
|
79
95
|
en: readLocale("configuration.md", "en"),
|
|
80
96
|
fr: readLocale("configuration.md", "fr"),
|