@intlayer/docs 6.1.5 → 6.1.6
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 +463 -209
- 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 +32 -0
- package/dist/cjs/generated/docs.entry.cjs.map +1 -1
- package/dist/esm/generated/docs.entry.mjs +32 -0
- package/dist/esm/generated/docs.entry.mjs.map +1 -1
- package/dist/types/generated/docs.entry.d.ts +2 -0
- package/dist/types/generated/docs.entry.d.ts.map +1 -1
- package/docs/ar/component_i18n.md +186 -0
- package/docs/ar/intlayer_with_angular.md +2 -2
- package/docs/ar/intlayer_with_astro.md +246 -0
- package/docs/ar/intlayer_with_create_react_app.md +3 -2
- package/docs/ar/intlayer_with_express.md +2 -2
- package/docs/ar/intlayer_with_nestjs.md +2 -2
- package/docs/ar/intlayer_with_nextjs_14.md +2 -2
- package/docs/ar/intlayer_with_nextjs_15.md +2 -2
- package/docs/ar/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/ar/intlayer_with_nuxt.md +2 -2
- package/docs/ar/intlayer_with_react_native+expo.md +11 -20
- package/docs/ar/intlayer_with_react_router_v7.md +195 -241
- package/docs/ar/intlayer_with_tanstack.md +198 -272
- package/docs/ar/intlayer_with_vite+preact.md +9 -9
- package/docs/ar/intlayer_with_vite+react.md +7 -7
- package/docs/ar/intlayer_with_vite+vue.md +9 -9
- package/docs/ar/vs_code_extension.md +48 -109
- package/docs/de/component_i18n.md +186 -0
- package/docs/de/intlayer_with_angular.md +2 -2
- package/docs/de/intlayer_with_astro.md +246 -0
- package/docs/de/intlayer_with_create_react_app.md +2 -2
- package/docs/de/intlayer_with_express.md +2 -2
- package/docs/de/intlayer_with_nestjs.md +2 -2
- package/docs/de/intlayer_with_nextjs_14.md +2 -2
- package/docs/de/intlayer_with_nextjs_15.md +2 -2
- package/docs/de/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/de/intlayer_with_nuxt.md +2 -2
- package/docs/de/intlayer_with_react_native+expo.md +11 -20
- package/docs/de/intlayer_with_react_router_v7.md +193 -242
- package/docs/de/intlayer_with_tanstack.md +194 -266
- package/docs/de/intlayer_with_vite+preact.md +9 -9
- package/docs/de/intlayer_with_vite+react.md +9 -9
- package/docs/de/intlayer_with_vite+vue.md +11 -11
- package/docs/de/packages/vite-intlayer/index.md +3 -3
- package/docs/de/vs_code_extension.md +46 -107
- package/docs/en/component_i18n.md +186 -0
- package/docs/en/how_works_intlayer.md +1 -1
- package/docs/en/index.md +1 -1
- package/docs/en/intlayer_cli.md +1 -1
- package/docs/en/intlayer_with_angular.md +4 -4
- package/docs/en/intlayer_with_astro.md +246 -0
- package/docs/en/intlayer_with_create_react_app.md +4 -4
- package/docs/en/intlayer_with_express.md +3 -3
- package/docs/en/intlayer_with_lynx+react.md +1 -1
- package/docs/en/intlayer_with_nestjs.md +2 -2
- package/docs/en/intlayer_with_nextjs_14.md +31 -5
- package/docs/en/intlayer_with_nextjs_15.md +31 -5
- package/docs/en/intlayer_with_nextjs_page_router.md +5 -5
- package/docs/en/intlayer_with_nuxt.md +4 -4
- package/docs/en/intlayer_with_react_native+expo.md +46 -24
- package/docs/en/intlayer_with_react_router_v7.md +164 -211
- package/docs/en/intlayer_with_tanstack.md +166 -241
- package/docs/en/intlayer_with_vite+preact.md +12 -12
- package/docs/en/intlayer_with_vite+react.md +12 -12
- package/docs/en/intlayer_with_vite+solid.md +2 -2
- package/docs/en/intlayer_with_vite+svelte.md +2 -2
- package/docs/en/intlayer_with_vite+vue.md +12 -12
- package/docs/en/introduction.md +1 -1
- package/docs/en/packages/next-intlayer/useDictionary.md +1 -1
- package/docs/en/packages/next-intlayer/useIntlayer.md +1 -1
- package/docs/en/packages/react-intlayer/useDictionary.md +1 -1
- package/docs/en/packages/react-intlayer/useI18n.md +1 -1
- package/docs/en/packages/react-intlayer/useIntlayer.md +1 -1
- package/docs/en/releases/v6.md +1 -0
- package/docs/en/roadmap.md +1 -1
- package/docs/en/vs_code_extension.md +24 -114
- package/docs/en-GB/component_i18n.md +186 -0
- package/docs/en-GB/intlayer_with_angular.md +3 -3
- package/docs/en-GB/intlayer_with_astro.md +246 -0
- package/docs/en-GB/intlayer_with_create_react_app.md +5 -4
- package/docs/en-GB/intlayer_with_express.md +2 -2
- package/docs/en-GB/intlayer_with_nestjs.md +2 -2
- package/docs/en-GB/intlayer_with_nextjs_14.md +4 -4
- package/docs/en-GB/intlayer_with_nextjs_15.md +2 -2
- package/docs/en-GB/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/en-GB/intlayer_with_nuxt.md +2 -2
- package/docs/en-GB/intlayer_with_react_native+expo.md +11 -20
- package/docs/en-GB/intlayer_with_react_router_v7.md +171 -220
- package/docs/en-GB/intlayer_with_tanstack.md +174 -248
- package/docs/en-GB/intlayer_with_vite+preact.md +9 -9
- package/docs/en-GB/intlayer_with_vite+react.md +9 -9
- package/docs/en-GB/intlayer_with_vite+vue.md +11 -11
- package/docs/en-GB/packages/next-intlayer/useIntlayer.md +1 -1
- package/docs/en-GB/packages/react-intlayer/useIntlayer.md +1 -1
- package/docs/en-GB/vs_code_extension.md +42 -103
- package/docs/es/component_i18n.md +182 -0
- package/docs/es/intlayer_with_angular.md +2 -2
- package/docs/es/intlayer_with_astro.md +246 -0
- package/docs/es/intlayer_with_create_react_app.md +3 -2
- package/docs/es/intlayer_with_express.md +2 -2
- package/docs/es/intlayer_with_nextjs_14.md +2 -2
- package/docs/es/intlayer_with_nextjs_15.md +2 -2
- package/docs/es/intlayer_with_react_native+expo.md +11 -20
- package/docs/es/intlayer_with_react_router_v7.md +188 -232
- package/docs/es/intlayer_with_tanstack.md +203 -273
- package/docs/es/intlayer_with_vite+preact.md +7 -7
- package/docs/es/intlayer_with_vite+react.md +7 -7
- package/docs/es/intlayer_with_vite+vue.md +9 -9
- package/docs/es/vs_code_extension.md +53 -114
- package/docs/fr/component_i18n.md +186 -0
- package/docs/fr/intlayer_with_angular.md +2 -2
- package/docs/fr/intlayer_with_astro.md +246 -0
- package/docs/fr/intlayer_with_create_react_app.md +3 -2
- package/docs/fr/intlayer_with_express.md +2 -2
- package/docs/fr/intlayer_with_nestjs.md +2 -2
- package/docs/fr/intlayer_with_nextjs_14.md +2 -2
- package/docs/fr/intlayer_with_react_native+expo.md +11 -20
- package/docs/fr/intlayer_with_react_router_v7.md +188 -248
- package/docs/fr/intlayer_with_tanstack.md +192 -265
- package/docs/fr/intlayer_with_vite+preact.md +7 -7
- package/docs/fr/intlayer_with_vite+react.md +7 -7
- package/docs/fr/intlayer_with_vite+vue.md +9 -9
- package/docs/fr/vs_code_extension.md +50 -111
- package/docs/hi/component_i18n.md +186 -0
- package/docs/hi/intlayer_cli.md +1 -4
- package/docs/hi/intlayer_with_angular.md +2 -2
- package/docs/hi/intlayer_with_astro.md +246 -0
- package/docs/hi/intlayer_with_create_react_app.md +2 -2
- package/docs/hi/intlayer_with_express.md +2 -2
- package/docs/hi/intlayer_with_nestjs.md +2 -2
- package/docs/hi/intlayer_with_nextjs_14.md +2 -2
- package/docs/hi/intlayer_with_nextjs_15.md +2 -2
- package/docs/hi/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/hi/intlayer_with_nuxt.md +2 -2
- package/docs/hi/intlayer_with_react_native+expo.md +11 -20
- package/docs/hi/intlayer_with_react_router_v7.md +199 -243
- package/docs/hi/intlayer_with_tanstack.md +210 -285
- package/docs/hi/intlayer_with_vite+preact.md +9 -9
- package/docs/hi/intlayer_with_vite+react.md +9 -9
- package/docs/hi/intlayer_with_vite+solid.md +1 -1
- package/docs/hi/intlayer_with_vite+vue.md +11 -11
- package/docs/hi/vs_code_extension.md +49 -110
- package/docs/it/component_i18n.md +186 -0
- package/docs/it/intlayer_with_angular.md +2 -2
- package/docs/it/intlayer_with_astro.md +246 -0
- package/docs/it/intlayer_with_create_react_app.md +3 -2
- package/docs/it/intlayer_with_express.md +2 -2
- package/docs/it/intlayer_with_nestjs.md +2 -2
- package/docs/it/intlayer_with_nextjs_14.md +2 -2
- package/docs/it/intlayer_with_nextjs_15.md +2 -2
- package/docs/it/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/it/intlayer_with_nuxt.md +2 -2
- package/docs/it/intlayer_with_react_native+expo.md +11 -21
- package/docs/it/intlayer_with_react_router_v7.md +195 -242
- package/docs/it/intlayer_with_tanstack.md +203 -267
- package/docs/it/intlayer_with_vite+preact.md +9 -9
- package/docs/it/intlayer_with_vite+react.md +13 -11
- package/docs/it/intlayer_with_vite+vue.md +11 -11
- package/docs/it/vs_code_extension.md +50 -111
- package/docs/ja/component_i18n.md +186 -0
- package/docs/ja/intlayer_with_angular.md +2 -2
- package/docs/ja/intlayer_with_astro.md +246 -0
- package/docs/ja/intlayer_with_create_react_app.md +3 -2
- package/docs/ja/intlayer_with_express.md +2 -2
- package/docs/ja/intlayer_with_nestjs.md +2 -2
- package/docs/ja/intlayer_with_nextjs_14.md +2 -2
- package/docs/ja/intlayer_with_nextjs_15.md +2 -2
- package/docs/ja/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/ja/intlayer_with_nuxt.md +2 -2
- package/docs/ja/intlayer_with_react_native+expo.md +18 -29
- package/docs/ja/intlayer_with_react_router_v7.md +204 -250
- package/docs/ja/intlayer_with_tanstack.md +218 -286
- package/docs/ja/intlayer_with_vite+preact.md +9 -9
- package/docs/ja/intlayer_with_vite+react.md +11 -11
- package/docs/ja/intlayer_with_vite+vue.md +11 -11
- package/docs/ja/vs_code_extension.md +50 -111
- package/docs/ko/component_i18n.md +186 -0
- package/docs/ko/intlayer_with_angular.md +2 -2
- package/docs/ko/intlayer_with_astro.md +246 -0
- package/docs/ko/intlayer_with_create_react_app.md +3 -2
- package/docs/ko/intlayer_with_express.md +2 -2
- package/docs/ko/intlayer_with_nestjs.md +2 -2
- package/docs/ko/intlayer_with_nextjs_14.md +2 -2
- package/docs/ko/intlayer_with_nextjs_15.md +2 -2
- package/docs/ko/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/ko/intlayer_with_nuxt.md +2 -2
- package/docs/ko/intlayer_with_react_native+expo.md +19 -28
- package/docs/ko/intlayer_with_react_router_v7.md +190 -244
- package/docs/ko/intlayer_with_tanstack.md +200 -270
- package/docs/ko/intlayer_with_vite+preact.md +9 -9
- package/docs/ko/intlayer_with_vite+react.md +9 -9
- package/docs/ko/intlayer_with_vite+vue.md +11 -11
- package/docs/ko/vs_code_extension.md +48 -109
- package/docs/pt/component_i18n.md +186 -0
- package/docs/pt/intlayer_with_angular.md +2 -2
- package/docs/pt/intlayer_with_astro.md +246 -0
- package/docs/pt/intlayer_with_create_react_app.md +3 -2
- package/docs/pt/intlayer_with_express.md +2 -2
- package/docs/pt/intlayer_with_nestjs.md +2 -2
- package/docs/pt/intlayer_with_nextjs_14.md +2 -2
- package/docs/pt/intlayer_with_nextjs_15.md +2 -2
- package/docs/pt/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/pt/intlayer_with_nuxt.md +2 -2
- package/docs/pt/intlayer_with_react_native+expo.md +11 -20
- package/docs/pt/intlayer_with_react_router_v7.md +7 -13
- package/docs/pt/intlayer_with_tanstack.md +183 -258
- package/docs/pt/intlayer_with_vite+preact.md +9 -9
- package/docs/pt/intlayer_with_vite+react.md +9 -9
- package/docs/pt/intlayer_with_vite+vue.md +9 -9
- package/docs/pt/vs_code_extension.md +46 -107
- package/docs/ru/component_i18n.md +186 -0
- package/docs/ru/intlayer_with_angular.md +2 -2
- package/docs/ru/intlayer_with_astro.md +246 -0
- package/docs/ru/intlayer_with_create_react_app.md +3 -2
- package/docs/ru/intlayer_with_express.md +2 -2
- package/docs/ru/intlayer_with_nestjs.md +2 -2
- package/docs/ru/intlayer_with_nextjs_14.md +2 -2
- package/docs/ru/intlayer_with_nextjs_15.md +2 -2
- package/docs/ru/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/ru/intlayer_with_nuxt.md +2 -2
- package/docs/ru/intlayer_with_react_native+expo.md +11 -20
- package/docs/ru/intlayer_with_react_router_v7.md +192 -238
- package/docs/ru/intlayer_with_tanstack.md +197 -269
- package/docs/ru/intlayer_with_vite+preact.md +9 -9
- package/docs/ru/intlayer_with_vite+react.md +9 -9
- package/docs/ru/intlayer_with_vite+vue.md +11 -11
- package/docs/ru/vs_code_extension.md +48 -109
- package/docs/tr/component_i18n.md +186 -0
- package/docs/tr/how_works_intlayer.md +1 -1
- package/docs/tr/index.md +1 -1
- package/docs/tr/intlayer_cli.md +1 -1
- package/docs/tr/intlayer_with_angular.md +4 -4
- package/docs/tr/intlayer_with_astro.md +246 -0
- package/docs/tr/intlayer_with_create_react_app.md +4 -4
- package/docs/tr/intlayer_with_express.md +3 -3
- package/docs/tr/intlayer_with_lynx+react.md +1 -1
- package/docs/tr/intlayer_with_nestjs.md +2 -2
- package/docs/tr/intlayer_with_nextjs_14.md +2 -2
- package/docs/tr/intlayer_with_nextjs_15.md +4 -4
- package/docs/tr/intlayer_with_nextjs_page_router.md +5 -5
- package/docs/tr/intlayer_with_nuxt.md +4 -4
- package/docs/tr/intlayer_with_react_native+expo.md +12 -21
- package/docs/tr/intlayer_with_react_router_v7.md +222 -267
- package/docs/tr/intlayer_with_tanstack.md +400 -303
- package/docs/tr/intlayer_with_vite+preact.md +12 -12
- package/docs/tr/intlayer_with_vite+react.md +12 -12
- package/docs/tr/intlayer_with_vite+solid.md +2 -2
- package/docs/tr/intlayer_with_vite+svelte.md +2 -2
- package/docs/tr/intlayer_with_vite+vue.md +12 -12
- package/docs/tr/introduction.md +1 -1
- package/docs/tr/packages/react-intlayer/useDictionary.md +1 -1
- package/docs/tr/packages/react-intlayer/useI18n.md +1 -1
- package/docs/tr/roadmap.md +1 -1
- package/docs/tr/vs_code_extension.md +54 -115
- package/docs/zh/component_i18n.md +186 -0
- package/docs/zh/intlayer_with_angular.md +2 -2
- package/docs/zh/intlayer_with_astro.md +246 -0
- package/docs/zh/intlayer_with_create_react_app.md +3 -2
- package/docs/zh/intlayer_with_express.md +2 -2
- package/docs/zh/intlayer_with_nestjs.md +2 -2
- package/docs/zh/intlayer_with_nextjs_14.md +2 -2
- package/docs/zh/intlayer_with_nextjs_15.md +2 -2
- package/docs/zh/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/zh/intlayer_with_nuxt.md +2 -2
- package/docs/zh/intlayer_with_react_native+expo.md +19 -28
- package/docs/zh/intlayer_with_react_router_v7.md +200 -248
- package/docs/zh/intlayer_with_tanstack.md +208 -283
- package/docs/zh/intlayer_with_vite+preact.md +9 -9
- package/docs/zh/intlayer_with_vite+react.md +9 -9
- package/docs/zh/intlayer_with_vite+vue.md +9 -9
- package/docs/zh/vs_code_extension.md +51 -105
- package/package.json +10 -10
- package/src/generated/docs.entry.ts +32 -0
|
@@ -1059,38 +1059,38 @@ const App = () => (
|
|
|
1059
1059
|
module.exports = App;
|
|
1060
1060
|
```
|
|
1061
1061
|
|
|
1062
|
-
In parallelo, puoi anche utilizzare il `
|
|
1062
|
+
In parallelo, puoi anche utilizzare il `intlayerMiddleware` per aggiungere il routing lato server alla tua applicazione. Questo plugin rileverà automaticamente la locale corrente basandosi sull'URL e imposterà il cookie della locale appropriata. Se non viene specificata alcuna locale, il plugin determinerà la locale più adatta in base alle preferenze linguistiche del browser dell'utente. Se non viene rilevata alcuna locale, verrà effettuato un reindirizzamento alla locale predefinita.
|
|
1063
1063
|
|
|
1064
1064
|
```typescript {3,7} fileName="vite.config.ts" codeFormat="typescript"
|
|
1065
1065
|
import { defineConfig } from "vite";
|
|
1066
1066
|
import preact from "@preact/preset-vite";
|
|
1067
|
-
import { intlayer,
|
|
1067
|
+
import { intlayer, intlayerMiddleware } from "vite-intlayer";
|
|
1068
1068
|
|
|
1069
1069
|
// https://vitejs.dev/config/
|
|
1070
1070
|
export default defineConfig({
|
|
1071
|
-
plugins: [preact(), intlayer(),
|
|
1071
|
+
plugins: [preact(), intlayer(), intlayerMiddleware()],
|
|
1072
1072
|
});
|
|
1073
1073
|
```
|
|
1074
1074
|
|
|
1075
1075
|
```javascript {3,7} fileName="vite.config.mjs" codeFormat="esm"
|
|
1076
1076
|
import { defineConfig } from "vite";
|
|
1077
1077
|
import preact from "@preact/preset-vite";
|
|
1078
|
-
import { intlayer,
|
|
1078
|
+
import { intlayer, intlayerMiddleware } from "vite-intlayer";
|
|
1079
1079
|
|
|
1080
1080
|
// https://vitejs.dev/config/
|
|
1081
1081
|
export default defineConfig({
|
|
1082
|
-
plugins: [preact(), intlayer(),
|
|
1082
|
+
plugins: [preact(), intlayer(), intlayerMiddleware()],
|
|
1083
1083
|
});
|
|
1084
1084
|
```
|
|
1085
1085
|
|
|
1086
1086
|
```javascript {3,7} fileName="vite.config.cjs" codeFormat="commonjs"
|
|
1087
1087
|
const { defineConfig } = require("vite");
|
|
1088
1088
|
const preact = require("@preact/preset-vite");
|
|
1089
|
-
const { intlayer,
|
|
1089
|
+
const { intlayer, intlayerMiddleware } = require("vite-intlayer");
|
|
1090
1090
|
|
|
1091
1091
|
// https://vitejs.dev/config/
|
|
1092
1092
|
module.exports = defineConfig({
|
|
1093
|
-
plugins: [preact(), intlayer(),
|
|
1093
|
+
plugins: [preact(), intlayer(), intlayerMiddleware()],
|
|
1094
1094
|
});
|
|
1095
1095
|
```
|
|
1096
1096
|
|
|
@@ -1636,9 +1636,9 @@ module.exports = { LocalizedLink, checkIsExternalLink };
|
|
|
1636
1636
|
|
|
1637
1637
|
Intlayer utilizza l'augmentation dei moduli per sfruttare i vantaggi di TypeScript e rendere il tuo codice più robusto.
|
|
1638
1638
|
|
|
1639
|
-

|
|
1640
1640
|
|
|
1641
|
-

|
|
1642
1642
|
|
|
1643
1643
|
Assicurati che la tua configurazione TypeScript includa i tipi generati automaticamente.
|
|
1644
1644
|
|
|
@@ -1008,38 +1008,38 @@ const App = () => (
|
|
|
1008
1008
|
);
|
|
1009
1009
|
```
|
|
1010
1010
|
|
|
1011
|
-
In parallelo, puoi anche utilizzare il `
|
|
1011
|
+
In parallelo, puoi anche utilizzare il `intlayerMiddleware` per aggiungere il routing lato server alla tua applicazione. Questo plugin rileverà automaticamente la locale corrente basandosi sull'URL e imposterà il cookie della locale appropriata. Se non viene specificata alcuna locale, il plugin determinerà la locale più adatta in base alle preferenze linguistiche del browser dell'utente. Se non viene rilevata alcuna locale, verrà effettuato un reindirizzamento alla locale predefinita.
|
|
1012
1012
|
|
|
1013
1013
|
```typescript {3,7} fileName="vite.config.ts" codeFormat="typescript"
|
|
1014
1014
|
import { defineConfig } from "vite";
|
|
1015
1015
|
import react from "@vitejs/plugin-react-swc";
|
|
1016
|
-
import { intlayer,
|
|
1016
|
+
import { intlayer, intlayerMiddleware } from "vite-intlayer";
|
|
1017
1017
|
|
|
1018
1018
|
// https://vitejs.dev/config/
|
|
1019
1019
|
export default defineConfig({
|
|
1020
|
-
plugins: [react(), intlayer(),
|
|
1020
|
+
plugins: [react(), intlayer(), intlayerMiddleware()],
|
|
1021
1021
|
});
|
|
1022
1022
|
```
|
|
1023
1023
|
|
|
1024
1024
|
```javascript {3,7} fileName="vite.config.mjs" codeFormat="esm"
|
|
1025
1025
|
import { defineConfig } from "vite";
|
|
1026
1026
|
import react from "@vitejs/plugin-react-swc";
|
|
1027
|
-
import { intlayer,
|
|
1027
|
+
import { intlayer, intlayerMiddleware } from "vite-intlayer";
|
|
1028
1028
|
|
|
1029
1029
|
// https://vitejs.dev/config/
|
|
1030
1030
|
export default defineConfig({
|
|
1031
|
-
plugins: [react(), intlayer(),
|
|
1031
|
+
plugins: [react(), intlayer(), intlayerMiddleware()],
|
|
1032
1032
|
});
|
|
1033
1033
|
```
|
|
1034
1034
|
|
|
1035
1035
|
```javascript {3,7} fileName="vite.config.cjs" codeFormat="commonjs"
|
|
1036
1036
|
const { defineConfig } = require("vite");
|
|
1037
1037
|
const react = require("@vitejs/plugin-react-swc");
|
|
1038
|
-
const { intlayer,
|
|
1038
|
+
const { intlayer, intlayerMiddleware } = require("vite-intlayer");
|
|
1039
1039
|
|
|
1040
1040
|
// https://vitejs.dev/config/
|
|
1041
1041
|
module.exports = defineConfig({
|
|
1042
|
-
plugins: [react(), intlayer(),
|
|
1042
|
+
plugins: [react(), intlayer(), intlayerMiddleware()],
|
|
1043
1043
|
});
|
|
1044
1044
|
```
|
|
1045
1045
|
|
|
@@ -1597,9 +1597,9 @@ Integrando questo componente `Link` in tutta la tua applicazione, mantieni un'es
|
|
|
1597
1597
|
|
|
1598
1598
|
Intlayer utilizza l'augmentation dei moduli per sfruttare i vantaggi di TypeScript e rendere il tuo codice più robusto.
|
|
1599
1599
|
|
|
1600
|
-

|
|
1601
1601
|
|
|
1602
|
-

|
|
1603
1603
|
|
|
1604
1604
|
Assicurati che la tua configurazione di TypeScript includa i tipi generati automaticamente.
|
|
1605
1605
|
|
|
@@ -1615,9 +1615,11 @@ Integrando questo componente `Link` in tutta la tua applicazione, mantieni un'es
|
|
|
1615
1615
|
|
|
1616
1616
|
Intlayer utilizza l'augmentation dei moduli per sfruttare i vantaggi di TypeScript e rendere il tuo codice più robusto.
|
|
1617
1617
|
|
|
1618
|
-

|
|
1619
1618
|
|
|
1620
|
-

|
|
1620
|
+
|
|
1621
|
+

|
|
1622
|
+
|
|
1621
1623
|
|
|
1622
1624
|
Assicurati che la tua configurazione TypeScript includa i tipi generati automaticamente.
|
|
1623
1625
|
|
|
@@ -691,46 +691,46 @@ import LocaleSwitcher from "@components/LocaleSwitcher.vue";
|
|
|
691
691
|
</template>
|
|
692
692
|
```
|
|
693
693
|
|
|
694
|
-
Parallelamente, puoi anche utilizzare il `
|
|
694
|
+
Parallelamente, puoi anche utilizzare il `intlayerMiddleware` per aggiungere il routing lato server alla tua applicazione. Questo plugin rileverà automaticamente la locale corrente basandosi sull'URL e imposterà il cookie della locale appropriata. Se non viene specificata alcuna locale, il plugin determinerà la locale più adatta in base alle preferenze linguistiche del browser dell'utente. Se non viene rilevata alcuna locale, effettuerà un reindirizzamento alla locale predefinita.
|
|
695
695
|
|
|
696
696
|
```typescript {3,7} fileName="vite.config.ts" codeFormat="typescript"
|
|
697
697
|
import { defineConfig } from "vite";
|
|
698
698
|
import vue from "@vitejs/plugin-vue";
|
|
699
|
-
import { intlayer,
|
|
699
|
+
import { intlayer, intlayerMiddleware } from "vite-intlayer";
|
|
700
700
|
|
|
701
701
|
// https://vitejs.dev/config/
|
|
702
702
|
export default defineConfig({
|
|
703
|
-
plugins: [vue(), intlayer(),
|
|
703
|
+
plugins: [vue(), intlayer(), intlayerMiddleware()],
|
|
704
704
|
});
|
|
705
705
|
```
|
|
706
706
|
|
|
707
707
|
```javascript {3,7} fileName="vite.config.mjs" codeFormat="esm"
|
|
708
708
|
import { defineConfig } from "vite";
|
|
709
709
|
import vue from "@vitejs/plugin-vue";
|
|
710
|
-
import { intlayer,
|
|
710
|
+
import { intlayer, intlayerMiddleware } from "vite-intlayer";
|
|
711
711
|
|
|
712
712
|
// https://vitejs.dev/config/
|
|
713
713
|
export default defineConfig({
|
|
714
|
-
plugins: [vue(), intlayer(),
|
|
714
|
+
plugins: [vue(), intlayer(), intlayerMiddleware()],
|
|
715
715
|
});
|
|
716
716
|
```
|
|
717
717
|
|
|
718
718
|
```javascript {3,7} fileName="vite.config.cjs" codeFormat="commonjs"
|
|
719
719
|
const { defineConfig } = require("vite");
|
|
720
720
|
const vue = require("@vitejs/plugin-vue");
|
|
721
|
-
const { intlayer,
|
|
721
|
+
const { intlayer, intlayerMiddleware } = require("vite-intlayer");
|
|
722
722
|
|
|
723
723
|
// https://vitejs.dev/config/
|
|
724
724
|
module.exports = defineConfig({
|
|
725
|
-
plugins: [vue(), intlayer(),
|
|
725
|
+
plugins: [vue(), intlayer(), intlayerMiddleware()],
|
|
726
726
|
});
|
|
727
727
|
const { defineConfig } = require("vite");
|
|
728
728
|
const vue = require("@vitejs/plugin-vue");
|
|
729
|
-
const { intlayer,
|
|
729
|
+
const { intlayer, intlayerMiddleware } = require("vite-intlayer");
|
|
730
730
|
|
|
731
731
|
// https://vitejs.dev/config/
|
|
732
732
|
module.exports = defineConfig({
|
|
733
|
-
plugins: [vue(), intlayer(),
|
|
733
|
+
plugins: [vue(), intlayer(), intlayerMiddleware()],
|
|
734
734
|
});
|
|
735
735
|
```
|
|
736
736
|
|
|
@@ -1035,9 +1035,9 @@ const { myMarkdownContent } = useIntlayer("my-component");
|
|
|
1035
1035
|
|
|
1036
1036
|
Intlayer utilizza l'augmentation dei moduli per sfruttare i vantaggi di TypeScript e rendere il tuo codice più robusto.
|
|
1037
1037
|
|
|
1038
|
-

|
|
1039
1039
|
|
|
1040
|
-

|
|
1041
1041
|
|
|
1042
1042
|
Assicurati che la tua configurazione di TypeScript includa i tipi generati automaticamente.
|
|
1043
1043
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
createdAt: 2025-03-17
|
|
3
|
-
updatedAt: 2025-09-
|
|
3
|
+
updatedAt: 2025-09-30
|
|
4
4
|
title: Estensione Ufficiale per VS Code
|
|
5
|
-
description: Scopri come utilizzare l'estensione Intlayer in VS Code per migliorare il tuo flusso di lavoro di sviluppo. Naviga rapidamente tra contenuti localizzati e gestisci i tuoi dizionari in modo efficiente.
|
|
5
|
+
description: Scopri come utilizzare l'estensione Intlayer in VS Code per migliorare il tuo flusso di lavoro di sviluppo. Naviga rapidamente tra i contenuti localizzati e gestisci i tuoi dizionari in modo efficiente.
|
|
6
6
|
keywords:
|
|
7
7
|
- Estensione VS Code
|
|
8
8
|
- Intlayer
|
|
@@ -23,96 +23,40 @@ slugs:
|
|
|
23
23
|
|
|
24
24
|
[**Intlayer**](https://marketplace.visualstudio.com/items?itemName=Intlayer.intlayer-vs-code-extension) è l'estensione ufficiale di Visual Studio Code per **Intlayer**, progettata per migliorare l'esperienza dello sviluppatore quando si lavora con contenuti localizzati nei tuoi progetti.
|
|
25
25
|
|
|
26
|
-

|
|
26
|
+

|
|
27
27
|
|
|
28
28
|
Link all'estensione: [https://marketplace.visualstudio.com/items?itemName=Intlayer.intlayer-vs-code-extension](https://marketplace.visualstudio.com/items?itemName=Intlayer.intlayer-vs-code-extension)
|
|
29
29
|
|
|
30
30
|
## Funzionalità
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+

|
|
33
33
|
|
|
34
|
-
**
|
|
35
|
-
**
|
|
36
|
-
**Supporto Multilingue** – Supporta contenuti localizzati in diverse lingue.
|
|
37
|
-
**Integrazione con VS Code** – Si integra fluidamente con la navigazione e la palette dei comandi di VS Code.
|
|
34
|
+
- **Navigazione Istantanea** – Passa rapidamente al file di contenuto corretto cliccando su una chiave `useIntlayer`.
|
|
35
|
+
- **Riempi Dizionari** – Riempi i dizionari con i contenuti del tuo progetto.
|
|
38
36
|
|
|
39
|
-
|
|
37
|
+

|
|
40
38
|
|
|
41
|
-
|
|
39
|
+
- **Accesso facile ai comandi Intlayer** – Costruisci, invia, scarica, riempi, testa i dizionari di contenuti con facilità.
|
|
42
40
|
|
|
43
|
-
|
|
44
|
-
- **Carica Dizionari** – Carica l'ultimo contenuto del dizionario nel tuo repository.
|
|
45
|
-
- **Scarica Dizionari** – Sincronizza l'ultimo contenuto del dizionario dal tuo repository al tuo ambiente locale.
|
|
46
|
-
- **Riempi Dizionari** – Popola i dizionari con contenuti dal tuo progetto.
|
|
47
|
-
- **Testa Dizionari** – Identifica traduzioni mancanti o incomplete.
|
|
41
|
+

|
|
48
42
|
|
|
49
|
-
|
|
43
|
+
- **Generatore di dichiarazioni di contenuto** – Crea file di contenuto del dizionario in vari formati (`.ts`, `.esm`, `.cjs`, `.json`).
|
|
50
44
|
|
|
51
|
-
|
|
45
|
+

|
|
52
46
|
|
|
53
|
-
|
|
47
|
+
- **Test dizionari** – Testa i dizionari per traduzioni mancanti.
|
|
54
48
|
|
|
55
|
-
|
|
49
|
+

|
|
56
50
|
|
|
57
|
-
|
|
58
|
-
const MyComponent = () => {
|
|
59
|
-
const { myTranslatedContent } = useIntlayer("my-component");
|
|
51
|
+
- **Mantieni i tuoi dizionari aggiornati** – Mantieni i tuoi dizionari aggiornati con i contenuti più recenti del tuo progetto.
|
|
60
52
|
|
|
61
|
-
|
|
62
|
-
};
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
File generato in formato TypeScript:
|
|
66
|
-
|
|
67
|
-
```tsx fileName="src/components/MyComponent/index.content.ts"
|
|
68
|
-
import { t, type Dictionary } from "intlayer";
|
|
69
|
-
|
|
70
|
-
const componentContent = {
|
|
71
|
-
key: "my-component",
|
|
72
|
-
content: {
|
|
73
|
-
myTranslatedContent: t({
|
|
74
|
-
en: "Hello World",
|
|
75
|
-
es: "Hola Mundo",
|
|
76
|
-
fr: "Bonjour le monde",
|
|
77
|
-
}),
|
|
78
|
-
},
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export default componentContent;
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
Formati disponibili:
|
|
85
|
-
|
|
86
|
-
- **TypeScript (`.ts`)**
|
|
87
|
-
- **Modulo ES (`.esm`)**
|
|
88
|
-
- **CommonJS (`.cjs`)**
|
|
89
|
-
- **JSON (`.json`)**
|
|
90
|
-
|
|
91
|
-
### Scheda Intlayer (Barra delle Attività)
|
|
53
|
+

|
|
92
54
|
|
|
93
|
-
|
|
55
|
+
- **Scheda Intlayer (Barra attività)** – Naviga e cerca nei dizionari da una scheda laterale dedicata con barra degli strumenti e azioni contestuali (Costruisci, Scarica, Invia, Riempi, Aggiorna, Testa, Crea file).
|
|
94
56
|
|
|
95
|
-
|
|
96
|
-
- **Dizionari**: Una vista ad albero dei tuoi ambienti/progetti, delle chiavi del dizionario e dei file che contribuiscono con voci. Puoi:
|
|
97
|
-
- Cliccare su un file per aprirlo nell'editor.
|
|
98
|
-
- Usare la barra degli strumenti per eseguire azioni: Build, Pull, Push, Fill, Refresh, Test e Create Dictionary File.
|
|
99
|
-
- Usare il menu contestuale per azioni specifiche dell'elemento:
|
|
100
|
-
- Su un dizionario: Pull o Push
|
|
101
|
-
- Su un file: Fill Dictionary
|
|
102
|
-
- Quando cambi editor, l'albero rivelerà il file corrispondente se appartiene a un dizionario.
|
|
57
|
+
## Uso
|
|
103
58
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
Puoi installare **Intlayer** direttamente dal Marketplace di VS Code:
|
|
107
|
-
|
|
108
|
-
1. Apri **VS Code**.
|
|
109
|
-
2. Vai al **Marketplace delle Estensioni**.
|
|
110
|
-
3. Cerca **"Intlayer"**.
|
|
111
|
-
4. Clicca su **Installa**.
|
|
112
|
-
|
|
113
|
-
## Utilizzo
|
|
114
|
-
|
|
115
|
-
### Navigazione Rapida
|
|
59
|
+
### Navigazione rapida
|
|
116
60
|
|
|
117
61
|
1. Apri un progetto che utilizza **react-intlayer**.
|
|
118
62
|
2. Individua una chiamata a `useIntlayer()`, come:
|
|
@@ -122,62 +66,57 @@ Puoi installare **Intlayer** direttamente dal Marketplace di VS Code:
|
|
|
122
66
|
```
|
|
123
67
|
|
|
124
68
|
3. **Command-click** (`⌘+Click` su macOS) o **Ctrl+Click** (su Windows/Linux) sulla chiave (ad esempio, `"app"`).
|
|
125
|
-
4. VS Code aprirà automaticamente il file
|
|
126
|
-
|
|
127
|
-
### Gestione dei Dizionari di Contenuto
|
|
69
|
+
4. VS Code aprirà automaticamente il file dizionario corrispondente, ad esempio, `src/app.content.ts`.
|
|
128
70
|
|
|
129
|
-
### Scheda Intlayer (Barra
|
|
71
|
+
### Scheda Intlayer (Barra attività)
|
|
130
72
|
|
|
131
73
|
Usa la scheda laterale per navigare e gestire i dizionari:
|
|
132
74
|
|
|
133
|
-
- Apri l'icona Intlayer nella Barra
|
|
134
|
-
- In **
|
|
135
|
-
- In **Dizionari**, esplora ambienti, dizionari e file. Usa la barra degli strumenti per
|
|
75
|
+
- Apri l'icona Intlayer nella Barra attività.
|
|
76
|
+
- In **Cerca**, digita per filtrare dizionari e voci in tempo reale.
|
|
77
|
+
- In **Dizionari**, esplora ambienti, dizionari e file. Usa la barra degli strumenti per Costruisci, Scarica, Invia, Riempi, Aggiorna, Testa e Crea file dizionario. Clic destro per azioni contestuali (Scarica/Invia sui dizionari, Riempi sui file). Il file attualmente aperto nell'editor si evidenzia automaticamente nell'albero quando applicabile.
|
|
136
78
|
|
|
137
|
-
|
|
79
|
+
### Accesso ai comandi
|
|
138
80
|
|
|
139
|
-
|
|
81
|
+
Puoi accedere ai comandi dalla **Command Palette**.
|
|
140
82
|
|
|
141
83
|
```sh
|
|
142
84
|
Cmd + Shift + P (macOS) / Ctrl + Shift + P (Windows/Linux)
|
|
143
85
|
```
|
|
144
86
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
1. Apri la **Palette dei Comandi**.
|
|
152
|
-
2. Cerca **Carica Dizionari**.
|
|
153
|
-
3. Seleziona i dizionari da caricare e conferma.
|
|
154
|
-
|
|
155
|
-
#### Scaricare Dizionari
|
|
87
|
+
- **Costruisci Dizionari**
|
|
88
|
+
- **Invia Dizionari**
|
|
89
|
+
- **Scarica Dizionari**
|
|
90
|
+
- **Riempi Dizionari**
|
|
91
|
+
- **Testa Dizionari**
|
|
92
|
+
- **Crea File Dizionario**
|
|
156
93
|
|
|
157
|
-
|
|
94
|
+
### Caricamento delle Variabili d'Ambiente
|
|
158
95
|
|
|
159
|
-
|
|
160
|
-
2. Cerca **Scarica Dizionari**.
|
|
161
|
-
3. Scegli i dizionari da scaricare.
|
|
96
|
+
Intlayer consiglia di memorizzare le chiavi API AI, così come l'ID client e il segreto di Intlayer, nelle variabili d'ambiente.
|
|
162
97
|
|
|
163
|
-
|
|
98
|
+
L'estensione può caricare le variabili d'ambiente dal tuo workspace per eseguire i comandi Intlayer con il contesto corretto.
|
|
164
99
|
|
|
165
|
-
|
|
100
|
+
- **Ordine di caricamento (per priorità)**: `.env.<env>.local` → `.env.<env>` → `.env.local` → `.env`
|
|
101
|
+
- **Non distruttivo**: i valori esistenti in `process.env` non vengono sovrascritti.
|
|
102
|
+
- **Ambito**: i file vengono risolti dalla directory base configurata (predefinita alla radice del workspace).
|
|
166
103
|
|
|
167
|
-
|
|
168
|
-
2. Cerca **Riempi Dizionari**.
|
|
169
|
-
3. Esegui il comando per popolare i dizionari.
|
|
104
|
+
#### Selezione dell'ambiente attivo
|
|
170
105
|
|
|
171
|
-
|
|
106
|
+
- **Palette dei Comandi**: apri la palette ed esegui `Intlayer: Select Environment`, quindi scegli l'ambiente (ad esempio, `development`, `staging`, `production`). L'estensione tenterà di caricare il primo file disponibile nella lista di priorità sopra indicata e mostrerà una notifica come “Caricato env da .env.<env>.local”.
|
|
107
|
+
- **Impostazioni**: vai su `Impostazioni → Estensioni → Intlayer`, e imposta:
|
|
108
|
+
- **Ambiente**: il nome dell'ambiente usato per risolvere i file `.env.<env>*`.
|
|
109
|
+
- (Opzionale) **File Env**: un percorso esplicito a un file `.env`. Quando fornito, ha la precedenza sulla lista dedotta.
|
|
172
110
|
|
|
173
|
-
|
|
111
|
+
#### Monorepo e directory personalizzate
|
|
174
112
|
|
|
175
|
-
|
|
176
|
-
2. Cerca **Testa Dizionari**.
|
|
177
|
-
3. Rivedi i problemi segnalati e correggili se necessario.
|
|
113
|
+
Se i tuoi file `.env` si trovano al di fuori della radice dello spazio di lavoro, imposta la **Directory Base** in `Impostazioni → Estensioni → Intlayer`. Il loader cercherà i file `.env` relativi a quella directory.
|
|
178
114
|
|
|
179
115
|
## Cronologia Documentazione
|
|
180
116
|
|
|
181
|
-
| Versione | Data | Modifiche
|
|
182
|
-
| -------- | ---------- |
|
|
183
|
-
|
|
|
117
|
+
| Versione | Data | Modifiche |
|
|
118
|
+
| -------- | ---------- | ----------------------------------- |
|
|
119
|
+
| 6.1.5 | 2025-09-30 | Aggiunta gif demo |
|
|
120
|
+
| 6.1.0 | 2025-09-24 | Aggiunta sezione selezione ambiente |
|
|
121
|
+
| 6.0.0 | 2025-09-22 | Comandi Intlayer Tab / Fill & Test |
|
|
122
|
+
| 5.5.10 | 2025-06-29 | Inizializzazione cronologia |
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
---
|
|
2
|
+
createdAt: 2024-03-07
|
|
3
|
+
updatedAt: 2025-09-30
|
|
4
|
+
title: React と Next.js でコンポーネントを多言語対応(i18n)にする方法
|
|
5
|
+
description: Intlayer を使って多言語対応の React または Next.js コンポーネントを作成するために、ローカライズされたコンテンツの宣言と取得方法を学びます。
|
|
6
|
+
keywords:
|
|
7
|
+
- i18n
|
|
8
|
+
- コンポーネント
|
|
9
|
+
- react
|
|
10
|
+
- 多言語対応
|
|
11
|
+
- next.js
|
|
12
|
+
- intlayer
|
|
13
|
+
slugs:
|
|
14
|
+
- doc
|
|
15
|
+
- component
|
|
16
|
+
- i18n
|
|
17
|
+
applicationTemplate: https://github.com/aymericzip/intlayer-vite-react-template
|
|
18
|
+
youtubeVideo: https://www.youtube.com/watch?v=dS9L7uJeak4
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
# Intlayer でコンポーネントを多言語対応(i18n)にする方法
|
|
22
|
+
|
|
23
|
+
このガイドでは、2つの一般的なセットアップで UI コンポーネントを多言語対応にするための最小限の手順を示します:
|
|
24
|
+
|
|
25
|
+
- React (Vite/SPA)
|
|
26
|
+
- Next.js (App Router)
|
|
27
|
+
|
|
28
|
+
まずコンテンツを宣言し、その後コンポーネント内で取得します。
|
|
29
|
+
|
|
30
|
+
## 1) コンテンツを宣言する(React と Next.js 共通)
|
|
31
|
+
|
|
32
|
+
コンポーネントの近くにコンテンツ宣言ファイルを作成します。これにより、翻訳が使用される場所に近くなり、型安全性も確保されます。
|
|
33
|
+
|
|
34
|
+
```ts fileName="component.content.ts"
|
|
35
|
+
import { t, type Dictionary } from "intlayer";
|
|
36
|
+
|
|
37
|
+
const componentContent = {
|
|
38
|
+
key: "component-example",
|
|
39
|
+
content: {
|
|
40
|
+
title: t({
|
|
41
|
+
en: "Hello",
|
|
42
|
+
fr: "Bonjour",
|
|
43
|
+
es: "Hola",
|
|
44
|
+
}),
|
|
45
|
+
description: t({
|
|
46
|
+
en: "A multilingual React component",
|
|
47
|
+
fr: "Un composant React multilingue",
|
|
48
|
+
es: "Un componente React multilingüe",
|
|
49
|
+
}),
|
|
50
|
+
},
|
|
51
|
+
} satisfies Dictionary;
|
|
52
|
+
|
|
53
|
+
export default componentContent;
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
設定ファイルとして JSON を使いたい場合もサポートされています。
|
|
57
|
+
|
|
58
|
+
```json fileName="component.content.json"
|
|
59
|
+
{
|
|
60
|
+
"$schema": "https://intlayer.org/schema.json",
|
|
61
|
+
"key": "component-example",
|
|
62
|
+
"content": {
|
|
63
|
+
"title": {
|
|
64
|
+
"nodeType": "translation",
|
|
65
|
+
"translation": { "en": "Hello", "fr": "Bonjour", "es": "Hola" }
|
|
66
|
+
},
|
|
67
|
+
"description": {
|
|
68
|
+
"nodeType": "translation",
|
|
69
|
+
"translation": {
|
|
70
|
+
"en": "多言語対応のReactコンポーネント",
|
|
71
|
+
"fr": "Un composant React multilingue",
|
|
72
|
+
"es": "Un componente React multilingüe"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## 2) コンテンツの取得
|
|
80
|
+
|
|
81
|
+
### ケースA — Reactアプリ(Vite/SPA)
|
|
82
|
+
|
|
83
|
+
デフォルトの方法:キーで取得するために `useIntlayer` を使用します。これによりコンポーネントはシンプルかつ型安全に保たれます。
|
|
84
|
+
|
|
85
|
+
```tsx fileName="ComponentExample.tsx"
|
|
86
|
+
import { useIntlayer } from "react-intlayer";
|
|
87
|
+
|
|
88
|
+
export function ComponentExample() {
|
|
89
|
+
const content = useIntlayer("component-example");
|
|
90
|
+
return (
|
|
91
|
+
<div>
|
|
92
|
+
<h1>{content.title}</h1>
|
|
93
|
+
<p>{content.description}</p>
|
|
94
|
+
</div>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
サーバーサイドレンダリングやプロバイダー外での使用:`react-intlayer/server` を使用し、必要に応じて明示的に `locale` を渡します。
|
|
100
|
+
|
|
101
|
+
```tsx fileName="ServerRenderedExample.tsx"
|
|
102
|
+
import { useIntlayer } from "react-intlayer/server";
|
|
103
|
+
|
|
104
|
+
export function ServerRenderedExample({ locale }: { locale: string }) {
|
|
105
|
+
const content = useIntlayer("component-example", locale);
|
|
106
|
+
return (
|
|
107
|
+
<>
|
|
108
|
+
<h1>{content.title}</h1>
|
|
109
|
+
<p>{content.description}</p>
|
|
110
|
+
</>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
代替案:呼び出し元で構造をまとめておきたい場合は、`useDictionary` を使って宣言済みのオブジェクト全体を読み取ることができます。
|
|
116
|
+
|
|
117
|
+
```tsx fileName="ComponentWithDictionary.tsx"
|
|
118
|
+
import { useDictionary } from "react-intlayer";
|
|
119
|
+
import componentContent from "./component.content";
|
|
120
|
+
|
|
121
|
+
export function ComponentWithDictionary() {
|
|
122
|
+
const { title, description } = useDictionary(componentContent);
|
|
123
|
+
return (
|
|
124
|
+
<div>
|
|
125
|
+
<h1>{title}</h1>
|
|
126
|
+
<p>{description}</p>
|
|
127
|
+
</div>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### ケースB — Next.js(App Router)
|
|
133
|
+
|
|
134
|
+
データの安全性とパフォーマンスのためにサーバーコンポーネントを優先してください。サーバーファイルでは `next-intlayer/server` から `useIntlayer` を使用し、クライアントコンポーネントでは `next-intlayer` から `useIntlayer` を使用します。
|
|
135
|
+
|
|
136
|
+
```tsx fileName="app/[locale]/example/ServerComponent.tsx"
|
|
137
|
+
import { useIntlayer } from "next-intlayer/server";
|
|
138
|
+
|
|
139
|
+
export default function ServerComponent() {
|
|
140
|
+
const content = useIntlayer("component-example");
|
|
141
|
+
return (
|
|
142
|
+
<>
|
|
143
|
+
<h1>{content.title}</h1>
|
|
144
|
+
<p>{content.description}</p>
|
|
145
|
+
</>
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
```tsx fileName="app/[locale]/example/ClientComponent.tsx"
|
|
151
|
+
"use client";
|
|
152
|
+
|
|
153
|
+
import { useIntlayer } from "next-intlayer";
|
|
154
|
+
|
|
155
|
+
export function ClientComponent() {
|
|
156
|
+
const content = useIntlayer("component-example");
|
|
157
|
+
return (
|
|
158
|
+
<div>
|
|
159
|
+
<h1>{content.title}</h1>
|
|
160
|
+
<p>{content.description}</p>
|
|
161
|
+
</div>
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
ヒント: ページのメタデータやSEOのために、`getIntlayer` を使用してコンテンツを取得し、`getMultilingualUrls` を使って多言語URLを生成することもできます。
|
|
167
|
+
|
|
168
|
+
## なぜIntlayerのコンポーネントアプローチが最適なのか
|
|
169
|
+
|
|
170
|
+
- **コロケーション**: コンテンツの宣言がコンポーネントの近くに存在するため、ズレが減り、デザインシステム全体での再利用が向上します。
|
|
171
|
+
- **型安全性**: キーや構造が強く型付けされており、翻訳の欠落は実行時ではなくビルド時に検出されます。
|
|
172
|
+
- **サーバーファースト**: サーバーコンポーネントでネイティブに動作し、セキュリティとパフォーマンスを向上させます。クライアントフックは引き続き使いやすいままです。
|
|
173
|
+
- **ツリーシェイキング**: コンポーネントで使用されるコンテンツのみがバンドルされるため、大規模アプリでもペイロードを小さく保てます。
|
|
174
|
+
- **DX(開発者体験)&ツール**: 組み込みのミドルウェア、SEOヘルパー、オプションのビジュアルエディター/AI翻訳が日々の作業を効率化します。
|
|
175
|
+
|
|
176
|
+
Next.jsに特化した比較とパターンのまとめはこちらをご覧ください: https://intlayer.org/blog/next-i18next-vs-next-intl-vs-intlayer
|
|
177
|
+
|
|
178
|
+
## 関連ガイドと参考資料
|
|
179
|
+
|
|
180
|
+
- Reactセットアップ(Vite): https://intlayer.org/doc/environment/vite-and-react
|
|
181
|
+
- React Router v7: https://intlayer.org/doc/environment/vite-and-react/react-router-v7
|
|
182
|
+
- TanStackスタート: https://intlayer.org/doc/environment/vite-and-react/tanstack-start
|
|
183
|
+
- Next.js セットアップ: https://intlayer.org/doc/environment/nextjs
|
|
184
|
+
- なぜ Intlayer を選ぶのか vs. next-intl vs. next-i18next: https://intlayer.org/blog/next-i18next-vs-next-intl-vs-intlayer
|
|
185
|
+
|
|
186
|
+
これらのページには、エンドツーエンドのセットアップ、プロバイダー、ルーティング、および SEO ヘルパーが含まれています。
|
|
@@ -618,9 +618,9 @@ export const appConfig: ApplicationConfig = {
|
|
|
618
618
|
|
|
619
619
|
Intlayerはモジュール拡張を利用してTypeScriptの利点を活かし、コードベースをより強固にします。
|
|
620
620
|
|
|
621
|
-

|
|
622
622
|
|
|
623
|
-

|
|
624
624
|
|
|
625
625
|
TypeScriptの設定に自動生成された型が含まれていることを確認してください。
|
|
626
626
|
|