{"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/d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca/packages/astro/src/i18n/vite-plugin-i18n.ts#L6-L30","documentation":"The `astro:i18n` virtual module is only synthesized by the i18n Vite plugin when `settings.config.i18n` is defined. In `resolveId`, if `i18n === undefined`, the plugin throws `i18nNotEnabled` rather than resolving the module, because there is no i18n configuration to generate it from.","triggerScenarios":"Importing `astro:i18n` in any module when `astro.config` has no `i18n` block (or it is undefined).","commonSituations":"Copying code from an i18n-enabled project into one without i18n configured; removing the `i18n` config but leaving imports in place; a third-party integration/component that unconditionally imports `astro:i18n`.","solutions":["Add an `i18n` section to `astro.config.mjs` (at minimum `i18n: { defaultLocale, locales }`).","Remove the `astro:i18n` import if you do not need internationalization.","If shipping a reusable component, gate the import behind a check or document that i18n config is required."],"exampleFix":"// before — astro.config.mjs has no i18n key, yet code imports the module\nimport * as i18n from 'astro:i18n'\n\n// after — enable i18n in config\nexport default defineConfig({\n  i18n: { defaultLocale: 'en', locales: ['en', 'es'] },\n})","handlingStrategy":"validation","validationCode":"function assertI18nEnabled(config) {\n  if (!config.i18n) {\n    throw new Error('Enable i18n in astro.config before importing astro:i18n');\n  }\n}","typeGuard":"function i18nIsEnabled(config) {\n  return config.i18n !== undefined && Array.isArray(config.i18n.locales);\n}","tryCatchPattern":"null","preventionTips":["Configure i18n before adding astro:i18n imports.","Remove astro:i18n imports when you remove the i18n config.","For reusable components, document the i18n requirement."],"tags":["i18n","config","vite","virtual-module"],"backgroundTag":null,"analyzedSha":"d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca","analyzedAt":"2026-08-12T13:37:29.035Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}