angular/angular-cli · warning

Locale data for '${locale}' cannot be found. Using locale da

Error message

Locale data for '${locale}' cannot be found. Using locale data for '${first}'.

What it means

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.

Source

Thrown at packages/angular_devkit/build_angular/src/utils/i18n-webpack.ts:73

  const projectRequire = createRequire(projectRoot + '/');
  const localeResolver = (locale: string) =>
    projectRequire.resolve(path.join(LOCALE_DATA_BASE_MODULE, locale));

  // Load locale data and translations (if present)
  let loader;
  const usedFormats = new Set<string>();
  for (const [locale, desc] of Object.entries(i18n.locales)) {
    if (!i18n.inlineLocales.has(locale) && locale !== i18n.sourceLocale) {
      continue;
    }

    let localeDataPath = findLocaleDataPath(locale, localeResolver);
    if (!localeDataPath) {
      const [first] = locale.split('-');
      if (first) {
        localeDataPath = findLocaleDataPath(first.toLowerCase(), localeResolver);
        if (localeDataPath) {
          context.logger.warn(
            `Locale data for '${locale}' cannot be found. Using locale data for '${first}'.`,
          );
        }
      }
    }
    if (!localeDataPath) {
      context.logger.warn(
        `Locale data for '${locale}' cannot be found. No locale data will be included for this locale.`,
      );
    } else {
      desc.dataPath = localeDataPath;
    }

    if (!desc.files.length) {
      continue;
    }

    loader ??= await createTranslationLoader();

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Verify the locale ID spelling and format (BCP 47) in your i18n build options.
  2. Register custom locale data yourself (e.g. registerLocaleData) or provide a localeResolver so the full locale resolves.
  3. 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').

Example fix

// before (angular.json i18n options)
"locales": { "fr-CA": "src/locale/messages.fr-CA.xlf" }
// after (use a supported locale or register data)
"locales": { "fr": "src/locale/messages.fr.xlf" }
Defensive patterns

Strategy: fallback

Validate before calling

import { registerLocaleData } from '@angular/common';
import localeFrCa from '@angular/common/locales/fr-CA';
// fail fast at app bootstrap if data is unavailable
try { registerLocaleData(localeFrCa, 'fr-CA'); } catch { console.warn('fr-CA locale data unavailable; fallback will be used'); }

Try / catch

try {
  await configureI18nBuild(context, buildOptions, i18n);
} catch (e) {
  context.logger.warn(`i18n configuration degraded to fallback locale data: ${e.message}`);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30). Data as JSON: /api/errors/d7b579b3304e7bd4. Report an issue: GitHub.