Skip to content

Commit c62c74f

Browse files
committed
docs: about converting xlf->json
1 parent 8ce2aeb commit c62c74f

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

README.md

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ A simple UI for your translations: hosted on NPM, runs on your dev machine.
2323

2424
## Installation
2525

26-
```
26+
```shell
2727
$ npm i @novyk/ngxe -D
2828
```
2929

@@ -54,7 +54,7 @@ $ npm i @novyk/ngxe -D
5454

5555
#### Extract translations from your project in JSON format:
5656

57-
```
57+
```shell
5858
$ ng extract-i18n --format=json
5959
```
6060

@@ -68,7 +68,7 @@ $localize`:@@MSG_ID_2:Message with ID 2`;
6868

6969
#### Use ngxe:
7070

71-
```
71+
```shell
7272
$ npx ngxe
7373
```
7474

@@ -78,7 +78,7 @@ Use the ngxe app to update messages and press `Save Project` (all `output` files
7878

7979
###### Optional config path:
8080

81-
```
81+
```shell
8282
$ npx ngxe -p=./path/to/ngxe.json
8383
```
8484

@@ -87,7 +87,7 @@ $ npx ngxe -p=./path/to/ngxe.json
8787
1. You can use the default flow with separated build for each lang.
8888
2. **Or** import messages on the app bootstrapping in `main.ts`:
8989

90-
```
90+
```ts
9191
import { loadTranslations } from '@angular/localize';
9292

9393
...
@@ -106,6 +106,28 @@ async function loadMessages() {
106106
}
107107
```
108108

109+
109110
## Config
110111

111112
Interface of the `ngxe.json` file: [meta/config.ts](/projects/meta/config.ts)
113+
114+
115+
## Convert existing `xlf` files to `json`
116+
117+
```shell
118+
$ npm i @locl/cli -D
119+
$ npx locl convert -s=path/to/messages.de.xlf -f=json -o=path/to/messages.de.json
120+
```
121+
122+
You can get error: `The translation file "path/to/messages.de.xlf" does not contain a target locale and no explicit locale was provided for this file.`
123+
124+
Make sure you have the `target-language` attribute in `xlf` file:
125+
126+
```xml
127+
<?xml version="1.0" encoding="UTF-8" ?>
128+
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
129+
<file source-language="en" target-language="de" ...>
130+
...
131+
```
132+
133+
After that you can delete `@locl/cli` package.

0 commit comments

Comments
 (0)