Skip to content

Commit

Permalink
Merge pull request #30 from maximilien/issue28
Browse files Browse the repository at this point in the history
Issue28: rename executable to i18n4go
  • Loading branch information
maximilien committed Apr 9, 2015
2 parents 018c59e + 8cd1f3c commit f2c0073
Show file tree
Hide file tree
Showing 23 changed files with 205 additions and 204 deletions.
136 changes: 68 additions & 68 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ $ ./bin/build

NOTE: if you get any dependency errors, then use `go get path/to/dependency` to get it, e.g., `go get github.com/onsi/ginkgo` and `go get github.com/onsi/gomega`

The executable output should now be located in: `out/gi18n`. Place it wherever you want, e.g., `/usr/local/bin` on Linux or Mac OS X.
The executable output should now be located in: `out/i18n4go`. Place it wherever you want, e.g., `/usr/local/bin` on Linux or Mac OS X.

You can now use the `gi18n` executable to issue some of the typical i18n tooling processes.
You can now use the `i18n4go` executable to issue some of the typical i18n tooling processes.

### Running Tests
-----------------
Expand Down Expand Up @@ -89,21 +89,21 @@ For instance to create `fr_FR` file(s) for French and every other locale_Languag
### Help
--------

Printing the usage help: `$ gi18n -h` or `$ gi18n --help`
Printing the usage help: `$ i18n4go -h` or `$ i18n4go --help`

```
usage: gi18n -c extract-strings [-vpe] [--dry-run] [--output-flat|--output-match-package|-o <outputDir>] -f <fileName>
or: gi18n -c extract-strings [-vpe] [--dry-run] [--output-flat|--output-match-package|-o <outputDir>] -d <dirName> [-r] [--ignore-regexp <fileNameRegexp>]
usage: i18n4go -c extract-strings [-vpe] [--dry-run] [--output-flat|--output-match-package|-o <outputDir>] -f <fileName>
or: i18n4go -c extract-strings [-vpe] [--dry-run] [--output-flat|--output-match-package|-o <outputDir>] -d <dirName> [-r] [--ignore-regexp <fileNameRegexp>]
usage: gi18n -c rewrite-package [-v] [-r] -d <dirName> [--i18n-strings-filename <fileName> | --i18n-strings-dirname <dirName>]
or: gi18n -c rewrite-package [-v] [-r] -f <fileName> --i18n-strings-filename <fileName>
usage: i18n4go -c rewrite-package [-v] [-r] -d <dirName> [--i18n-strings-filename <fileName> | --i18n-strings-dirname <dirName>]
or: i18n4go -c rewrite-package [-v] [-r] -f <fileName> --i18n-strings-filename <fileName>
usage: gi18n -c merge-strings [-v] [-r] [--source-language <language>] -d <dirName>
usage: i18n4go -c merge-strings [-v] [-r] [--source-language <language>] -d <dirName>
usage: gi18n -c verify-strings [-v] [--source-language <language>] -f <sourceFileName> --language-files <language files>
or: gi18n -c verify-strings [-v] [--source-language <language>] -f <sourceFileName> --languages <lang1,lang2,...>
usage: i18n4go -c verify-strings [-v] [--source-language <language>] -f <sourceFileName> --language-files <language files>
or: i18n4go -c verify-strings [-v] [--source-language <language>] -f <sourceFileName> --languages <lang1,lang2,...>
usage: gi18n -c create-translations [-v] [--google-translate-api-key <api key>] [--source-language <language>] -f <fileName> --languages <lang1,lang2,...> -o <outputDir>
usage: i18n4go -c create-translations [-v] [--google-translate-api-key <api key>] [--source-language <language>] -f <fileName> --languages <lang1,lang2,...> -o <outputDir>
-h | --help prints the usage
-v verbose
Expand Down Expand Up @@ -142,9 +142,9 @@ The general usage for `-extract-strings` command is:
The command `-c extract-strings` pulls strings out of go files. For the examples below we are running the tool on a copy of the the [CloudFoundry CLI](https://github.com/cloudfoundry/cli) cloned in the `./tmp`

```
$ gi18n -c extract-strings -v --po -f ./tmp/cli/cf/app/app.go -o ./tmp/cli/i18n -output-match-package
$ i18n4go -c extract-strings -v --po -f ./tmp/cli/cf/app/app.go -o ./tmp/cli/i18n -output-match-package
gi18n: extracting strings from file: ./tmp/cli/cf/app/app.go
i18n4go: extracting strings from file: ./tmp/cli/cf/app/app.go
Could not find: excluded.json
Loaded 0 excluded strings
Could not find: excluded.json
Expand Down Expand Up @@ -194,7 +194,7 @@ msgstr "%s help [COMMAND]"
To extract multiples files that are in one directory, use the following:

