@intlayer/docs 5.8.0-canary.0 → 5.8.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/intlayer_with_next-i18next.md +2 -2
- package/blog/ar/next-i18next_vs_next-intl_vs_intlayer.md +96 -219
- package/blog/ar/react-i18next_vs_react-intl_vs_intlayer.md +88 -129
- package/blog/ar/vue-i18n_vs_intlayer.md +268 -0
- package/blog/de/intlayer_with_next-i18next.md +2 -2
- package/blog/de/next-i18next_vs_next-intl_vs_intlayer.md +93 -216
- package/blog/de/react-i18next_vs_react-intl_vs_intlayer.md +87 -128
- package/blog/de/vue-i18n_vs_intlayer.md +268 -0
- package/blog/en/intlayer_with_next-i18next.md +2 -2
- package/blog/en/next-i18next_vs_next-intl_vs_intlayer.md +89 -220
- package/blog/en/react-i18next_vs_react-intl_vs_intlayer.md +85 -123
- package/blog/en/vue-i18n_vs_intlayer.md +268 -0
- package/blog/en-GB/intlayer_with_next-i18next.md +2 -2
- package/blog/en-GB/next-i18next_vs_next-intl_vs_intlayer.md +85 -218
- package/blog/en-GB/react-i18next_vs_react-intl_vs_intlayer.md +80 -130
- package/blog/en-GB/vue-i18n_vs_intlayer.md +258 -0
- package/blog/es/intlayer_with_next-i18next.md +2 -2
- package/blog/es/next-i18next_vs_next-intl_vs_intlayer.md +93 -216
- package/blog/es/react-i18next_vs_react-intl_vs_intlayer.md +87 -128
- package/blog/es/vue-i18n_vs_intlayer.md +268 -0
- package/blog/fr/intlayer_with_next-i18next.md +2 -2
- package/blog/fr/next-i18next_vs_next-intl_vs_intlayer.md +91 -214
- package/blog/fr/react-i18next_vs_react-intl_vs_intlayer.md +86 -127
- package/blog/fr/vue-i18n_vs_intlayer.md +269 -0
- package/blog/hi/intlayer_with_next-i18next.md +2 -2
- package/blog/hi/next-i18next_vs_next-intl_vs_intlayer.md +97 -220
- package/blog/hi/react-i18next_vs_react-intl_vs_intlayer.md +89 -130
- package/blog/hi/vue-i18n_vs_intlayer.md +268 -0
- package/blog/it/intlayer_with_next-i18next.md +2 -2
- package/blog/it/next-i18next_vs_next-intl_vs_intlayer.md +91 -214
- package/blog/it/react-i18next_vs_react-intl_vs_intlayer.md +86 -127
- package/blog/it/vue-i18n_vs_intlayer.md +268 -0
- package/blog/ja/intlayer_with_next-i18next.md +2 -2
- package/blog/ja/next-i18next_vs_next-intl_vs_intlayer.md +93 -216
- package/blog/ja/react-i18next_vs_react-intl_vs_intlayer.md +87 -128
- package/blog/ja/vue-i18n_vs_intlayer.md +268 -0
- package/blog/ko/intlayer_with_next-i18next.md +2 -2
- package/blog/ko/next-i18next_vs_next-intl_vs_intlayer.md +95 -217
- package/blog/ko/react-i18next_vs_react-intl_vs_intlayer.md +89 -130
- package/blog/ko/vue-i18n_vs_intlayer.md +268 -0
- package/blog/pt/intlayer_with_next-i18next.md +2 -2
- package/blog/pt/next-i18next_vs_next-intl_vs_intlayer.md +93 -216
- package/blog/pt/react-i18next_vs_react-intl_vs_intlayer.md +87 -128
- package/blog/pt/vue-i18n_vs_intlayer.md +268 -0
- package/blog/ru/intlayer_with_next-i18next.md +2 -2
- package/blog/ru/next-i18next_vs_next-intl_vs_intlayer.md +94 -217
- package/blog/ru/react-i18next_vs_react-intl_vs_intlayer.md +87 -128
- package/blog/ru/vue-i18n_vs_intlayer.md +268 -0
- package/blog/zh/intlayer_with_next-i18next.md +2 -2
- package/blog/zh/next-i18next_vs_next-intl_vs_intlayer.md +93 -216
- package/blog/zh/react-i18next_vs_react-intl_vs_intlayer.md +87 -128
- package/blog/zh/vue-i18n_vs_intlayer.md +269 -0
- package/dist/cjs/generated/blog.entry.cjs +41 -0
- package/dist/cjs/generated/blog.entry.cjs.map +1 -1
- package/dist/esm/generated/blog.entry.mjs +41 -0
- package/dist/esm/generated/blog.entry.mjs.map +1 -1
- package/dist/types/generated/blog.entry.d.ts +1 -0
- package/dist/types/generated/blog.entry.d.ts.map +1 -1
- package/docs/ar/formatters.md +417 -31
- package/docs/ar/how_works_intlayer.md +2 -4
- package/docs/ar/interest_of_intlayer.md +7 -10
- package/docs/ar/intlayer_CMS.md +2 -3
- package/docs/ar/intlayer_visual_editor.md +2 -3
- package/docs/ar/intlayer_with_tanstack.md +1 -1
- package/docs/ar/introduction.md +4 -4
- package/docs/de/formatters.md +444 -34
- package/docs/de/introduction.md +2 -2
- package/docs/en/dictionary/enumeration.md +2 -2
- package/docs/en/dictionary/function_fetching.md +2 -2
- package/docs/en/dictionary/get_started.md +2 -2
- package/docs/en/dictionary/translation.md +2 -2
- package/docs/en/formatters.md +383 -15
- package/docs/en/how_works_intlayer.md +2 -4
- package/docs/en/interest_of_intlayer.md +40 -29
- package/docs/en/intlayer_CMS.md +2 -3
- package/docs/en/intlayer_visual_editor.md +2 -3
- package/docs/en/intlayer_with_create_react_app.md +2 -2
- package/docs/en/intlayer_with_express.md +2 -2
- package/docs/en/intlayer_with_tanstack.md +1 -1
- package/docs/en/introduction.md +4 -4
- package/docs/en/packages/express-intlayer/index.md +2 -2
- package/docs/en/packages/intlayer/getConfiguration.md +2 -3
- package/docs/en/packages/intlayer/getEnumeration.md +2 -7
- package/docs/en/packages/intlayer/getHTMLTextDir.md +2 -4
- package/docs/en/packages/intlayer/getLocaleLang.md +2 -4
- package/docs/en/packages/intlayer/getLocaleName.md +2 -3
- package/docs/en/packages/intlayer/getLocalizedUrl.md +2 -8
- package/docs/en/packages/intlayer/getMultilingualUrls.md +2 -7
- package/docs/en/packages/intlayer/getPathWithoutLocale.md +2 -3
- package/docs/en/packages/intlayer/getTranslation.md +2 -4
- package/docs/en/packages/intlayer/index.md +2 -2
- package/docs/en/packages/next-intlayer/index.md +2 -2
- package/docs/en/packages/next-intlayer/t.md +2 -2
- package/docs/en/packages/next-intlayer/useDictionary.md +2 -2
- package/docs/en/packages/next-intlayer/useIntlayer.md +2 -2
- package/docs/en/packages/next-intlayer/useLocale.md +2 -2
- package/docs/en/packages/react-intlayer/index.md +2 -2
- package/docs/en/packages/react-intlayer/t.md +2 -2
- package/docs/en/packages/react-intlayer/useI18n.md +2 -2
- package/docs/en/packages/react-intlayer/useIntlayer.md +2 -2
- package/docs/en/packages/react-intlayer/useLocale.md +2 -2
- package/docs/en/packages/react-scripts-intlayer/index.md +2 -2
- package/docs/en/packages/solid-intlayer/index.md +2 -2
- package/docs/en/packages/vite-intlayer/index.md +2 -2
- package/docs/en-GB/formatters.md +402 -16
- package/docs/en-GB/how_works_intlayer.md +2 -4
- package/docs/en-GB/interest_of_intlayer.md +7 -10
- package/docs/en-GB/intlayer_with_tanstack.md +1 -1
- package/docs/en-GB/introduction.md +2 -2
- package/docs/es/formatters.md +438 -28
- package/docs/es/how_works_intlayer.md +2 -4
- package/docs/es/interest_of_intlayer.md +7 -10
- package/docs/es/intlayer_with_tanstack.md +1 -1
- package/docs/es/introduction.md +2 -2
- package/docs/fr/formatters.md +438 -28
- package/docs/fr/how_works_intlayer.md +2 -4
- package/docs/fr/interest_of_intlayer.md +7 -10
- package/docs/fr/intlayer_with_tanstack.md +1 -1
- package/docs/fr/introduction.md +2 -2
- package/docs/hi/formatters.md +430 -39
- package/docs/hi/how_works_intlayer.md +2 -4
- package/docs/hi/interest_of_intlayer.md +7 -10
- package/docs/hi/intlayer_with_tanstack.md +1 -1
- package/docs/hi/introduction.md +2 -2
- package/docs/it/formatters.md +438 -30
- package/docs/it/how_works_intlayer.md +2 -4
- package/docs/it/interest_of_intlayer.md +7 -10
- package/docs/it/intlayer_with_tanstack.md +1 -1
- package/docs/it/introduction.md +2 -2
- package/docs/ja/formatters.md +435 -47
- package/docs/ja/how_works_intlayer.md +2 -4
- package/docs/ja/interest_of_intlayer.md +7 -10
- package/docs/ja/intlayer_with_tanstack.md +1 -1
- package/docs/ja/introduction.md +2 -2
- package/docs/ko/formatters.md +432 -41
- package/docs/ko/how_works_intlayer.md +2 -4
- package/docs/ko/interest_of_intlayer.md +7 -10
- package/docs/ko/intlayer_with_tanstack.md +1 -1
- package/docs/ko/introduction.md +2 -2
- package/docs/pt/formatters.md +416 -30
- package/docs/pt/how_works_intlayer.md +2 -4
- package/docs/pt/intlayer_with_tanstack.md +1 -1
- package/docs/pt/introduction.md +2 -2
- package/docs/ru/autoFill.md +2 -2
- package/docs/ru/configuration.md +1 -40
- package/docs/ru/formatters.md +438 -28
- package/docs/ru/how_works_intlayer.md +5 -7
- package/docs/ru/index.md +1 -1
- package/docs/ru/interest_of_intlayer.md +8 -11
- package/docs/ru/intlayer_CMS.md +7 -8
- package/docs/ru/intlayer_cli.md +4 -7
- package/docs/ru/intlayer_visual_editor.md +5 -6
- package/docs/ru/intlayer_with_angular.md +1 -1
- package/docs/ru/intlayer_with_create_react_app.md +5 -5
- package/docs/ru/intlayer_with_lynx+react.md +1 -1
- package/docs/ru/intlayer_with_nextjs_15.md +3 -3
- package/docs/ru/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/ru/intlayer_with_nuxt.md +1 -1
- package/docs/ru/intlayer_with_react_native+expo.md +2 -2
- package/docs/ru/intlayer_with_tanstack.md +3 -3
- package/docs/ru/intlayer_with_vite+preact.md +3 -3
- package/docs/ru/intlayer_with_vite+react.md +3 -3
- package/docs/ru/intlayer_with_vite+solid.md +1 -1
- package/docs/ru/intlayer_with_vite+svelte.md +1 -1
- package/docs/ru/intlayer_with_vite+vue.md +2 -2
- package/docs/ru/introduction.md +5 -5
- package/docs/ru/locale_mapper.md +1 -1
- package/docs/ru/packages/@intlayer/api/index.md +2 -2
- package/docs/ru/packages/@intlayer/chokidar/index.md +1 -1
- package/docs/ru/packages/@intlayer/cli/index.md +2 -2
- package/docs/ru/packages/@intlayer/config/index.md +2 -2
- package/docs/ru/packages/@intlayer/core/index.md +2 -2
- package/docs/ru/packages/@intlayer/design-system/index.md +2 -2
- package/docs/ru/packages/@intlayer/dictionary-entry/index.md +2 -2
- package/docs/ru/packages/@intlayer/editor/index.md +1 -1
- package/docs/ru/packages/@intlayer/editor-react/index.md +1 -1
- package/docs/ru/packages/@intlayer/webpack/index.md +1 -1
- package/docs/ru/packages/angular-intlayer/index.md +1 -1
- package/docs/ru/packages/express-intlayer/index.md +3 -3
- package/docs/ru/packages/express-intlayer/t.md +1 -1
- package/docs/ru/packages/intlayer/getEnumeration.md +3 -8
- package/docs/ru/packages/intlayer/getTranslation.md +3 -5
- package/docs/ru/packages/intlayer/getTranslationContent.md +1 -3
- package/docs/ru/packages/intlayer/index.md +3 -3
- package/docs/ru/packages/intlayer-cli/index.md +1 -1
- package/docs/ru/packages/intlayer-editor/index.md +2 -2
- package/docs/ru/packages/lynx-intlayer/index.md +1 -1
- package/docs/ru/packages/next-intlayer/index.md +4 -4
- package/docs/ru/packages/next-intlayer/t.md +4 -4
- package/docs/ru/packages/next-intlayer/useLocale.md +3 -3
- package/docs/ru/packages/nuxt-intlayer/index.md +1 -1
- package/docs/ru/packages/preact-intlayer/index.md +1 -1
- package/docs/ru/packages/react-intlayer/index.md +4 -4
- package/docs/ru/packages/react-intlayer/t.md +4 -4
- package/docs/ru/packages/react-native-intlayer/index.md +1 -1
- package/docs/ru/packages/react-scripts-intlayer/index.md +3 -3
- package/docs/ru/packages/solid-intlayer/index.md +3 -3
- package/docs/ru/packages/svelte-intlayer/index.md +1 -1
- package/docs/ru/packages/vite-intlayer/index.md +3 -3
- package/docs/ru/packages/vue-intlayer/index.md +1 -1
- package/docs/ru/per_locale_file.md +1 -1
- package/docs/ru/roadmap.md +3 -5
- package/docs/ru/vs_code_extension.md +1 -1
- package/docs/zh/formatters.md +446 -38
- package/docs/zh/how_works_intlayer.md +2 -4
- package/docs/zh/interest_of_intlayer.md +7 -10
- package/docs/zh/intlayer_with_tanstack.md +1 -1
- package/docs/zh/introduction.md +2 -2
- package/frequent_questions/ar/domain_routing.md +1 -1
- package/frequent_questions/en/domain_routing.md +1 -1
- package/frequent_questions/en-GB/domain_routing.md +1 -1
- package/frequent_questions/es/domain_routing.md +1 -1
- package/frequent_questions/fr/domain_routing.md +1 -1
- package/frequent_questions/hi/domain_routing.md +1 -1
- package/frequent_questions/it/domain_routing.md +1 -1
- package/frequent_questions/ko/domain_routing.md +1 -1
- package/frequent_questions/pt/domain_routing.md +1 -1
- package/frequent_questions/ru/domain_routing.md +1 -1
- package/frequent_questions/ru/get_locale_cookie.md +4 -4
- package/frequent_questions/ru/static_rendering.md +1 -2
- package/frequent_questions/zh/domain_routing.md +1 -1
- package/package.json +7 -7
- package/src/generated/blog.entry.ts +41 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
createdAt: 2025-01-02
|
|
3
3
|
updatedAt: 2025-06-29
|
|
4
|
-
title: react-
|
|
4
|
+
title: react-i18next vs react-intl vs Intlayer
|
|
5
5
|
description: Integrate react-i18next with next-intl and Intlayer for the internationalization (i18n) of a React app
|
|
6
6
|
keywords:
|
|
7
7
|
- next-intl
|
|
@@ -17,178 +17,140 @@ slugs:
|
|
|
17
17
|
- react-i18next-vs-react-intl-vs-intlayer
|
|
18
18
|
---
|
|
19
19
|
|
|
20
|
-
#
|
|
20
|
+
# react-Intl VS react-i18next VS intlayer | React Internationalization (i18n)
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
This guide compares three established i18n options for **React**: **react-intl** (FormatJS), **react-i18next** (i18next), and **Intlayer**.
|
|
23
|
+
We focus on **plain React** applications (e.g., Vite, CRA, SPA). If you’re using Next.js, see our dedicated Next.js comparison.
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
## 1. Introduction
|
|
27
|
-
|
|
28
|
-
Internationalization (i18n) in React applications can be achieved in multiple ways. The three libraries presented here have different design philosophies, sets of features, and community support:
|
|
25
|
+
We evaluate:
|
|
29
26
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
- Architecture & content organization
|
|
28
|
+
- TypeScript & safety
|
|
29
|
+
- Missing translation handling
|
|
30
|
+
- Rich content & formatting capabilities
|
|
31
|
+
- Performance & loading behavior
|
|
32
|
+
- Developer experience (DX), tooling & maintenance
|
|
33
|
+
- SEO/routing (framework-dependent)
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
> **tl;dr**: All three can localize a React app. If you want **component-scoped content**, **strict TypeScript types**, **build-time missing-key checks**, **tree-shaken dictionaries**, and built-in editorial tooling (Visual Editor/CMS + optional AI translation), **Intlayer** is the most complete choice for modular React codebases.
|
|
35
36
|
|
|
36
37
|
---
|
|
37
38
|
|
|
38
|
-
##
|
|
39
|
+
## High-level positioning
|
|
39
40
|
|
|
40
|
-
|
|
41
|
+
- **react-intl** - ICU-first, standards-aligned formatting (dates/numbers/plurals) with a mature API. Catalogs are typically centralized; key safety and build-time validation are largely on you.
|
|
42
|
+
- **react-i18next** - Extremely popular and flexible; namespaces, detectors, and many plugins (ICU, backends). Powerful, but configuration can sprawl as projects scale.
|
|
43
|
+
- **Intlayer** - Component-centric content model for React, **strict TS typing**, **build-time checks**, **tree-shaking**, plus **Visual Editor/CMS** and **AI-assisted translations**. Works with React Router, Vite, CRA, etc.
|
|
41
44
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
### Key Features
|
|
45
|
-
|
|
46
|
-
- **ICU Message Syntax**: Offers a comprehensive syntax for message interpolation, pluralization, and more.
|
|
47
|
-
- **Localized Formatting**: Built-in utilities to format dates, times, numbers, and relative times based on locale.
|
|
48
|
-
- **Declarative Components**: Exposes `<FormattedMessage>`, `<FormattedNumber>`, `<FormattedDate>`, etc., for seamless usage in JSX.
|
|
49
|
-
- **Rich Ecosystem**: Integrates well with the FormatJS tooling (e.g., [babel-plugin-react-intl](https://formatjs.io/docs/tooling/babel-plugin/)) for extracting, managing, and compiling messages.
|
|
45
|
+
---
|
|
50
46
|
|
|
51
|
-
|
|
47
|
+
## Feature matrix (React focus)
|
|
48
|
+
|
|
49
|
+
| Feature | `react-intlayer` (Intlayer) | `react-i18next` (i18next) | `react-intl` (FormatJS) |
|
|
50
|
+
| --------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
|
|
51
|
+
| **Translations Near Components** | ✅ Yes, content collocated with each component | ❌ No | ❌ No |
|
|
52
|
+
| **TypeScript Integration** | ✅ Advanced, auto-generated strict types | ⚠️ Basic; extra config for safety | ✅ Good, but less strict |
|
|
53
|
+
| **Missing Translation Detection** | ✅ TypeScript error hightlight and build-time error/warning | ⚠️ Mostly fallback strings at runtime | ⚠️ Fallback strings |
|
|
54
|
+
| **Rich Content (JSX/Markdown/components)** | ✅ Direct support | ⚠️ Limited / interpolation only | ⚠️ ICU syntax, not real JSX |
|
|
55
|
+
| **AI-powered Translation** | ✅ Yes, supports multiple AI providers. Usable using your own API keys. Considers the context of your application and content scope | ❌ No | ❌ No |
|
|
56
|
+
| **Visual Editor** | ✅ Yes, local Visual Editor + optional CMS; can externalize codebase content; embeddable | ❌ No / available via external localization platforms | ❌ No / available via external localization platforms |
|
|
57
|
+
| **Localized Routing** | ✅ Yes, supports localized paths out of the box (works with Next.js & Vite) | ⚠️ No built-in, requires plugins (e.g. `next-i18next`) or custom router config | ❌ No, only message formatting, routing must be manual |
|
|
58
|
+
| **Dynamic Route Generation** | ✅ Yes | ⚠️ Plugin/ecosystem or manual setup | ❌ Not provided |
|
|
59
|
+
| **Pluralization** | ✅ Enumeration-based patterns | ✅ Configurable (plugins like i18next-icu) | ✅ (ICU) |
|
|
60
|
+
| **Formatting (dates, numbers, currencies)** | ✅ Optimized formatters (Intl under the hood) | ⚠️ Via plugins or custom Intl usage | ✅ ICU formatters |
|
|
61
|
+
| **Content Format** | ✅ .tsx, .ts, .js, .json, .md, .txt, (.yaml WIP) | ⚠️ .json | ✅ .json, .js |
|
|
62
|
+
| **ICU support** | ⚠️ WIP | ⚠️ Via plugin (i18next-icu) | ✅ Yes |
|
|
63
|
+
| **SEO Helpers (hreflang, sitemap)** | ✅ Built-in tools: helpers for sitemap, robots.txt, metadata | ⚠️ Community plugins/manual | ❌ Not core |
|
|
64
|
+
| **Ecosystem / Community** | ⚠️ Smaller but growing fast and reactive | ✅ Largest and mature | ✅ Large |
|
|
65
|
+
| **Server-side Rendering & Server Components** | ✅ Yes, streamlined for SSR / React Server Components | ⚠️ Supported at page level but need to pass t-functions on component tree for children server components | ❌ Not supported, need to pass t-functions on component tree for children server components |
|
|
66
|
+
| **Tree-shaking (load only used content)** | ✅ Yes, per-component at build time via Babel/SWC plugins | ⚠️ Usually loads all (can be improved with namespaces/code-splitting) | ⚠️ Usually loads all |
|
|
67
|
+
| **Lazy loading** | ✅ Yes, per-locale / per-dictionary | ✅ Yes (e.g., backends/namespaces on demand) | ✅ Yes (split locale bundles) |
|
|
68
|
+
| **Purge unused content** | ✅ Yes, per-dictionary at build time | ❌ No, only via manual namespace segmentation | ❌ No, all declared messages are bundled |
|
|
69
|
+
| **Management of Large Projects** | ✅ Encourages modular, suited for design-system | ⚠️ Needs good file discipline | ⚠️ Central catalogs can get large |
|
|
52
70
|
|
|
53
|
-
|
|
54
|
-
2. **Wrap your app** in `<IntlProvider locale="en" messages={messages}>`.
|
|
55
|
-
3. **Use** `<FormattedMessage id="myMessage" defaultMessage="Hello world" />` or the `useIntl()` hook to access translation strings.
|
|
71
|
+
---
|
|
56
72
|
|
|
57
|
-
|
|
73
|
+
## Deep-dive comparison
|
|
58
74
|
|
|
59
|
-
|
|
60
|
-
- Advanced message formatting, including pluralization, gender, time zones, and more.
|
|
61
|
-
- Strong tooling support for message extraction and compilation.
|
|
75
|
+
### 1) Architecture & scalability
|
|
62
76
|
|
|
63
|
-
|
|
77
|
+
- **react-intl / react-i18next**: Most setups maintain **centralized locale folders** per language, sometimes split by **namespaces** (i18next). Works well early on but becomes a shared surface area as apps grow.
|
|
78
|
+
- **Intlayer**: Promotes **per-component (or per-feature) dictionaries** **co-located** with the UI they serve. This keeps ownership clear, eases duplication/migration of components, and reduces cross-team key churn. Unused content is easier to identify and remove.
|
|
64
79
|
|
|
65
|
-
|
|
66
|
-
- Not as straightforward to handle dynamic or complex translations that are more than just string-based.
|
|
80
|
+
**Why it matters:** Modular content mirrors modular UI. Large React codebases stay cleaner when translations live with the components they belong to.
|
|
67
81
|
|
|
68
82
|
---
|
|
69
83
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
### Overview
|
|
73
|
-
|
|
74
|
-
[**React-i18next**](https://react.i18next.com/) is a React extension of [i18next](https://www.i18next.com/), one of the most popular JavaScript i18n frameworks. It offers **extensive features** for runtime translations, lazy loading, and detection of language, making it extremely flexible for a wide variety of use cases.
|
|
75
|
-
|
|
76
|
-
### Key Features
|
|
77
|
-
|
|
78
|
-
- **Flexible Translation Structure**: Not tied to a single format like ICU. You can store translations in JSON, use interpolation, pluralization, etc.
|
|
79
|
-
- **Dynamic Language Switching**: Built-in language detector plugins and runtime updates.
|
|
80
|
-
- **Nested & Structured Translations**: You can nest translations easily within JSON.
|
|
81
|
-
- **Extensive Plugin Ecosystem**: For detection (browser, path, subdomain, etc.), resource loading, caching, and more.
|
|
84
|
+
### 2) TypeScript & safety
|
|
82
85
|
|
|
83
|
-
|
|
86
|
+
- **react-intl**: Solid typings, but **no automatic key typing**; you enforce safety patterns yourself.
|
|
87
|
+
- **react-i18next**: Strong typings for hooks; **strict key typing** typically requires extra configuration or generators.
|
|
88
|
+
- **Intlayer**: **Auto-generates strict types** from your content. IDE autocomplete and **compile-time errors** catch typos and missing keys before runtime.
|
|
84
89
|
|
|
85
|
-
|
|
86
|
-
2. **Configure i18n** to load translations (JSON) and set up language detection or fallback.
|
|
87
|
-
3. **Wrap your app** in `I18nextProvider`.
|
|
88
|
-
4. **Use the `useTranslation()` hook** or `<Trans>` component to display translations.
|
|
90
|
+
**Why it matters:** Shifting failures **left** (to build/CI) reduces production issues and speeds developer feedback loops.
|
|
89
91
|
|
|
90
|
-
|
|
92
|
+
---
|
|
91
93
|
|
|
92
|
-
|
|
93
|
-
- Very active community and large ecosystem of plugins.
|
|
94
|
-
- Ease of **dynamic loading** of translations (e.g., from a server, on demand).
|
|
94
|
+
### 3) Missing translation handling
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
- **react-intl / react-i18next**: Default to **runtime fallbacks** (key echo or default locale). You can add linting/plugins, but it’s not guaranteed at build.
|
|
97
|
+
- **Intlayer**: **Build-time detection** with warnings or errors when required locales/keys are missing.
|
|
97
98
|
|
|
98
|
-
|
|
99
|
-
- If you prefer strongly typed translations, you may need additional TypeScript setups.
|
|
99
|
+
**Why it matters:** CI failing on missing strings prevents “mystery English” leaking into non-English UIs.
|
|
100
100
|
|
|
101
101
|
---
|
|
102
102
|
|
|
103
|
-
|
|
103
|
+
### 4) Rich content & formatting
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
- **react-intl**: Excellent **ICU** support for plurals, selects, dates/numbers, and message composition. JSX can be used, but the mental model stays message-centric.
|
|
106
|
+
- **react-i18next**: Flexible interpolation and **`<Trans>`** for embedding elements/components; ICU available via plugin.
|
|
107
|
+
- **Intlayer**: Content files can include **rich nodes** (JSX/Markdown/components) and **metadata**. Formatting uses Intl under the hood; plural patterns are ergonomic.
|
|
106
108
|
|
|
107
|
-
|
|
109
|
+
**Why it matters:** Complex UI texts (links, bold pieces, inline components) are easier when the library embraces React nodes cleanly.
|
|
108
110
|
|
|
109
|
-
|
|
111
|
+
---
|
|
110
112
|
|
|
111
|
-
|
|
112
|
-
- **Built-in Routing & Middleware**: Optional modules for localized routing (e.g., `/en/about`, `/fr/about`) and server middleware for detecting user locale.
|
|
113
|
-
- **Auto-generated TypeScript Types**: Ensures type safety with features like autocompletion and compile-time error detection.
|
|
114
|
-
- **Dynamic & Rich Translations**: Can include JSX/TSX in translations for more complex use cases (e.g., links, bold text, icons in translations).
|
|
113
|
+
### 5) Performance & loading behavior
|
|
115
114
|
|
|
116
|
-
|
|
115
|
+
- **react-intl / react-i18next**: You typically manage **catalog splitting** and **lazy loading** manually (namespaces/dynamic imports). Effective but requires discipline.
|
|
116
|
+
- **Intlayer**: **Tree-shakes** unused dictionaries and supports **per-dictionary/per-locale lazy loading** out-of-the-box.
|
|
117
117
|
|
|
118
|
-
|
|
119
|
-
2. **Create `intlayer.config.ts`** to define available locales and default locale.
|
|
120
|
-
3. **Use the Intlayer CLI** or plugin to **transpile** content declarations.
|
|
121
|
-
4. **Wrap your app** in `<IntlayerProvider>` and retrieve content with `useIntlayer("keyName")`.
|
|
118
|
+
**Why it matters:** Smaller bundles and fewer unused strings improve startup and navigation performance.
|
|
122
119
|
|
|
123
|
-
|
|
120
|
+
---
|
|
124
121
|
|
|
125
|
-
|
|
126
|
-
- **Rich content** possible (e.g., passing React nodes as translations).
|
|
127
|
-
- **Localized Routing** out-of-the-box.
|
|
128
|
-
- Integrated with popular build tools (CRA, Vite) for easy setup.
|
|
122
|
+
### 6) DX, tooling & maintenance
|
|
129
123
|
|
|
130
|
-
|
|
124
|
+
- **react-intl / react-i18next**: Broad community ecosystem; for editorial workflows you usually adopt external localization platforms.
|
|
125
|
+
- **Intlayer**: Ships a **free Visual Editor** and **optional CMS** (keep content in Git or externalize it). Also offers a **VSCode extension** for content authoring and **AI-assisted translation** using your own provider keys.
|
|
131
126
|
|
|
132
|
-
-
|
|
133
|
-
- Heavier focus on a “component-level content declaration” approach may be a shift from typical .json catalogs.
|
|
134
|
-
- Smaller ecosystem and community compared to the more established libraries.
|
|
127
|
+
**Why it matters:** Built-in tooling shortens the loop between developers and content authors - less glue code, fewer vendor dependencies.
|
|
135
128
|
|
|
136
129
|
---
|
|
137
130
|
|
|
138
|
-
##
|
|
131
|
+
## When to choose which?
|
|
139
132
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
| **Approach** | Utilize `<IntlProvider>` & FormatJS message components | Utilize `I18nextProvider` & `useTranslation()` hook | Utilize `<IntlayerProvider>` & `useIntlayer()` hook with content declarations |
|
|
144
|
-
| **Localization Format** | ICU-based strings (JSON or JavaScript catalogs) | JSON resource files (or custom loaders). ICU format optional via i18next plugin | `.content.[ts/js/tsx]` or JSON declarations; can contain strings or React components |
|
|
145
|
-
| **Routing** | Handled externally (no built-in localized routing) | Handled externally with i18next plugins (path, subdomain detection, etc.) | Built-in localized routing support (e.g., `/en/about`, `/fr/about`), plus optional server middleware (for SSR/Vite) |
|
|
146
|
-
| **TypeScript Support** | Good (typings for official packages) | Good but extra config for typed translations if you want strict checking | Excellent (auto-generated type definitions for content keys and translations) |
|
|
147
|
-
| **Pluralization & Formatting** | Advanced: Built-in date/time/number formatting, plural/gender support | Configurable pluralization. Date/time formatting typically done via external libs or i18next plugin | Can rely on standard JavaScript Intl or embed logic in content. Not as specialized as FormatJS, but handles typical cases. |
|
|
148
|
-
| **Community & Ecosystem** | Large, part of FormatJS ecosystem | Very large, highly active, lots of plugins (detection, caching, frameworks) | Smaller but growing; open-source, modern approach |
|
|
149
|
-
| **Learning Curve** | Moderate (learning ICU message syntax, FormatJS conventions) | Low to moderate (straightforward usage, but advanced config can get verbose) | Moderate (concept of content declarations and specialized build steps) |
|
|
133
|
+
- **Choose react-intl** if you want **ICU-first** message formatting with a straightforward, standards-aligned API and your team is comfortable maintaining catalogs and safety checks manually.
|
|
134
|
+
- **Choose react-i18next** if you need the **breadth of i18next’s ecosystem** (detectors, backends, ICU plugin, integrations) and accept more configuration to gain flexibility.
|
|
135
|
+
- **Choose Intlayer** if you value **component-scoped content**, **strict TypeScript**, **build-time guarantees**, **tree-shaking**, and **batteries-included** editorial tooling - especially for **large, modular** React apps, design-systems, etc.
|
|
150
136
|
|
|
151
137
|
---
|
|
152
138
|
|
|
153
|
-
##
|
|
154
|
-
|
|
155
|
-
1. **React-Intl**
|
|
156
|
-
|
|
157
|
-
- You need **powerful formatting** for dates/times/numbers and strong **ICU message syntax**.
|
|
158
|
-
- You prefer a more “**standards-based**” approach to translations.
|
|
159
|
-
- You don’t require localized routing or strongly typed translation keys.
|
|
139
|
+
## Interoperability with `react-intl` and `react-i18next`
|
|
160
140
|
|
|
161
|
-
|
|
141
|
+
`intlayer` can also help to manage your `react-intl` and `react-i18next` namespaces.
|
|
162
142
|
|
|
163
|
-
|
|
164
|
-
- You want **plugin-based** language detection (e.g., from URL, cookies, local storage) or advanced caching.
|
|
165
|
-
- You need the largest ecosystem, with many existing integrations for various frameworks (Next.js, React Native, etc.).
|
|
143
|
+
Using `intlayer`, you can declare your content in the format of your favorite i18n library, and intlayer will generate your namespaces in the location of your choice (example: `/messages/{{locale}}/{{namespace}}.json`).
|
|
166
144
|
|
|
167
|
-
|
|
168
|
-
- You want **strong TypeScript** integration with _autogenerated types_, ensuring you rarely miss a translation key.
|
|
169
|
-
- You prefer **declarative content** close to the component, possibly including React nodes or advanced logic in translations.
|
|
170
|
-
- You require **built-in localized routing** or want to easily incorporate it into your SSR or Vite setup.
|
|
171
|
-
- You desire a modern approach or simply want a single library that covers both **content management** (i18n) and **routing** in a type-safe way.
|
|
145
|
+
Refer to [`dictionaryOutput` and `i18nextResourcesDir` options](https://intlayer.org/doc/concept/configuration#content-configuration) for more details.
|
|
172
146
|
|
|
173
147
|
---
|
|
174
148
|
|
|
175
|
-
##
|
|
176
|
-
|
|
177
|
-
Each library offers a robust solution for internationalizing a React application:
|
|
178
|
-
|
|
179
|
-
- **React-Intl** excels at message formatting and is a popular choice for enterprise solutions focusing on ICU message syntax.
|
|
180
|
-
- **React-i18next** provides a highly flexible, plugin-driven environment for advanced or dynamic i18n needs.
|
|
181
|
-
- **Intlayer** offers a **modern, strongly typed** approach that merges content declarations, advanced localized routing, and plugin-based (CRA, Vite) integrations.
|
|
182
|
-
|
|
183
|
-
Your choice largely depends on project requirements, desired developer experience (DX), and how important typed translations or advanced routing are. If you value built-in localized routing and TypeScript integration, **Intlayer** may be most appealing. If you want a battle-tested, ecosystem-rich solution, **React-i18next** is a great choice. For straightforward ICU-based formatting needs, **React-Intl** is a reliable option.
|
|
184
|
-
|
|
185
|
-
---
|
|
149
|
+
## Conclusion
|
|
186
150
|
|
|
187
|
-
|
|
151
|
+
All three libraries localize React effectively. The differentiator is how much **infrastructure** you must build to reach a **safe, scalable** setup:
|
|
188
152
|
|
|
189
|
-
-
|
|
190
|
-
-
|
|
191
|
-
- [Intlayer + CRA Getting Started Guide](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_with_create_react_app.md)
|
|
192
|
-
- [Intlayer + Vite & React Getting Started Guide](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_with_vite%2Breact.md)
|
|
153
|
+
- With **Intlayer**, **modular content**, **strict TS typing**, **build-time safety**, **tree-shaken bundles**, and **editorial tooling** are defaults - not chores.
|
|
154
|
+
- If your team prizes **maintainability and speed** in multi-locale, component-driven React apps, Intlayer offers the **most complete** developer and content workflow today.
|
|
193
155
|
|
|
194
|
-
|
|
156
|
+
Refer to ['Why Intlayer?' doc](https://intlayer.org/doc/why) for more details.
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
---
|
|
2
|
+
createdAt: 2024-08-11
|
|
3
|
+
updatedAt: 2025-08-23
|
|
4
|
+
title: vue-i18n vs Intlayer
|
|
5
|
+
description: Compare vue-i18n with Intlayer for internationalization (i18n) in Vue/Nuxt apps
|
|
6
|
+
keywords:
|
|
7
|
+
- vue-i18n
|
|
8
|
+
- Intlayer
|
|
9
|
+
- Internationalization
|
|
10
|
+
- i18n
|
|
11
|
+
- Blog
|
|
12
|
+
- Vue
|
|
13
|
+
- Nuxt
|
|
14
|
+
- JavaScript
|
|
15
|
+
slugs:
|
|
16
|
+
- blog
|
|
17
|
+
- vue-i18n-vs-intlayer
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
# vue-i18n VS Intlayer | Vue Internationalization (i18n)
|
|
21
|
+
|
|
22
|
+
This guide compares two popular i18n options for **Vue 3** (and **Nuxt**): **vue-i18n** and **Intlayer**.
|
|
23
|
+
We focus on modern Vue tooling (Vite, Composition API) and evaluate:
|
|
24
|
+
|
|
25
|
+
1. **Architecture & content organization**
|
|
26
|
+
2. **TypeScript & safety**
|
|
27
|
+
3. **Missing translation handling**
|
|
28
|
+
4. **Routing & URL strategy**
|
|
29
|
+
5. **Performance & loading behavior**
|
|
30
|
+
6. **Developer experience (DX), tooling & maintenance**
|
|
31
|
+
7. **SEO & large-project scalability**
|
|
32
|
+
|
|
33
|
+
> **tl;dr**: Both can localize Vue apps. If you want **component-scoped content**, **strict TypeScript types**, **build-time missing-key checks**, **tree-shaken dictionaries**, and **batteries-included router/SEO helpers** plus **Visual Editor & AI translations**, **Intlayer** is the more complete, modern choice.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## High-level positioning
|
|
38
|
+
|
|
39
|
+
- **vue-i18n** - The de-facto i18n library for Vue. Flexible message formatting (ICU-style), SFC `<i18n>` blocks for local messages, and a big ecosystem. Safety and large-scale maintenance are mostly on you.
|
|
40
|
+
- **Intlayer** - Component-centric content model for Vue/Vite/Nuxt with **strict TS typing**, **build-time checks**, **tree-shaking**, **router & SEO helpers**, optional **Visual Editor/CMS**, and **AI-assisted translations**.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Side-by-Side Feature Comparison (Vue-focused)
|
|
45
|
+
|
|
46
|
+
| Feature | **Intlayer** | **vue-i18n** |
|
|
47
|
+
| ------------------------------------------- | -------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
|
|
48
|
+
| **Translations near components** | ✅ Yes, content collocated per component (e.g., `MyComp.content.ts`) | ✅ Yes, via SFC `<i18n>` blocks (optional) |
|
|
49
|
+
| **TypeScript integration** | ✅ Advanced, auto-generated **strict** types & key autocompletion | ✅ Good typings; **strict key safety requires additional setup/disciplines** |
|
|
50
|
+
| **Missing translation detection** | ✅ **Build-time** warnings/errors and TS surfacing | ⚠️ Runtime fallbacks/warnings |
|
|
51
|
+
| **Rich content (components/Markdown)** | ✅ Direct support for rich nodes and Markdown content files | ⚠️ Limited (components via `<i18n-t>`, Markdown via external plugins) |
|
|
52
|
+
| **AI-powered translation** | ✅ Built-in workflows using your own AI provider keys | ❌ Not built-in |
|
|
53
|
+
| **Visual Editor / CMS** | ✅ Free Visual Editor & optional CMS | ❌ Not built-in (use external platforms) |
|
|
54
|
+
| **Localized routing** | ✅ Helpers for Vue Router/Nuxt to generate localized paths, URLs, and `hreflang` | ⚠️ Not core (use Nuxt i18n or custom Vue Router setup) |
|
|
55
|
+
| **Dynamic route generation** | ✅ Yes | ❌ Not provided (Nuxt i18n provides) |
|
|
56
|
+
| **Pluralization & formatting** | ✅ Enumeration patterns; Intl-based formatters | ✅ ICU-style messages; Intl formatters |
|
|
57
|
+
| **Content formats** | ✅ `.ts`, `.js`, `.json`, `.md`, `.txt` (YAML WIP) | ✅ `.json`, `.js` (plus SFC `<i18n>` blocks) |
|
|
58
|
+
| **ICU support** | ⚠️ WIP | ✅ Yes |
|
|
59
|
+
| **SEO helpers (sitemap, robots, metadata)** | ✅ Built-in helpers (framework-agnostic) | ❌ Not core (Nuxt i18n/community) |
|
|
60
|
+
| **SSR/SSG** | ✅ Works with Vue SSR and Nuxt; does not block static rendering | ✅ Works with Vue SSR/Nuxt |
|
|
61
|
+
| **Tree-shaking (ship only used content)** | ✅ Per-component at build time | ⚠️ Partial; requires manual code-splitting/async messages |
|
|
62
|
+
| **Lazy loading** | ✅ Per-locale / per-dictionary | ✅ Async locale messages supported |
|
|
63
|
+
| **Purge unused content** | ✅ Yes (build-time) | ❌ Not built-in |
|
|
64
|
+
| **Large-project maintainability** | ✅ Encourages modular, design-system-friendly structure | ✅ Possible, but needs strong file/namespace discipline |
|
|
65
|
+
| **Ecosystem / community** | ⚠️ Smaller but growing fast | ✅ Large and mature in the Vue ecosystem |
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Deep-dive comparison
|
|
70
|
+
|
|
71
|
+
### 1) Architecture & scalability
|
|
72
|
+
|
|
73
|
+
- **vue-i18n**: Common setups use **centralized catalogs** per locale (optionally split into files/namespaces). SFC `<i18n>` blocks allow local messages but teams often revert to shared catalogs as projects grow.
|
|
74
|
+
- **Intlayer**: Promotes **per-component dictionaries** stored next to the component they serve. This reduces cross-team conflicts, keeps content discoverable, and naturally limits drift/unused keys.
|
|
75
|
+
|
|
76
|
+
**Why it matters:** In large Vue apps or design systems, **modular content** scales better than monolithic catalogs.
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
### 2) TypeScript & safety
|
|
81
|
+
|
|
82
|
+
- **vue-i18n**: Good TS support; **strict key typing** typically needs custom schemas/generics and careful conventions.
|
|
83
|
+
- **Intlayer**: **Generates strict types** from your content, giving **IDE autocompletion** and **compile-time errors** for typos/missing keys.
|
|
84
|
+
|
|
85
|
+
**Why it matters:** Strong typing catches issues **before** runtime.
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
### 3) Missing translation handling
|
|
90
|
+
|
|
91
|
+
- **vue-i18n**: **Runtime** warnings/fallbacks (e.g., fall back locale or key).
|
|
92
|
+
- **Intlayer**: **Build-time** detection with warnings/errors across locales and keys.
|
|
93
|
+
|
|
94
|
+
**Why it matters:** Build-time enforcement keeps production UI clean and consistent.
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
### 4) Routing & URL strategy (Vue Router/Nuxt)
|
|
99
|
+
|
|
100
|
+
- **Both** can work with localized routes.
|
|
101
|
+
- **Intlayer** provides helpers to **generate localized paths**, **manage locale prefixes**, and emit **`<link rel="alternate" hreflang>`** for SEO. With Nuxt, it complements the framework’s routing.
|
|
102
|
+
|
|
103
|
+
**Why it matters:** Fewer custom glue layers and **cleaner SEO** across locales.
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
### 5) Performance & loading behavior
|
|
108
|
+
|
|
109
|
+
- **vue-i18n**: Supports async locale messages; avoiding over-bundling is on you (split catalogs carefully).
|
|
110
|
+
- **Intlayer**: **Tree-shakes** at build and **lazy-loads per dictionary/locale**. Unused content doesn’t ship.
|
|
111
|
+
|
|
112
|
+
**Why it matters:** Smaller bundles and faster startup for multi-locale Vue apps.
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
### 6) Developer experience & tooling
|
|
117
|
+
|
|
118
|
+
- **vue-i18n**: Mature docs and community; you’ll typically rely on **external localization platforms** for editorial workflows.
|
|
119
|
+
- **Intlayer**: Ships a **free Visual Editor**, optional **CMS** (Git-friendly or externalized), a **VSCode extension**, **CLI/CI** utilities, and **AI-assisted translations** using your own provider keys.
|
|
120
|
+
|
|
121
|
+
**Why it matters:** Lower ops cost and a shorter dev–content loop.
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
### 7) SEO, SSR & SSG
|
|
126
|
+
|
|
127
|
+
- **Both** work with Vue SSR and Nuxt.
|
|
128
|
+
- **Intlayer**: Adds **SEO helpers** (sitemaps/metadata/`hreflang`) that are framework-agnostic and play nicely with Vue/Nuxt builds.
|
|
129
|
+
|
|
130
|
+
**Why it matters:** International SEO without bespoke wiring.
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Why Intlayer? (Problem & approach)
|
|
135
|
+
|
|
136
|
+
Most i18n stacks (including **vue-i18n**) start from **centralized catalogs**:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
.
|
|
140
|
+
├── locales
|
|
141
|
+
│ ├── en.json
|
|
142
|
+
│ ├── es.json
|
|
143
|
+
│ └── fr.json
|
|
144
|
+
└── src
|
|
145
|
+
└── components
|
|
146
|
+
└── MyComponent.vue
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Or with per-locale folders:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
.
|
|
153
|
+
├── locales
|
|
154
|
+
│ ├── en
|
|
155
|
+
│ │ ├── footer.json
|
|
156
|
+
│ │ └── navbar.json
|
|
157
|
+
│ ├── fr
|
|
158
|
+
│ │ ├── footer.json
|
|
159
|
+
│ │ └── navbar.json
|
|
160
|
+
│ └── es
|
|
161
|
+
│ ├── footer.json
|
|
162
|
+
│ └── navbar.json
|
|
163
|
+
└── src
|
|
164
|
+
└── components
|
|
165
|
+
└── MyComponent.vue
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
This often slows development as apps grow:
|
|
169
|
+
|
|
170
|
+
1. **For a new component** you create/edit remote catalogs, wire namespaces, and translate (often via manual copy/paste from AI tools).
|
|
171
|
+
2. **When changing components** you hunt down shared keys, translate, keep locales in sync, remove dead keys, and align JSON structures.
|
|
172
|
+
|
|
173
|
+
**Intlayer** scopes content **per-component** and keeps it **next to the code**, like we already do with CSS, stories, tests, and docs:
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
.
|
|
177
|
+
└── components
|
|
178
|
+
└── MyComponent
|
|
179
|
+
├── MyComponent.content.ts
|
|
180
|
+
└── MyComponent.vue
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
**Content declaration** (per component):
|
|
184
|
+
|
|
185
|
+
```ts fileName="./components/MyComponent/MyComponent.content.ts"
|
|
186
|
+
import { t, type Dictionary } from "intlayer";
|
|
187
|
+
|
|
188
|
+
const componentExampleContent = {
|
|
189
|
+
key: "component-example",
|
|
190
|
+
content: {
|
|
191
|
+
greeting: t({
|
|
192
|
+
en: "Hello World",
|
|
193
|
+
es: "Hola Mundo",
|
|
194
|
+
fr: "Bonjour le monde",
|
|
195
|
+
}),
|
|
196
|
+
},
|
|
197
|
+
} satisfies Dictionary;
|
|
198
|
+
|
|
199
|
+
export default componentExampleContent;
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
**Usage in Vue** (Composition API):
|
|
203
|
+
|
|
204
|
+
```vue fileName="./components/MyComponent/MyComponent.vue"
|
|
205
|
+
<script setup lang="ts">
|
|
206
|
+
import { useIntlayer } from "vue-intlayer"; // Vue integration
|
|
207
|
+
const { greeting } = useIntlayer("component-example");
|
|
208
|
+
</script>
|
|
209
|
+
|
|
210
|
+
<template>
|
|
211
|
+
<span>{{ greeting }}</span>
|
|
212
|
+
</template>
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
This approach:
|
|
216
|
+
|
|
217
|
+
- **Speeds development** (declare once; IDE/AI autocompletes).
|
|
218
|
+
- **Cleans the codebase** (1 component = 1 dictionary).
|
|
219
|
+
- **Eases duplication/migration** (copy a component and its content together).
|
|
220
|
+
- **Avoids dead keys** (unused components don’t import content).
|
|
221
|
+
- **Optimizes loading** (lazy-loaded components bring their content with them).
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
## Additional features of Intlayer (Vue-relevant)
|
|
226
|
+
|
|
227
|
+
- **Cross-framework support**: Works with Vue, Nuxt, Vite, React, Express, and more.
|
|
228
|
+
- **JavaScript-powered content management**: Declare in code with full flexibility.
|
|
229
|
+
- **Per-locale declaration file**: Seed all locales and let tooling generate the rest.
|
|
230
|
+
- **Type-safe environment**: Strong TS config with autocompletion.
|
|
231
|
+
- **Simplified content retrieval**: A single hook/composable to fetch all content for a dictionary.
|
|
232
|
+
- **Organized codebase**: 1 component = 1 dictionary in the same folder.
|
|
233
|
+
- **Enhanced routing**: Helpers for **Vue Router/Nuxt** localized paths and metadata.
|
|
234
|
+
- **Markdown support**: Import remote/local Markdown per locale; expose frontmatter to code.
|
|
235
|
+
- **Free Visual Editor & optional CMS**: Authoring without a paid localization platform; Git-friendly sync.
|
|
236
|
+
- **Tree-shakable content**: Ships only what’s used; supports lazy loading.
|
|
237
|
+
- **Static rendering friendly**: Does not block SSG.
|
|
238
|
+
- **AI-powered translations**: Translate to 231 languages using your own AI provider/API key.
|
|
239
|
+
- **MCP server & VSCode extension**: Automate i18n workflows and authoring inside your IDE.
|
|
240
|
+
- **Interoperability**: Bridges with **vue-i18n**, **react-i18next**, and **react-intl** when needed.
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## When to choose which?
|
|
245
|
+
|
|
246
|
+
- **Choose vue-i18n** if you want the **standard Vue approach**, you’re comfortable managing catalogs/namespaces yourself, and your app is **small to mid-size** (or you already rely on Nuxt i18n).
|
|
247
|
+
- **Choose Intlayer** if you value **component-scoped content**, **strict TypeScript**, **build-time guarantees**, **tree-shaking**, and **batteries-included** routing/SEO/editor tooling-especially for **large, modular Vue/Nuxt codebases**, design-systems, etc.
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## Interoperability with vue-i18n
|
|
252
|
+
|
|
253
|
+
`intlayer` can also help to manage your `vue-i18n` namespaces.
|
|
254
|
+
|
|
255
|
+
Using `intlayer`, you can declare your content in the format of your favorite i18n library, and intlayer will generate your namespaces in the location of your choice (example: `/messages/{{locale}}/{{namespace}}.json`).
|
|
256
|
+
|
|
257
|
+
Refer to [`dictionaryOutput` and `i18nextResourcesDir` options](https://intlayer.org/doc/concept/configuration#content-configuration) for more details.
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
## Conclusion
|
|
262
|
+
|
|
263
|
+
Both **vue-i18n** and **Intlayer** localize Vue apps well. The difference is **how much you must build yourself** to achieve a robust, scalable setup:
|
|
264
|
+
|
|
265
|
+
- With **Intlayer**, **modular content**, **strict TS**, **build-time safety**, **tree-shaken bundles**, and **router/SEO/editor tooling** come **out of the box**.
|
|
266
|
+
- If your team prioritizes **maintainability and speed** in a multi-locale, component-driven Vue/Nuxt app, Intlayer offers the **most complete** experience today.
|
|
267
|
+
|
|
268
|
+
Refer to ['Why Intlayer?' doc](https://intlayer.org/doc/why) for more details.
|