angular/angular-cli · error · Error

The development server only supports localizing a single loc

Error message

The development server only supports localizing a single locale per build.

What it means

The webpack dev-server can only localize one locale per serve run, unlike the production build which can inline multiple locales. When i18n.shouldInline indicates localization and the set of inline locales has more than one entry, setup() throws because serving all localized variants simultaneously is not supported.

Source

Thrown at packages/angular_devkit/build_angular/src/builders/dev-server/webpack-server.ts:148

    if (!config.devServer) {
      throw new Error('Webpack Dev Server configuration was not set.');
    }

    let locale: string | undefined;
    if (i18n.shouldInline) {
      // Dev-server only supports one locale
      locale = [...i18n.inlineLocales][0];
    } else if (i18n.hasDefinedSourceLocale) {
      // use source locale if not localizing
      locale = i18n.sourceLocale;
    }

    let webpackConfig = config;

    // If a locale is defined, setup localization
    if (locale) {
      if (i18n.inlineLocales.size > 1) {
        throw new Error(
          'The development server only supports localizing a single locale per build.',
        );
      }

      await setupLocalize(
        locale,
        i18n,
        browserOptions,
        webpackConfig,
        options.cacheOptions,
        context,
      );
    }

    if (transforms.webpackConfiguration) {
      webpackConfig = await transforms.webpackConfiguration(webpackConfig);
    }

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Serve a single locale: run ng serve with --configuration referencing a config that limits localize to one locale, or set "localize": ["fr"] in the dev-server build target options.
  2. Use buildTarget/configuration overrides in the serve target that restrict inline locales to one.
  3. Do full multi-locale inlining only in the production build (ng build), not in serve.
  4. Temporarily test other locales by re-running serve with a different single locale.

Example fix

// before (angular.json serve/buildTarget options)
"localize": true
// after
"localize": ["fr"]
Defensive patterns

Strategy: validation

Validate before calling

import { getProjectI18nConfig } from './i18n-utils'; // or read angular.json i18n config
const inlineLocales = resolveInlineLocales(options); // your locale resolution
if (inlineLocales.size > 1) {
  throw new Error('Dev-server supports one locale; pass a single locale to localize.');
}

Type guard

const isSingleLocale = (locales: Set<string>): locales is Set<string> & { size: 1 } => locales.size === 1;

Try / catch

try {
  await ngServe();
} catch (e) {
  if (String(e.message).includes('single locale')) {
    // rerun serve with one locale, e.g. localize: ['fr'] in serve options
  }
  throw e;
}

Prevention

When it happens

Trigger: angular.json (or CLI options) defines multiple localize locales for the build target and 'ng serve' is run without restricting to a single locale; passing --localize with several locales to the dev-server; a configuration that inherits i18n.locales with many entries while dev-server defaults to inlining all.

Common situations: Developers adding several locales (e.g. en, fr, de) for production and then running ng serve; CI jobs reusing production configurations (with multi-locale localize: true) for the dev-server; programmatic dev-server scheduling with a multi-locale buildTarget.

Related errors


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