forked from angular/angular-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(@angular/cli): add i18n commands and story
fix(@angular/cli): make flag values case insensitive (angular#5355) Fixes angular#5344 docs(@angular/cli): fixing broken ng doc link in wiki ng docs --> ng doc style: blueprint consistency (angular#5392) docs(@angular/cli): services are provided, not declared docs(@angular/cli): services are provided, not declared Merge branch 'master' into docs-i18n-story docs(@angular/cli): add i18n commands and story
- Loading branch information
Showing
43 changed files
with
323 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Serve from Disk | ||
|
||
The CLI supports running a live browser reload experience to users by running `ng serve`. This will compile the application upon file saves and reload the browser with the newly compiled application. This is done by hosting the application in memory and serving it via [webpack-dev-server](https://webpack.js.org/guides/development/#webpack-dev-server). | ||
|
||
If you wish to get a similar experience with the application output to disk please use the steps below. This practice will allow you to ensure that serving the contents of your `dist` dir will be closer to how your application will behave when it is deployed. | ||
|
||
## Environment Setup | ||
### Install a web server | ||
You will not be using webpack-dev-server, so you will need to install a web server for the browser to request the application. There are many to choose from but a good one to try is [lite-server](https://github.com/johnpapa/lite-server) as it will auto-reload your browser when new files are output. | ||
|
||
## Usage | ||
You will need two terminals to get the live-reload experience. The first will run the build in a watch mode to compile the application to the `dist` folder. The second will run the web server against the `dist` folder. The combination of these two processes will mimic the same behavior of ng serve. | ||
|
||
### 1st terminal - Start the build | ||
```bash | ||
ng build --watch | ||
``` | ||
|
||
### 2nd terminal - Start the web server | ||
```bash | ||
lite-server --baseDir="dist" | ||
``` | ||
When using `lite-server` the default browser will open to the appropriate URL. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Internationalization (i18n) | ||
|
||
If you are working on internationalization, the CLI can help you with the following steps: | ||
- extraction | ||
- serve | ||
- build | ||
|
||
The first thing that you have to do is to setup your application to use i18n. | ||
To do that you can follow [the cookbook on angular.io](https://angular.io/docs/ts/latest/cookbook/i18n.html). | ||
|
||
### Extraction | ||
When your app is ready, you can extract the strings to translate from your templates with the | ||
`ng xi18n` command. | ||
|
||
By default it will create a file named `messages.xlf` in your `src` folder. | ||
You can use [parameters from the xi18n command](../xi18n) to change the format, | ||
the name, the location and the source locale of the extracted file. | ||
|
||
For example to create a file in the `src/locale` folder you would use: | ||
```sh | ||
ng xi18n --output-path src/locale | ||
``` | ||
|
||
### Serve | ||
Now that you have generated a messages bundle source file, you can translate it. | ||
Let's say that your file containing the french translations is named `messages.fr.xlf` | ||
and is located in the `src/locale` folder. | ||
If you want to use it when you serve your application you can use the 3 following commands: | ||
- `--i18n-file` Localization file to use for i18n. | ||
- `--i18n-format` Format of the localization file specified with --i18n-file. | ||
- `--locale` Locale to use for i18n. | ||
|
||
In our case we can load the french translations with the following command: | ||
```sh | ||
ng serve --aot --locale fr --i18n-format xlf --i18n-file src/locale/messages.fr.xlf | ||
``` | ||
|
||
Our application is exactly the same but the `LOCALE_ID` has been provided with "fr", | ||
`TRANSLATIONS_FORMAT` with "xlf" and `TRANSLATIONS` with the content of `messages.fr.xlf`. | ||
All the strings flagged for i18n have been replaced with their french translations. | ||
|
||
Note: this only works for AOT, if you want to use i18n in JIT you will have to update | ||
your bootstrap file yourself. | ||
|
||
### Build | ||
To build your application with a specific locale you can use the exact same commands | ||
that you used for `serve`: | ||
```sh | ||
ng build --aot --locale fr --i18n-format xlf --i18n-file src/i18n/messages.fr.xlf | ||
``` | ||
|
||
When you build your application for a specific locale, it is probably a good idea to change | ||
the output path with the command `--output-path` in order to save the files to a different location. | ||
|
||
```sh | ||
ng build --aot --output-path dist/fr --locale fr --i18n-format xlf --i18n-file src/i18n/messages.fr.xlf | ||
``` | ||
|
||
If you end up serving this specific version from a subdirectory, you can also change | ||
the base url used by your application with the command `--base-href`. | ||
|
||
For example if the french version of your application is served from https://myapp.com/fr/ | ||
then you would build the french version like this: | ||
|
||
```sh | ||
ng build --aot --output-path dist/fr --base-href fr --locale fr --i18n-format xlf --i18n-file src/i18n/messages.fr.xlf | ||
``` | ||
|
||
If you need more details about how to create scripts to generate the app in multiple | ||
languages and how to setup Apache 2 to serve them from different subdirectories, | ||
you can read [this great tutorial](https://medium.com/@feloy/deploying-an-i18n-angular-app-with-angular-cli-fc788f17e358#.1xq4iy6fp) | ||
by Philippe Martin. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!-- Links in /docs/documentation should NOT have `.md` at the end, because they end up in our wiki at release. --> | ||
|
||
# ng xi18n | ||
|
||
## Overview | ||
`ng xi18n` Extracts i18n messages from the templates. | ||
|
||
## Options | ||
`--i18n-format` (`-f`) Output format for the generated file: either `xmb` or `xlf`. | ||
|
||
`--output-path` (`-op`) Path where output will be placed. | ||
|
||
`--locale` (`-l`) Specifies the source language of the application. | ||
|
||
`--outfile` (`-of`) Name of the file to output. | ||
|
||
`--verbose` Adds more details to output logging. | ||
|
||
`--progress` Log progress to the console while running. | ||
|
||
`--app` (`-a`) Specifies app name to use. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.