angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

ng serve --configuration=en throws error

Open bobKasbi opened this issue 8 years ago • 8 comments

### Versions


Output from: `ng --version`.

Angular CLI: 6.0.3
Node: 8.11.1
OS: darwin x64 (Sierra)
Angular: 6.0.2
... animations, cdk, common, compiler, compiler-cli, core, forms
... http, language-service, material, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.3
@angular-devkit/build-angular     0.6.3
@angular-devkit/build-optimizer   0.6.3
@angular-devkit/core              0.6.3
@angular-devkit/schematics        0.6.3
@angular/cli                      6.0.3
@ngtools/webpack                  6.0.3
@schematics/angular               0.6.3
@schematics/update                0.6.3
rxjs                              6.1.0
typescript                        2.7.2
webpack                           4.8.3
    
[](url)

**### Repro steps**
Step 1:
I did add this to my angular.json file for i18n translation - it's based on the doc [here](https://angular.io/guide/i18n#merge-the-completed-translation-file-into-the-app): 

`...
"serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "demo:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "demo:build:production"
            },
            "en": {
                "aot": true,
                "outputPath": "dist/en/",
                "i18nFile": "src/assets/i18n/messages.en.xlf",
                "i18nFormat": "xlf",
                "i18nLocale": "en"
            }
          }
    },
.......`

Step 2:
Run the command: `ng serve --configuration=en --port 4900`

Step 3: Run/try other command: `for lang in en de; do ng build --output-path=dist/$lang --aot --prod --i18n-file=src/assets/i18n/messages.$lang.xlf --i18n-format=xlf --locale=$lang; done`


**### Observed behavior**
When I run the command: `ng serve --configuration=en --port 4900`, I get the following error:

> Schema validation failed with the following errors:
> Data path "" should NOT have additional properties(outputPath).

When I run the following: `for lang in en de; do ng build --output-path=dist/$lang --aot --prod --i18n-file=src/assets/i18n/messages.$lang.xlf --i18n-format=xlf --locale=$lang; done`, I get the following error:

> Unknown option: '--locale'

**### Desired behavior**

What would like to see implemented?
i18n Internazionalization  for different languages - in this case EN and DE

What is the usecase?
Serving the App in specific language based on the serve command mentioned above.

What did you expect to see?
Serving the App in specific language based on the serve command mentioned above.

bobKasbi avatar May 29 '18 14:05 bobKasbi

Move your "en" configuration into configuration of build command. Then referance in configuration of serve command.

"serve": { "builder": "@angular-devkit/build-angular:dev-server", "options": { "browserTarget": "projec:build" }, "configurations": { "production": { "browserTarget": "project:build:production" }, "qa": { "browserTarget": "projec:build:qa" }

hungcung2409 avatar May 31 '18 06:05 hungcung2409

@chimung How do you reference the configuration from the serve area?

Also, I got the same problem. I think the documentation should be more explicit on which configurations do we have to edit, because there is more than one.

mglavall avatar Jun 01 '18 10:06 mglavall

in my configuration of "qa" in serve. I reference by "name-of-your-project:build:qa". It will get configuration of "qa" in build

hungcung2409 avatar Jun 01 '18 10:06 hungcung2409

In this way, it would work:

"projects": { "ProjectName": { ....., "build": { "builder": "@angular-devkit/build-angular:browser", ...., "configurations": { "production": { "fileReplacements": [ { "replace": "src/environments/environment.ts", "with": "src/environments/environment.prod.ts" } ], "optimization": true, "outputHashing": "all", .... }, "en": { "aot": true, "outputPath": "dist/en", "i18nFile": "src/assets/i18n/messages.en.xlf", "i18nFormat": "xlf", "i18nLocale": "en" }, .... } }, "serve": { "builder": "@angular-devkit/build-angular:dev-server", "options": { "browserTarget": "ProjectName:build" }, "configurations": { "production": { "browserTarget": "ProjectName:build:production" }, "en": { "browserTarget": "ProjectName:build:en" } } }, ..... } }

bobKasbi avatar Jun 01 '18 13:06 bobKasbi

Any proper docs that guide us on ng serve with configurations in angular.json?

triplevoid avatar Jun 02 '18 13:06 triplevoid

https://github.com/angular/angular-cli/blob/master/docs/documentation/stories/internationalization.md

cghislai avatar Jun 19 '18 21:06 cghislai

https://github.com/angular/angular-cli/blob/master/docs/documentation/stories/internationalization.md should be updated with correct instructions on how to do this.

filipesilva avatar Aug 10 '18 09:08 filipesilva

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.