Skip to content

Commit e6ab2cf

Browse files
committed
docs(README.md): update usage instructions and examples for clarity and accuracy
1. Clarify that the default translation is to English. 2. Remove redundant examples. 3. Change `--output` to `--out` to match actual command. 4. Add `--update` option and detailed example to show how to use it. 5. Expand explanation for `--preserve` option. 6. Remove redundant examples for `--verbose` and `--help` options.
1 parent da05fd6 commit e6ab2cf

File tree

1 file changed

+60
-25
lines changed

1 file changed

+60
-25
lines changed

README.md

+60-25
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ The basic usage of Dragoman is as follows:
4141
dragoman source.json
4242
```
4343

44-
This command will translate the content of `source.json` and print the
45-
translated document to stdout. The source language is automatically detected by
46-
default, but if you want to specify the source or target languages, you need to
47-
use the `--from` or `--to` option.
44+
This command will translate the content of `source.json` to English and print
45+
the translated document to stdout. The source language is automatically detected
46+
by default, but if you want to specify the source or target languages, you need
47+
to use the `--from` or `--to` option.
4848

4949
### Full list of available options
5050

@@ -54,10 +54,8 @@ The source language of the document. It can be specified in any format that a
5454
human would understand (like 'English', 'German', 'French', etc.). If not
5555
provided, it defaults to 'auto', meaning the language is automatically detected.
5656

57-
Example:
58-
5957
```bash
60-
dragoman source.json --from English --to French
58+
dragoman source.json --from English
6159
```
6260

6361
**`-t` or `--to`**
@@ -66,46 +64,85 @@ The target language to which the document will be translated. It can be
6664
specified in any format that a human would understand (like 'English', 'German',
6765
'French', etc.). If not provided, it defaults to 'English'.
6866

69-
Example:
70-
7167
```bash
7268
dragoman source.json --to French
7369
```
7470

75-
**`-o` or `--output`**
71+
**`-o` or `--out`**
7672

7773
The path to the output file where the translated content will be saved. If this
7874
option is not provided, the translated content will be printed to stdout.
7975

80-
Example:
76+
```bash
77+
dragoman source.json --out target.json
78+
```
79+
80+
**`-u` or `--update`**
81+
82+
Enable this option to only translate missing fields from the source file that
83+
are missing in the output file. This option requires the source and output files
84+
to be JSON!
8185

8286
```bash
83-
dragoman source.json --output target.json
87+
dragoman source.json --out target.json --update
8488
```
8589

86-
**`-p` or `--preserve`**
90+
#### Example
8791

88-
A comma-separated list of words or terms that should not be translated.
89-
The preserved words will be recognized not only as stand-alone words but also as
90-
part of larger expressions. This could be useful, for example, when the known
91-
word is embedded within HTML tags or combined with other words.
92+
When you add new translations to your JSON source file, you can use the `--update`
93+
option to only translate the newly added fields and merge them into the output file.
9294

93-
Example:
95+
```json
96+
// en.json
97+
{
98+
"hello": "Hello, world!",
99+
"contact": {
100+
"email": "[email protected]",
101+
"response": "Thank you for your message."
102+
}
103+
}
104+
```
105+
106+
```json
107+
// de.json
108+
{
109+
"hello": "Hallo, Welt!",
110+
"contact": {
111+
"email": "[email protected]"
112+
}
113+
}
114+
```
94115

95116
```bash
96-
dragoman source.json --preserve Dragoman
117+
dragoman en.json --out de.json --update
97118
```
98119

99-
In this example, a term like `<span class="font-bold">Drago</span>man` will not
100-
be translated.
120+
Result:
121+
122+
```json
123+
// de.json
124+
{
125+
"hello": "Hallo, Welt!",
126+
"contact": {
127+
"email": "[email protected]",
128+
"response": "Vielen Dank für deine Nachricht."
129+
}
130+
}
131+
```
132+
133+
**`-p` or `--preserve`**
134+
135+
This option allows you to specify a list of specific words or phrases, separated by commas, that you want to remain unchanged during the translation process. It's particularly useful for ensuring that certain terms, which may have significance in their original form or are used in specific contexts (like code, trademarks, or names), are not altered. These specified terms will be recognized and preserved whether they appear in isolation or as part of larger strings. This feature is especially handy for content that includes embedded terms within other elements, such as HTML tags. For instance, using --preserve ensures that a term like <span class="font-bold">Drago</span>man retains its original form post-translation. Note that the effectiveness of this feature may vary depending on the language model used, and it is optimized for use with OpenAI's GPT models.
136+
137+
```bash
138+
dragoman source.json --preserve Dragoman
139+
```
101140

102141
**`-v` or `--verbose`**
103142

104143
A flag that, if provided, makes the CLI provide more detailed output about the
105144
process and result of the translation.
106145

107-
Example:
108-
109146
```bash
110147
dragoman source.json --verbose
111148
```
@@ -114,8 +151,6 @@ dragoman source.json --verbose
114151

115152
A flag that displays a help message detailing how to use the command and its options.
116153

117-
Example:
118-
119154
```bash
120155
dragoman --help
121156
```

0 commit comments

Comments
 (0)