```
$ gi18n -c extract-strings -v --po -d ./tmp/cli/cf/app/ -o ./tmp/cli/i18n -output-match-package -ignore-regexp ".*test.*"
$ i18n4go -c extract-strings -v --po -d ./tmp/cli/cf/app/ -o ./tmp/cli/i18n -output-match-package -ignore-regexp ".*test.*"
...
```
Expand All @@ -221,12 +221,12 @@ The general usage for `-merge-strings` command is:
The command `-c merge-strings` combines strings in multiple `*.go.[lang].json` files generated by `Extract Strings` into one file. Using the same example source as above.

```
$ gi18n -c merge-strings -v -d ./tmp/cli/i18n/app -source-language en
$ i18n4go -c merge-strings -v -d ./tmp/cli/i18n/app -source-language en
gi18n: scanning file: tmp/cli/i18n/app/app.go.en.json
gi18n: scanning file: tmp/cli/i18n/app/flag_helper.go.en.json
gi18n: scanning file: tmp/cli/i18n/app/help.go.en.json
gi18n: saving combined language file: tmp/cli/i18n/app/en.all.json
i18n4go: scanning file: tmp/cli/i18n/app/app.go.en.json
i18n4go: scanning file: tmp/cli/i18n/app/flag_helper.go.en.json
i18n4go: scanning file: tmp/cli/i18n/app/help.go.en.json
i18n4go: saving combined language file: tmp/cli/i18n/app/en.all.json
Total time: 1.283116ms
```

Expand Down Expand Up @@ -259,11 +259,11 @@ The command `-c rewrite-package` will modify the go source files such that every
a. running it on one source file

```
$ gi18n -c rewrite-package -v -f tmp/cli/cf/app/help.go -i18n-strings-dirname tmp/cli/i18n/app/ -o tmp/cli/cf/app/
$ i18n4go -c rewrite-package -v -f tmp/cli/cf/app/help.go -i18n-strings-dirname tmp/cli/i18n/app/ -o tmp/cli/cf/app/
gi18n: rewriting strings for source file: tmp/cli/cf/app/help.go
gi18n: adding init func to package: app to output dir: tmp/cli/cf/app
gi18n: inserting T() calls for strings that need to be translated
i18n4go: rewriting strings for source file: tmp/cli/cf/app/help.go
i18n4go: adding init func to package: app to output dir: tmp/cli/cf/app
i18n4go: inserting T() calls for strings that need to be translated
saving file to path tmp/cli/cf/app/help.go
Total files parsed: 1
Expand All @@ -274,24 +274,24 @@ Total time: 9.986963ms
b. running it on a directory

```
$ gi18n -c rewrite-package -v -d tmp/cli/cf/app/ -i18n-strings-dirname tmp/cli/i18n/app/ -o tmp/cli/cf/app/
$ i18n4go -c rewrite-package -v -d tmp/cli/cf/app/ -i18n-strings-dirname tmp/cli/i18n/app/ -o tmp/cli/cf/app/
gi18n: rewriting strings in dir tmp/cli/cf/app/, recursive: false
i18n4go: rewriting strings in dir tmp/cli/cf/app/, recursive: false
gi18n: loading JSON strings from file: tmp/cli/i18n/app/app.go.en.json
gi18n: rewriting strings for source file: tmp/cli/cf/app/app.go
gi18n: adding init func to package: app to output dir: tmp/cli/cf/app
gi18n: inserting T() calls for strings that need to be translated
i18n4go: loading JSON strings from file: tmp/cli/i18n/app/app.go.en.json
i18n4go: rewriting strings for source file: tmp/cli/cf/app/app.go
i18n4go: adding init func to package: app to output dir: tmp/cli/cf/app
i18n4go: inserting T() calls for strings that need to be translated
saving file to path tmp/cli/cf/app/app.go
gi18n: loading JSON strings from file: tmp/cli/i18n/app/flag_helper.go.en.json
gi18n: rewriting strings for source file: tmp/cli/cf/app/flag_helper.go
gi18n: adding init func to package: app to output dir: tmp/cli/cf/app
gi18n: inserting T() calls for strings that need to be translated
i18n4go: loading JSON strings from file: tmp/cli/i18n/app/flag_helper.go.en.json
i18n4go: rewriting strings for source file: tmp/cli/cf/app/flag_helper.go
i18n4go: adding init func to package: app to output dir: tmp/cli/cf/app
i18n4go: inserting T() calls for strings that need to be translated
saving file to path tmp/cli/cf/app/flag_helper.go
gi18n: loading JSON strings from file: tmp/cli/i18n/app/help.go.en.json
gi18n: rewriting strings for source file: tmp/cli/cf/app/help.go
gi18n: adding init func to package: app to output dir: tmp/cli/cf/app
gi18n: inserting T() calls for strings that need to be translated
i18n4go: loading JSON strings from file: tmp/cli/i18n/app/help.go.en.json
i18n4go: rewriting strings for source file: tmp/cli/cf/app/help.go
i18n4go: adding init func to package: app to output dir: tmp/cli/cf/app
i18n4go: inserting T() calls for strings that need to be translated
saving file to path tmp/cli/cf/app/help.go
Total files parsed: 3
Expand Down Expand Up @@ -336,22 +336,22 @@ The general usage for `-c create-translations` command is:
The command `-create-translations` generates copies of the `-source-language` file, one per language specified in the `-languages` flag (seperated by comma).

