You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, you have to edit your `src/tsconfig.js` file to exclude the `test.ts` file from compilation, and to specify an output directory where your translations files will be extracted:
6
+
7
+
```json
8
+
{
9
+
"compilerOptions": {
10
+
...
11
+
},
12
+
"exclude": [ "test.ts" ],
13
+
"angularCompilerOptions": {
14
+
"genDir": "i18n"
15
+
}
16
+
}
17
+
```
18
+
19
+
You can now extract the i18n-marked texts with the following command:
20
+
21
+
```bash
22
+
$ cd src && ../node_modules/.bin/ng-x18n
23
+
```
24
+
25
+
Alternatively, you can add a script definition to your `package.json` file:
26
+
27
+
```json
28
+
{
29
+
...
30
+
"scripts": {
31
+
...
32
+
"xi18n": "cd src && ng-xi18n"
33
+
},
34
+
...
35
+
}
36
+
```
37
+
38
+
This way, you can now execute the extraction process with this simple command:
39
+
40
+
```bash
41
+
$ npm run xi18n
42
+
```
43
+
44
+
After this extraction process, you will find a `messages.xlf` file in the `src/i18n` directory (or any other directory specified in the `angularCompilerOptions/genDir` option above).
45
+
46
+
You can copy this source file to language-specific files, for example `src/i18n/messages.en.xlf` and `src/i18n/messages.fr.xlf`.
47
+
48
+
49
+
## Serve with AOT compilation
50
+
51
+
When serving your app with AOT compilation, you can specify the language-specific file that you want to use:
52
+
53
+
```bash
54
+
$ ng serve --aot \
55
+
--i18n-file=src/i18n/messages.fr.xlf \
56
+
--locale=fr
57
+
```
58
+
59
+
60
+
## AOT build
61
+
62
+
When building your app with AOT compilation, you can specify the language-specific file to use and a specific output path, to be able to build the different packs for the different languages:
0 commit comments