Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk4 min

How to Deploy Multiple Locales in Angular—and Make the URLs Work

Build Angular locale variants, publish each under a matching URL path, and configure routing so visitors reach an available language.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To deploy multiple locales in Angular, configure a source locale and translation files in angular.json, build the locale variants you need, then serve each variant at a URL that matches its output path and base href. For static hosting, the web server can route the root URL according to the browser’s Accept-Language header and fall back to a default locale. With Angular server rendering and outputMode set to server, Angular can handle that redirect dynamically.

How do I deploy multiple locales in Angular?

The deployment has three parts that must agree: your locale configuration, the generated output directories, and the public URL paths. Angular’s usual static-hosting pattern puts each language in a subdirectory, such as /fr or /es. The server serves the matching variant from that path and can direct visitors from / to a locale based on Accept-Language.

As an Amazon Associate I earn from qualifying purchases.

Angular’s Deploy multiple locales guide includes Nginx and Apache examples. Treat them as starting points: adjust locale matching, the default locale, document root, and single-page application fallback to fit your application and hosting setup.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Configure the source locale and translations

In angular.json, identify the source locale and map each target locale to its translation file in the project’s i18n configuration. Angular uses en-US as the default source locale if you have not specified one. Locale identifiers are based on BCP 47 tags, so keep each identifier consistent across configuration, translation files, output paths, and server routing.

Mark translatable text in your templates, then use Angular CLI’s extract-i18n command to create source translation files. Angular supports XLIFF and other translation formats, and lets you choose an output path and filename. After translations are supplied, Angular’s build-time localization process compiles a complete application variant for each selected locale.

For ongoing work shared across a team, an external translation-management workflow may help coordinate content and synchronization. For example, Transifex documents an Angular workflow involving its SDK and command-line tooling. This is optional: Angular’s native build-time localization does not require an external service, and the available documentation does not establish comparative cost, translation quality, or performance.

Build the locale variants you plan to publish

Use the localize build option to choose which configured locales to generate:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Set localize to true to build all configured locales.
  • Set it to an array, such as ["fr"], to build only selected locale IDs.
  • For a one-off build of the configured locales, run ng build --localize.

Angular places each generated variant in a locale-specific directory under the configured output path, sets the document’s lang attribute, and adjusts the base href for that locale. The deployment guide says ng build defaults to the production configuration.

The Angular development server supports one localized locale at a time; serving several localized variants together with ng serve is not supported. Build the variants you intend to release and publish those generated outputs instead.

Match output paths, base hrefs, and public URLs

For every locale, make the generated directory and the externally visible URL line up. If a variant is generated for a locale subpath, the public site should serve that variant under the corresponding path. Angular adjusts the base href by adding the configured locale subpath. The HTML base tag’s href sets the base URI for relative links, so a mismatch can make navigation or resource paths resolve incorrectly after deployment.

Locale configuration can use baseHref or subPath to customize the path. Use subPath when you need to customize both the output directory and base href; Angular’s workspace reference says that subPath and baseHref cannot be used together on the same locale setting. Check the generated HTML and directory layout against the paths your host actually serves.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If assets must load from a separate compile-time path, Angular provides --deploy-url. It overlaps with base href, so Angular recommends using the base href where possible and reserving --deploy-url for cases that need it.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choose how visitors reach a locale

Approach Where locale selection happens What you need to configure
Static locale variants The web server serves locale-specific output paths and may redirect requests from the root based on Accept-Language. Publish each generated variant under its matching path, configure the redirect and default-locale fallback, and adapt the host’s routing and SPA fallback rules.
Angular server rendering With outputMode set to server, Angular handles redirection dynamically based on Accept-Language. Use the server-rendered deployment configuration and confirm that the available locale paths and fallback fit the application.

The documentation describes these approaches but does not provide a general performance or cost comparison. A locale switcher should also take visitors directly to the corresponding locale path rather than assuming that a root-level redirect will select the language they want.

Check the deployment before release

  • Confirm the source locale and each translation-file mapping in angular.json.
  • Build all intended locales, or the selected subset, and verify that each has its own generated directory.
  • Check each variant’s generated lang attribute and base href.
  • Open the public URL for each locale directly, not only through the site root, and verify that assets and relative navigation resolve correctly.
  • Test the root redirect with a supported browser language and with an unavailable preference; confirm that the latter falls back to your configured default.
  • Verify that the server’s locale patterns, document root, and application fallback match your actual deployment rather than copying an example unchanged.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.