gotext/cli/xgotext
Leonel Quinteros d32dc82045
Merge pull request #83 from didrocks/fix-location-order
Order locations in ascii order
2023-08-29 12:40:39 -03:00
..
fixtures Add more test cases and refresh tests for pot generation 2023-07-26 13:05:46 +02:00
parser Merge pull request #83 from didrocks/fix-location-order 2023-08-29 12:40:39 -03:00
main.go load package tree once and traverse 2021-09-16 19:02:06 +03:00
README.md xgotext: updated README.md 2020-02-29 11:42:35 +01:00

xgotext

CLI tool to extract translation strings from Go packages into .POT files.

Installation

go install github.com/leonelquinteros/gotext/cli/xgotext

Usage

Usage of xgotext:
  -default string
        Name of default domain (default "default")
  -exclude string
        Comma separated list of directories to exclude (default ".git")
  -in string
        input dir: /path/to/go/pkg
  -out string
        output dir: /path/to/i18n/files

Implementation

This is the first (naive) implementation for this tool.

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.

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:

// This line will be added to the .po file
gotext.Get("Translate this")

tr := "Translate this string"
// The following line will NOT be added to the .pot file
gotext.Get(tr)

The CLI tool traverse sub-directories based on the given input directory.

Contribute

Please