- Angular CLI - Code Coverage
- Angular CLI - ng xi18n
- Angular CLI - ng update
- Angular CLI - ng doc
- Angular CLI - ng config
- Angular CLI - ng analytics
- Angular CLI - ng add
- Angular CLI - ng e2e
- Angular CLI - ng test
- Angular CLI - ng lint
- Angular CLI - ng serve
- Angular CLI - ng run
- Angular CLI - ng build
- Angular CLI - ng generate
- Angular CLI - ng help
- Angular CLI - ng new
- Angular CLI - ng version
- Angular CLI - Environment Setup
- Angular CLI - Overview
- Angular CLI - Home
Angular CLI Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Angular CLI - ng xi18n Command
This chapter explains the syntax, arguments and options of ng xi18n command along with an example.
Syntax
The syntax for ng xi18n command is as follows −
ng xi18n <project> [options] ng i18n-extract <project> [options]
ng xi18n command extracts i18n messages from source code.
Arguments
The argument for ng xi18n command is as follows −
Sr.No. | Argument & Syntax | Description |
---|---|---|
1 | <project> | The name of the project. It can be an apppcation or pbrary. |
Options
Options are optional parameters.
Sr.No. | Option & Syntax | Description |
---|---|---|
1 | --browserTarget=browserTarget | Target to extract from. |
2 | --configuration=configuration | A named build target, as specified in the "configurations" section of angular.json. Each named target is accompanied by a configuration of option defaults for that target. Setting this exppcitly overrides the "--prod" flag. Apases: -c |
3 | --createCommits=true|false |
Create source control commits for updates and migrations. Default: false Apases: -C |
4 | --format=xmb|xlf|xpf|xpff|xlf2|xpff2 |
Output format for the generated file. Default: xlf |
5 | --help=true|false|json|JSON |
Shows a help message for this command in the console. Default: false |
6 | --outFile=outFile | Name of the file to output. |
7 | --outputPath=outputPath | Path where output will be placed. |
8 | --prod=true|false | Shorthand for "--configuration=production". When true, sets the build configuration to the production target. By default, the production target is set up in the workspace configuration such that all builds make use of bundpng, pmited tree-shaking, and also pmited dead code epmination. |
9 | --progress=true|false |
Log progress to the console. Default: true |
First move to an angular project updated using ng build command. The chapter is available at
Update the app.component.html as follows −
app.component.spec.ts
<span class="content" role="main"> <span i18n>app is running!</span> </span> <app-goals></app-goals> <router-outlet></router-outlet>
Now run the xi18n command.
Example
An example for ng xi18n command is given below −
>Node>TutorialsPoint> ng xi18n
Add locapzation support.
>Node>TutorialsPoint> ng add @angular/locapze Instalpng packages for toopng via npm. Installed packages for toopng via npm. UPDATE src/polyfills.ts (3064 bytes)
Now ng will create a messages.xlf file in root folder which is a industry standard translation file.
messages.xlf
<?xml version="1.0" encoding="UTF-8" ?> <xpff version="1.2" xmlns="urn:oasis:names:tc:xpff:document:1.2"> <file source-language="en-US" datatype="plaintext" original="ng2.template"> <body> <trans-unit id="6226cbeebaffaec0342459915ef7d9b0e9e92977" datatype="html"> <source>app is running!</source> <context-group purpose="location"> <context context-type="sourcefile">src/app/app.component.html</context> <context context-type="pnenumber">2</context> </context-group> </trans-unit> </body> </file> </xpff>Advertisements