| 1 |
# xgotext |
| 2 |
|
| 3 |
CLI tool to extract translation strings from Go packages into .POT files. |
| 4 |
|
| 5 |
## Installation |
| 6 |
|
| 7 |
``` |
| 8 |
go install github.com/leonelquinteros/gotext/cli/xgotext |
| 9 |
``` |
| 10 |
|
| 11 |
## Usage |
| 12 |
|
| 13 |
``` |
| 14 |
Usage of xgotext: |
| 15 |
-default string |
| 16 |
Name of default domain (default "default") |
| 17 |
-exclude string |
| 18 |
Comma separated list of directories to exclude (default ".git") |
| 19 |
-in string |
| 20 |
input dir: /path/to/go/pkg |
| 21 |
-out string |
| 22 |
output dir: /path/to/i18n/files |
| 23 |
``` |
| 24 |
|
| 25 |
## Implementation |
| 26 |
|
| 27 |
This is the first (naive) implementation for this tool. |
| 28 |
|
| 29 |
It will scan the Go package provided for method calls that matches the method names from the gotext package and write the corresponding translation files to the output directory. |
| 30 |
|
| 31 |
Isn't able to parse calls to translation functions using parameters inside variables, if the translation string is inside a variable and that variable is used to invoke the translation function, this tool won't be able to parse that string. See this example code: |
| 32 |
|
| 33 |
```go |
| 34 |
// This line will be added to the .po file |
| 35 |
gotext.Get("Translate this") |
| 36 |
|
| 37 |
tr := "Translate this string" |
| 38 |
// The following line will NOT be added to the .pot file |
| 39 |
gotext.Get(tr) |
| 40 |
``` |
| 41 |
|
| 42 |
The CLI tool traverse sub-directories based on the given input directory. |
| 43 |
|
| 44 |
|
| 45 |
## Contribute |
| 46 |
|
| 47 |
Please |
| 48 |
|