Angular CLI 6: Unknown option: '--locale'

As part of introducing CLI Workspaces, the developers have removed build-related command line switches in favor of configuring them inside the new angular.json file.
After some digging into the new schema (available at the link above), the easiest way to reintroduce your localization switches would be to add them under the following path inside angular.json: projects/your-project/architect/build/options.

Then serve your app without any switches: ng serve.

In the long term, I suppose you are encouraged to define yourself different configurations and set those options over there. Again, see the schema for more about this.

Here is an example of what I did:

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "my-app": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist",
            "index": "src/index.html",
            "main": "src/main.ts",
            "tsConfig": "src/tsconfig.app.json",
            "polyfills": "src/polyfills.ts",
            "i18nFile": "src/locale/messages.some-lang.xlf",
            "i18nLocale": "some-lang",
            "i18nFormat": "xlf",
            "aot": true,
            "assets": [ ...
            ],
            "styles": [ ...
...

Update

Apparently there is a PR for the documentation update, which explains how to do it (pretty much how I wrote it here ;-) )


For the record, --locale was also removed from ng build but they introduced instead --i18n-locale as specified in angular documentation.

E.g, you can do:

ng build --prod --i18n-locale de --i18n-format xlf --i18n-file src/locale/messages.de.xlf

Unfortunately, this does not work with ng serve.