@@ -39,37 +39,38 @@ need the `msgmerge` and `msgcat` Gettext tool installed. Please see our
39
39
40
40
First, you need to know how to update the ` .pot ` and ` .po ` files.
41
41
42
- You should never touch the auto-generated ` po/messages.pot ` file. You should
43
- also not never the ` msgid ` entries in a ` po/xx.po ` file. If you find mistakes,
44
- you need to update the original English text instead. The fixes to the English
45
- text will flow into the ` .po ` files the next time the translators update them.
42
+ You should never touch the auto-generated ` book/xgettext/messages.pot ` file. You
43
+ should also not never the ` msgid ` entries in a ` po/xx.po ` file. If you find
44
+ mistakes, you need to update the original English text instead. The fixes to the
45
+ English text will flow into the ` .po ` files the next time the translators update
46
+ them.
46
47
47
48
> ** Tip:** See our [ style guide] ( STYLE.md ) for some things to keep in mind when
48
49
> writing the translation.
49
50
50
51
### Generating the PO Template
51
52
52
- To extract the original English text and generate a ` messages.pot ` file, you run
53
- ` mdbook ` with a special renderer:
53
+ To extract the original English text and generate a ` messages.pot ` file, you
54
+ build the book. This will automatically invoke the ` mdbook-xgettext ` renderer:
54
55
55
56
``` shell
56
- MDBOOK_OUTPUT=' {"xgettext": {"pot-file": "messages.pot", "granularity": 0}}' \
57
- mdbook build -d po
57
+ mdbook build
58
58
```
59
59
60
- You will find the generated POT file as ` po /messages.pot` .
60
+ You will find the generated POT file as ` book/xgettext /messages.pot` .
61
61
62
62
### Initialize a New Translation
63
63
64
- To start a new translation, first generate the ` po/messages.pot ` file. Then use
65
- ` msginit ` to create a ` xx.po ` file for the fictional ` xx ` language:
64
+ To start a new translation, first generate the ` book/xgettext/messages.pot `
65
+ file. Then use ` msginit ` to create a ` xx.po ` file for the fictional ` xx `
66
+ language:
66
67
67
68
``` shell
68
- msginit -i po /messages.pot -l xx -o po/xx.po
69
+ msginit -i book/xgettext /messages.pot -l xx -o po/xx.po
69
70
```
70
71
71
- You can also simply copy ` po/ messages.pot` to ` po/xx.po ` . Then update the file
72
- header (the first entry with ` msgid "" ` ) to the correct language.
72
+ You can also simply copy ` book/xgettext/ messages.pot` to ` po/xx.po ` . Then update
73
+ the file header (the first entry with ` msgid "" ` ) to the correct language.
73
74
74
75
> ** Tip:** You can use the
75
76
> [ ` cloud-translate ` ] ( https://github.com/mgeisler/cloud-translate ) tool to
@@ -98,10 +99,10 @@ translations contain a POT-Creation-Date header which tells you when they were
98
99
last updated with new English messages.
99
100
100
101
To update the ` po/xx.po ` file with new messages, first extract the English text
101
- into a ` po /messages.pot` template file. Then run
102
+ into a ` book/xgettext /messages.pot` template file. Then run
102
103
103
104
``` shell
104
- msgmerge --update po/xx.po po /messages.pot
105
+ msgmerge --update po/xx.po book/xgettext /messages.pot
105
106
```
106
107
107
108
Notice that the POT-Creation-Date field is updated to the current time and date.
@@ -162,9 +163,8 @@ To use the `po/xx.po` file for your output, run the following command:
162
163
MDBOOK_BOOK__LANGUAGE=xx mdbook build -d book/xx
163
164
```
164
165
165
- This will update the book's language to ` xx ` , it will make the ` mdbook-gettext `
166
- preprocessor become active and tell it to use the ` po/xx.po ` file, and finally
167
- it will redirect the output to ` book/xx ` .
166
+ This will tell the ` mdbook-gettext ` preprocessor to translate the book using the
167
+ ` po/xx.po ` file. The HTML output can be found in ` book/xx/html/ ` .
168
168
169
169
### Serving a Translation
170
170
0 commit comments