{"record":{"id":"f31545f59850b2bf","repo":"withastro/astro","slug":"i18nnotenabled","errorCode":"i18nNotEnabled","errorMessage":"The `astro:i18n` module cannot be used without enabling `i18n` in your Astro config.","messagePattern":"The `astro:i18n` module cannot be used without enabling `i18n` in your Astro config\\.","errorType":"exception","errorClass":"AstroError","httpStatus":null,"severity":"error","filePath":"packages/astro/src/i18n/vite-plugin-i18n.ts","lineNumber":24,"sourceCode":"const VIRTUAL_MODULE_ID = 'astro:i18n';\n\ntype AstroInternationalization = {\n\tsettings: AstroSettings;\n};\n\nexport default function astroInternationalization({\n\tsettings,\n}: AstroInternationalization): vite.Plugin {\n\tconst { i18n } = settings.config;\n\treturn {\n\t\tname: VIRTUAL_MODULE_ID,\n\t\tenforce: 'pre',\n\t\tresolveId: {\n\t\t\tfilter: {\n\t\t\t\tid: new RegExp(`^${VIRTUAL_MODULE_ID}$`),\n\t\t\t},\n\t\t\thandler() {\n\t\t\t\tif (i18n === undefined) throw new AstroError(AstroErrorData.i18nNotEnabled);\n\t\t\t\treturn this.resolve('astro/virtual-modules/i18n.js');\n\t\t\t},\n\t\t},\n\t};\n}\n","sourceCodeStart":6,"sourceCodeEnd":30,"githubUrl":"https://github.com/withastro/astro/blob/52e6c34790cc8ac4e69e6135ace06049867e5c4a/packages/astro/src/i18n/vite-plugin-i18n.ts#L6-L30","documentation":"The `astro:i18n` virtual module (getRelativeLocaleUrl, pathHasLocale, and friends) only exists when internationalization is configured. Its Vite plugin throws i18nNotEnabled at resolve time when an import of `astro:i18n` is resolved while `i18n` is undefined in the Astro config.","triggerScenarios":"Importing `astro:i18n` in any component, script, or module when astro.config has no `i18n` property; adding a dependency or copied-in component that uses astro:i18n to a project without i18n enabled; removing the i18n config while imports remain in the codebase.","commonSituations":"Copying an i18n-aware component from another project or a starter template; beginning an i18n migration by adding imports before touching the config; disabling i18n later and missing stray imports.","solutions":["Enable i18n in astro.config: `i18n: { defaultLocale: 'en', locales: ['en', 'es'] }`.","If you do not want i18n, remove the `astro:i18n` imports (search the repo for them).","If the import comes from a dependency, either enable i18n or drop/replace that dependency."],"exampleFix":"// before - astro.config.mjs\nexport default defineConfig({ integrations: [react()] }); // component imports 'astro:i18n'\n\n// after\nexport default defineConfig({\n  i18n: { defaultLocale: 'en', locales: ['en', 'es'] },\n  integrations: [react()],\n});","handlingStrategy":"validation","validationCode":"// repo lint: flag astro:i18n imports when the config has no i18n block\nimport { readFileSync } from 'node:fs';\nconst config = readFileSync('astro.config.mjs', 'utf8');\nconst src = readFileSync('src/pages/index.astro', 'utf8');\nif (src.includes(\"from 'astro:i18n'\") && !/\\bi18n\\s*:/.test(config)) {\n  console.error('enable i18n in astro.config before importing astro:i18n');\n  process.exit(1);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Enable i18n in astro.config before adding the first astro:i18n import.","When removing i18n from a project, search the repo for astro:i18n imports.","Check that copied-in components or dependencies do not use astro:i18n before adding them to a non-i18n project."],"tags":["i18n","localization","virtual-module","config"],"backgroundTag":"optional-feature-not-enabled","analyzedSha":"52e6c34790cc8ac4e69e6135ace06049867e5c4a","analyzedAt":"2026-08-18T18:48:03.901Z","contentChangedAt":"2026-08-18T18:48:03.901Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}