{"record":{"id":"d7b579b3304e7bd4","repo":"angular/angular-cli","slug":"locale-data-for-locale-cannot-be-found-using","errorCode":null,"errorMessage":"Locale data for '${locale}' cannot be found. Using locale data for '${first}'.","messagePattern":"Locale data for '(.+?)' cannot be found\\. Using locale data for '(.+?)'\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/angular_devkit/build_angular/src/utils/i18n-webpack.ts","lineNumber":73,"sourceCode":"  const projectRequire = createRequire(projectRoot + '/');\n  const localeResolver = (locale: string) =>\n    projectRequire.resolve(path.join(LOCALE_DATA_BASE_MODULE, locale));\n\n  // Load locale data and translations (if present)\n  let loader;\n  const usedFormats = new Set<string>();\n  for (const [locale, desc] of Object.entries(i18n.locales)) {\n    if (!i18n.inlineLocales.has(locale) && locale !== i18n.sourceLocale) {\n      continue;\n    }\n\n    let localeDataPath = findLocaleDataPath(locale, localeResolver);\n    if (!localeDataPath) {\n      const [first] = locale.split('-');\n      if (first) {\n        localeDataPath = findLocaleDataPath(first.toLowerCase(), localeResolver);\n        if (localeDataPath) {\n          context.logger.warn(\n            `Locale data for '${locale}' cannot be found. Using locale data for '${first}'.`,\n          );\n        }\n      }\n    }\n    if (!localeDataPath) {\n      context.logger.warn(\n        `Locale data for '${locale}' cannot be found. No locale data will be included for this locale.`,\n      );\n    } else {\n      desc.dataPath = localeDataPath;\n    }\n\n    if (!desc.files.length) {\n      continue;\n    }\n\n    loader ??= await createTranslationLoader();","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular_devkit/build_angular/src/utils/i18n-webpack.ts#L55-L91","documentation":"During i18n build configuration, when locale data for a full locale tag (e.g. 'fr-CA') cannot be resolved in Angular's locale data, the CLI falls back to the primary language subtag (e.g. 'fr') and warns that fallback data is being used.","triggerScenarios":"configureI18nBuild with a build option locale like 'xx-YY' where findLocaleDataPath has no data for the full tag but does for the first subtag before the hyphen.","commonSituations":"Using regional locale variants in i18n configurations ('en-GB', 'pt-BR' variants not in Angular's registry); custom or rare locales; typos in locale IDs.","solutions":["Verify the locale ID spelling and format (BCP 47) in your i18n build options.","Register custom locale data yourself (e.g. registerLocaleData) or provide a localeResolver so the full locale resolves.","Accept the fallback if base-language data is acceptable, or switch the build to the exact supported locale (e.g. 'fr' instead of 'fr-XX')."],"exampleFix":"// before (angular.json i18n options)\n\"locales\": { \"fr-CA\": \"src/locale/messages.fr-CA.xlf\" }\n// after (use a supported locale or register data)\n\"locales\": { \"fr\": \"src/locale/messages.fr.xlf\" }","handlingStrategy":"fallback","validationCode":"import { registerLocaleData } from '@angular/common';\nimport localeFrCa from '@angular/common/locales/fr-CA';\n// fail fast at app bootstrap if data is unavailable\ntry { registerLocaleData(localeFrCa, 'fr-CA'); } catch { console.warn('fr-CA locale data unavailable; fallback will be used'); }","typeGuard":null,"tryCatchPattern":"try {\n  await configureI18nBuild(context, buildOptions, i18n);\n} catch (e) {\n  context.logger.warn(`i18n configuration degraded to fallback locale data: ${e.message}`);\n}","preventionTips":["Only use locale IDs present in @angular/common/locales for i18n build options.","Register custom locale data for regional variants you need.","Review build warnings in CI to catch unintended locale fallbacks."],"tags":["angular","i18n","localization","fallback"],"backgroundTag":"locale-data-missing-fallback","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}