استخدم مساعدك المفضل للملخص واستخدم هذه الصفحة والموفر AI الذي تريده
تاريخ الإصدارات
- "Init history"v8.13.0٥/٦/٢٠٢٦
تمت ترجمة محتوى هذه الصفحة باستخدام الذكاء الاصطناعي.
اعرض آخر نسخة المحتوى الأصلي باللغة الإنكليزيةIf you have an idea for improving this documentation, please feel free to contribute by submitting a pull request on GitHub.
GitHub link to the documentationCopy doc Markdown to clipboard
Migrating from @nuxtjs/i18n to Intlayer
Why migrate from @nuxtjs/i18n to Intlayer?
Instead of loading massive JSON files into your pages, load only the necessary content. Intlayer helps reduce your bundle and page sizes by up to 50%.
Scoping your application's content facilitates maintenance for large-scale applications. You can duplicate or delete a single feature folder without the mental burden of reviewing your entire content codebase. Additionally, Intlayer is fully typed to ensure your content's accuracy.
Intlayer is also the solution with the most active development in the i18n ecosystem — issues are fixed fast, new framework adapters land regularly, and the core API is continuously refined based on real-world production feedback.
Co-locating content reduces the context needed by Large Language Models (LLMs). Intlayer also comes with a suite of tools, such as a CLI to test for missing translations, LSP, MCP, and agent skills, to make the developer experience (DX) even smoother for AI agents.
Use automation to translate in your CI/CD pipeline using the LLM of your choice at the cost of your AI provider. Intlayer also offers a compiler to automate content extraction, as well as a web platform to help translate in the background.
Connecting massive JSON files to components can lead to performance and reactivity issues. Intlayer optimizes your content loading at build time.
More than just an i18n solution, Intlayer provides a self-hosted visual editor and a full CMS to help you manage your multilingual content in real-time, making collaboration with translators, copywriters, and other team members seamless. Content can be stored locally and/or remotely.
Migration strategies
Since @nuxtjs/i18n is powered by vue-i18n under the hood, there are two complementary strategies for migrating to Intlayer:
Compat adapter (recommended for existing apps) — Install
@intlayer/vue-i18nandnuxt-intlayer. This exposes the exact same API asvue-i18nbut delegates all translation work to Intlayer under the hood. You keep your existing$t,useI18n(), and Nuxt routing unchanged — the only change is the initialization.Full migration — Gradually replace
@nuxtjs/i18nAPIs with native Intlayer hooks (useIntlayer) and co-locate content in.content.tsfiles alongside your components.
This guide covers Strategy 1 first (drop-in compat adapter), then walks through the optional full migration.
Table of Contents
Quick migration
The following steps are the minimum required to get your existing Nuxt app running on Intlayer with zero code changes in your components.
Install Dependencies
Install the Intlayer core packages and the compat adapter:
bashنسخ الكودنسخ الكود إلى الحافظة
npm install intlayer vue-intlayer nuxt-intlayer @intlayer/vue-i18n @intlayer/sync-json-pluginnpx intlayer initYou can safely keep
@nuxtjs/i18ninstalled during migration, though you will remove it from your Nuxt config shortly.Configure Intlayer
The
intlayer initcommand creates a starterintlayer.config.ts. Update it to match your existing locales and point thesyncJSONplugin at your message files:intlayer.config.tsنسخ الكودنسخ الكود إلى الحافظة
import { Locales, type IntlayerConfig } from "intlayer"; import { syncJSON } from "@intlayer/sync-json-plugin"; const config: IntlayerConfig = { internationalization: { locales: [ Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH, // Add all your existing locales here ], defaultLocale: Locales.ENGLISH, }, plugins: [ syncJSON({ // matches vue-i18n placeholder syntax: {name} format: "icu", source: ({ locale }) => `./locales/${locale}.json`, location: "locales", }), ], }; export default config;sourcemaps a locale to its JSON file path.locationtells the Intlayer watcher which folder to monitor for changes. Theformat: 'icu'option ensures that placeholders are parsed correctly forvue-i18n.Update Nuxt Configuration
Replace the
@nuxtjs/i18nmodule withnuxt-intlayerin yournuxt.config.ts. The Intlayer plugin automatically injects module aliases, meaning your existingimport { useI18n } from 'vue-i18n'calls are transparently redirected to@intlayer/vue-i18n.nuxt.config.tsنسخ الكودنسخ الكود إلى الحافظة
export default defineNuxtConfig({ // Remove '@nuxtjs/i18n' modules: ["nuxt-intlayer"], });You no longer need to define Nuxt i18n config objects. Intlayer compiles all dictionaries at build time, handling locale detection, routing, and dictionary loading seamlessly.
That's it for the quick migration. Your Nuxt app now runs on Intlayer while keeping every $t and useI18n() intact.
Complete migration
The steps below are optional and can be done incrementally. They unlock the full Intlayer feature set: visual editor, CMS, typed content files, AI-powered translation, and more.
Explicit import renaming (optional)
اختياريThe Intlayer plugins already handle aliasing at the bundler level. If you prefer to make the dependency explicit in your source files, you can rename imports manually:
اظهار جميع محتويات الجدولافتح الجدول في نافذة منبثقة لعرض جميع محتويات البيانات بوضوح
Before After import { useI18n } from 'vue-i18n'import { useI18n } from '@intlayer/vue-i18n'These are drop-in replacements — no changes to call signatures, arguments, or return types are required.
Enable AI-Powered Translation Automation
اختياريOnce Intlayer is wired up, use its CLI to fill missing translations automatically:
bashنسخ الكودنسخ الكود إلى الحافظة
# Test for missing translations (add to CI)npx intlayer test# Fill missing translations with AInpx intlayer fillAdd the AI configuration to
intlayer.config.ts:intlayer.config.tsنسخ الكودنسخ الكود إلى الحافظة
import { Locales, type IntlayerConfig } from "intlayer"; import { syncJSON } from "@intlayer/sync-json-plugin"; const config: IntlayerConfig = { internationalization: { locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH], defaultLocale: Locales.ENGLISH, }, plugins: [ syncJSON({ format: "icu", source: ({ locale }) => `./locales/${locale}.json`, location: "locales", }), ], ai: { apiKey: process.env.OPENAI_API_KEY, // provider: "openai", // default // model: "gpt-4o-mini", // default }, }; export default config;See Intlayer CLI documentation for all available options.
What you can delete after migration
Once the compat adapter is in place, the following boilerplate can be removed:
افتح الجدول في نافذة منبثقة لعرض جميع محتويات البيانات بوضوح
| File / pattern | Why it's no longer needed |
|---|---|
i18n configurations in nuxt.config.ts | Intlayer handles routing, dictionary loading, and default locales internally. |
@nuxtjs/i18n from package.json | Replaced entirely by nuxt-intlayer. |
JSON language bundles (locales/*.json) | JSON bundles are only needed if you still use the syncJSON plugin. Once you migrate to .content.ts files you can delete the JSON folder. |
When you are ready to go further, Intlayer automatically discovers all .content.ts and .content.json files anywhere in your codebase (by default, anywhere inside ./src). You can place a my-component.content.ts file right next to your MyComponent.vue and Intlayer will pick it up at build time with no additional configuration — no imports, no registration, no centralized index file needed. This makes co-locating translations with pages and components completely frictionless.
Configure TypeScript
Intlayer uses module augmentation to provide full TypeScript intellisense for your translation keys. Make sure your tsconfig.json includes the auto-generated types:
نسخ الكود إلى الحافظة
{ // ... Your existing TypeScript configurations "include": [ // ... Your existing TypeScript configurations ".intlayer/**/*.ts", // Include the auto-generated types ],}Git Configuration
Add Intlayer's generated directory to your .gitignore:
نسخ الكود إلى الحافظة
# Ignore the files generated by Intlayer.intlayerGo Further
- Visual Editor — Manage translations visually in your browser: Intlayer Visual Editor
- CMS — Externalize and manage content remotely: Intlayer CMS
- VS Code Extension — Get autocompletion and real-time translation error detection: Intlayer VS Code Extension
- CLI Reference — Full list of CLI commands: Intlayer CLI
- Intlayer with Nuxt — Full setup guide for Nuxt: intlayerwithnuxt.md
- Intlayer with Vue — Full setup guide for Vue: intlayerwithvite+vue.md