```
$ gi18n -create-translations -v -f tmp/cli/i18n/app/en.all.json -source-language en -languages "en_US,fr_FR,es_ES,de_DE" -o tmp/cli/i18n/app/
$ i18n4go -create-translations -v -f tmp/cli/i18n/app/en.all.json -source-language en -languages "en_US,fr_FR,es_ES,de_DE" -o tmp/cli/i18n/app/
gi18n: creating translation files for: tmp/cli/i18n/app/en.all.json
i18n4go: creating translation files for: tmp/cli/i18n/app/en.all.json
gi18n: creating translation file copy for language: en_US
gi18n: creating translation file: tmp/cli/i18n/app/en_US.all.json
gi18n: created default translation file: tmp/cli/i18n/app/en_US.all.json
gi18n: creating translation file copy for language: fr_FR
gi18n: creating translation file: tmp/cli/i18n/app/fr_FR.all.json
gi18n: created default translation file: tmp/cli/i18n/app/fr_FR.all.json
gi18n: creating translation file copy for language: es_ES
gi18n: creating translation file: tmp/cli/i18n/app/es_ES.all.json
gi18n: created default translation file: tmp/cli/i18n/app/es_ES.all.json
gi18n: creating translation file copy for language: de_DE
gi18n: creating translation file: tmp/cli/i18n/app/de_DE.all.json
gi18n: created default translation file: tmp/cli/i18n/app/de_DE.all.json
i18n4go: creating translation file copy for language: en_US
i18n4go: creating translation file: tmp/cli/i18n/app/en_US.all.json
i18n4go: created default translation file: tmp/cli/i18n/app/en_US.all.json
i18n4go: creating translation file copy for language: fr_FR
i18n4go: creating translation file: tmp/cli/i18n/app/fr_FR.all.json
i18n4go: created default translation file: tmp/cli/i18n/app/fr_FR.all.json
i18n4go: creating translation file copy for language: es_ES
i18n4go: creating translation file: tmp/cli/i18n/app/es_ES.all.json
i18n4go: created default translation file: tmp/cli/i18n/app/es_ES.all.json
i18n4go: creating translation file copy for language: de_DE
i18n4go: creating translation file: tmp/cli/i18n/app/de_DE.all.json
i18n4go: created default translation file: tmp/cli/i18n/app/de_DE.all.json
Total time: 2.143251ms
```
Expand Down Expand Up @@ -385,31 +385,31 @@ had a `./tmp/cli/i18n/app/fr.all.json` for French and that file had missing stri
`tmp/cli/i18n/app/fr.all.json.missing.diff.json`, as in the following:

```
$ gi18n -c verify-strings -v -f tmp/cli/i18n/app/en.all.json -languages "fr"
$ i18n4go -c verify-strings -v -f tmp/cli/i18n/app/en.all.json -languages "fr"
targetFilenames: [tmp/cli/i18n/app/fr.all.json]
gi18n: ERROR input file does not match target file: tmp/cli/i18n/app/fr.all.json
gi18n: generated diff file: tmp/cli/i18n/app/fr.all.json.missing.diff.json
gi18n: Error verifying target filename: tmp/cli/i18n/app/fr.all.json
gi18n: Could not verify strings for input filename, err: gi18n: target file is missing i18n strings with IDs: --,'%v',-
i18n4go: ERROR input file does not match target file: tmp/cli/i18n/app/fr.all.json
i18n4go: generated diff file: tmp/cli/i18n/app/fr.all.json.missing.diff.json
i18n4go: Error verifying target filename: tmp/cli/i18n/app/fr.all.json
i18n4go: Could not verify strings for input filename, err: i18n4go: target file is missing i18n strings with IDs: --,'%v',-
```

