Module Configuration Reference
Relevant source files
The following files were used as context for generating this wiki page:
The nuxt-i18n-micro configuration system manages how the internationalization module behaves during build time and runtime. It focuses on performance, allowing developers to define locale strategies, translation loading methods, and SEO metadata generation.
The configuration object is typically defined within the i18n key of the nuxt.config.ts file. It controls internal processes such as route generation via @i18n-micro/route-strategy and path resolution via @i18n-micro/path-strategy.
Sources: README.md:104-123, packages/route-strategy/README.md:79-90, AGENTS.md:14-25
Configuration Grouping Architecture
The module organizes its options into six logical categories to manage the complexity of internationalization.
This diagram illustrates the high-level grouping of configuration options used by the documentation generator to categorize module settings.
Sources: scripts/src/commands/docs-generate.ts:25-70
Locales and Routing
This section defines the available languages and how they appear in the application URLs.
Strategy-Based Routing
The strategy option determines how locale prefixes are applied to routes. The RouteGenerator consumes these settings to mutate Nuxt pages.
| Strategy | Description |
|---|---|
no_prefix | URLs have no locale prefix. Locale is handled via cookies or runtime logic. |
prefix | All localized routes require a prefix (e.g., /en/about). |
prefix_except_default | The default locale uses no prefix, while others are prefixed. |
prefix_and_default | The default locale is available both with and without a prefix. |
Sources: packages/route-strategy/README.md:38-66, scripts/src/commands/docs-generate.ts:31-41
Core Routing Options
- locales: An array of objects defining language codes, ISO codes, and text direction.
- defaultLocale: The fallback language code used when no locale is detected.
- globalLocaleRoutes: A map for custom per-locale paths (e.g.,
/aboutbecoming/de/ueber-uns). - localeCookie: Configuration for the cookie that stores the user's language preference.
Sources: scripts/src/commands/docs-generate.ts:32-40, test/fixtures/n3/nuxt.config.ts:40-47
Translations and Payloads
Translation settings control where files live and how they are served to the client.
Translation Resolution
The module primarily supports JSON-based translations. It splits content between global files and page-specific files to optimize bundle sizes.
- translationDir: The directory containing translation files (defaults to
locales). - fallbackLocale: The locale to use if a key is missing in the current language.
- disablePageLocales: Disables the automatic loading of page-specific translation files.
- plural: Configuration for pluralization rules.
Sources: scripts/src/commands/docs-generate.ts:45-50, README.md:88-93
Performance and Caching
To maintain a "micro" footprint, the module provides options to fine-tune data delivery.
The sequence shows how translations reach the browser based on payload configuration.
Sources: scripts/src/commands/docs-generate.ts:54-58, README.md:46-55
SEO and Meta Tags
When the meta option is enabled, the module automatically generates SEO-related tags for each localized page.
- meta: Boolean flag to enable/disable automatic meta tag generation.
- canonicalQueryWhitelist: Defines which query parameters are allowed in canonical URLs to prevent duplicate content issues.
- useI18nHead: A composable influenced by these settings to provide per-page SEO overrides.
Sources: scripts/src/commands/docs-generate.ts:62-65, test/fixtures/n3/nuxt.config.ts:48
Example Configuration
The following snippet demonstrates a typical implementation in a Nuxt project.
// test/fixtures/n3/nuxt.config.ts:34-49
export default defineNuxtConfig({
i18n: {
disableWatcher: true,
locales: [
{ code: 'en', iso: 'en-US', dir: 'ltr' },
{ code: 'de', iso: 'de-DE', dir: 'ltr' }
],
autoDetectLanguage: false,
autoDetectPath: '/',
strategy: 'prefix',
globalLocaleRoutes: {
'/about': { de: '/ueber-uns' }
},
defaultLocale: 'de',
translationDir: './app/locales',
meta: true,
},
})
Sources: test/fixtures/n3/nuxt.config.ts:34-49, README.md:104-123
Summary
The nuxt-i18n-micro configuration provides a performance-first approach to internationalization. By categorizing options into specific domains like routing strategies, translation payloads, and SEO, the module ensures that developers can scale large projects while maintaining small bundle sizes and fast build times. The use of @i18n-micro/route-strategy ensures that route generation remains deterministic and decoupled from the Nuxt runtime.
Sources: README.md:80-87, packages/route-strategy/README.md:10-25