Similarly, `verify-strings` will make sure that no additonal strings are added. So if we had an additional German `de.all.json` file that included additional strings
running `verify-strings` would include a `tmp/cli/i18n/app/de.all.json.extra.diff.json`.

```
$ gi18n -v -verify-strings -f tmp/cli/i18n/app/en.all.json -languages "fr,de"
$ i18n4go -v -verify-strings -f tmp/cli/i18n/app/en.all.json -languages "fr,de"
targetFilenames: [tmp/cli/i18n/app/fr.all.json tmp/cli/i18n/app/de.all.json]
gi18n: ERROR input file does not match target file: tmp/cli/i18n/app/fr.all.json
gi18n: generated diff file: tmp/cli/i18n/app/fr.all.json.missing.diff.json
gi18n: Error verifying target filename: tmp/cli/i18n/app/fr.all.json
gi18n: WARNING target file has extra key with ID: advanced
gi18n: WARNING target file has extra key with ID: apps
gi18n: WARNING target file contains total of extra keys: 2
gi18n: generated diff file: tmp/cli/i18n/app/de.all.json.extra.diff.json
gi18n: Error verifying target filename: tmp/cli/i18n/app/de.all.json
gi18n: Could not verify strings for input filename, err: gi18n: target file has extra i18n strings with IDs: advanced,apps
i18n4go: ERROR input file does not match target file: tmp/cli/i18n/app/fr.all.json
i18n4go: generated diff file: tmp/cli/i18n/app/fr.all.json.missing.diff.json
i18n4go: Error verifying target filename: tmp/cli/i18n/app/fr.all.json
i18n4go: WARNING target file has extra key with ID: advanced
i18n4go: WARNING target file has extra key with ID: apps
i18n4go: WARNING target file contains total of extra keys: 2
i18n4go: generated diff file: tmp/cli/i18n/app/de.all.json.extra.diff.json
i18n4go: Error verifying target filename: tmp/cli/i18n/app/de.all.json
i18n4go: Could not verify strings for input filename, err: i18n4go: target file has extra i18n strings with IDs: advanced,apps
```

Finally, if a combined language file contains both extra and missing keys then `verify-strings` will generate two diff files: `missing` and `extra`.
Expand Down Expand Up @@ -440,7 +440,7 @@ to the generated files from extracted strings.
As an example run, generate an extracted string files useing the command:

```
$ gi18n -c extract-strings -p -d ./tmp/cli/cf/app/ -o ./tmp/cli/i18n -output-match-package -ignore-regexp ".*test.*" -e ./example/excluded.json
$ i18n4go -c extract-strings -p -d ./tmp/cli/cf/app/ -o ./tmp/cli/i18n -output-match-package -ignore-regexp ".*test.*" -e ./example/excluded.json
```

If we inspect the `./tmp/cli/i18n/app/app.go.en.json` file there should not be an entry for `"id": "help"`, but you should still see an entry for `"id": "show help"`
Expand All @@ -463,7 +463,7 @@ As an example for regular expressions, let us consider the `^json:`. This expres
`./tmp/cli/cf/api/resources/events.go` file such as: `ExitDescription string `json:"exit_description"`. After running the command:

```
$ gi18n -c extract-strings -v -d ./tmp/cli/cf/api/resources -o ./tmp/cli/i18n -output-match-package -ignore-regexp ".*test.*" -e ./example/excluded.json
$ i18n4go -c extract-strings -v -d ./tmp/cli/cf/api/resources -o ./tmp/cli/i18n -output-match-package -ignore-regexp ".*test.*" -e ./example/excluded.json
```

We can inspect the `./tmp/cli/i18n/resources/events.go.en.json` file and see that there are no strings with the expression `json:`.
Expand Down
2 changes: 1 addition & 1 deletion bin/build
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ echo -e "\n Formatting packages..."
go fmt ./...

echo -e "\nGenerating Binary..."
go build -o $(dirname $0)/../out/gi18n ./gi18n/gi18n.go
go build -o $(dirname $0)/../out/i18n4go ./i18n4go/i18n4go.go
Loading

0 comments on commit f2c0073

Please sign in to comment.