├── .github ├── dependabot.yml └── workflows │ ├── codeql-analysis.yml │ ├── go.yml │ ├── greetings.yml │ └── stale.yml ├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── bin ├── build ├── clean ├── run ├── test └── validate ├── docs ├── blog_post1.md ├── i18n4go.graffle └── images │ └── typical-workflow.png ├── examples ├── demo1-i18n │ ├── build │ ├── demo1.go │ ├── demo1.go.en.json │ ├── en.all.json │ ├── excluded.json │ ├── generate-language-resources │ ├── i18n │ │ └── resources │ │ │ ├── de.all.json │ │ │ ├── de_DE.all.json │ │ │ ├── en_US.all.json │ │ │ ├── es.all.json │ │ │ ├── es_ES.all.json │ │ │ ├── fr.all.json │ │ │ ├── fr_FR.all.json │ │ │ ├── zh.all.json │ │ │ └── zh_Hans.all.json │ ├── i18n_init.go │ └── i18n_resources.go ├── demo1 │ ├── build │ ├── demo1.go │ ├── demo1_script.txt │ ├── excluded.json │ └── generate-language-resources ├── excluded │ └── excluded.json └── i18n_init │ └── cf_cli_i18n_init.go.template ├── go.mod ├── go.sum ├── i18n4go ├── cmds │ ├── checkup.go │ ├── cmd_interface.go │ ├── create_translations.go │ ├── extract_strings.go │ ├── fixup.go │ ├── merge_string.go │ ├── rewrite_package.go │ ├── show_missing_strings.go │ ├── types.go │ ├── verify_strings.go │ └── version.go ├── common │ ├── ast.go │ ├── cmd.go │ └── common.go ├── i18n │ ├── excluded.json │ ├── i18n_init.go │ ├── i18n_init.go.template │ ├── i18n_resources.go │ ├── init.go │ └── resources │ │ └── all.en_US.json └── i18n4go.go ├── integration ├── checkup │ ├── checkup_suite_test.go │ └── checkup_test.go ├── create_translations │ ├── create_translations_suite_test.go │ └── f_option_test.go ├── extract_strings │ ├── d_option_test.go │ ├── extract_strings_suite_test.go │ ├── f_o_options_test.go │ ├── f_option_test.go │ └── s_option_test.go ├── fixup │ ├── fixup_suite_test.go │ └── fixup_test.go ├── merge_strings │ ├── d_option_test.go │ ├── merge_strings_suite_test.go │ ├── r_option_test.go │ └── source_language_test.go ├── rewrite_package │ ├── d_option_test.go │ ├── f_option_test.go │ ├── i18n_strings_filename_test.go │ ├── init_code_snippet_filename_test.go │ └── suite_test.go ├── show_missing_strings │ ├── d_option_test.go │ └── show_missing_strings_suite_test.go ├── test_helpers │ ├── build_executable.go │ └── helpers.go └── verify_strings │ ├── duplicate_keys_test.go │ ├── f_option_test.go │ └── verify_strings_suite_test.go ├── slack ├── badge.svg ├── slack.png └── slackin.js └── test_fixtures ├── checkup ├── allgood │ ├── src │ │ └── code │ │ │ └── main.go │ └── translations │ │ ├── en_US.all.json │ │ └── zh_CN.all.json ├── fileformat │ ├── src │ │ └── code │ │ │ └── main.go │ └── translations │ │ ├── all.en_US.json │ │ └── all.zh_CN.json ├── notsogood │ ├── src │ │ └── code │ │ │ ├── main.go │ │ │ └── mypackage │ │ │ └── thing.go │ └── translations │ │ ├── en_US.all.json │ │ └── zh_CN.all.json ├── qualified │ ├── src │ │ └── code │ │ │ └── main.go │ └── translations │ │ ├── en_US.all.json │ │ └── zh_CN.all.json └── variable │ ├── src │ └── code │ │ └── main.go │ └── translations │ ├── en_US.all.json │ └── zh_CN.all.json ├── create_translations └── f_option │ └── input_files │ ├── quota.go.en.json │ └── quota.go.ja.json ├── extract_strings ├── d_option │ ├── expected_output │ │ ├── create_org.go.en.json │ │ ├── create_org.go.en.po │ │ ├── create_org.go.extracted.json │ │ ├── create_quota.go.en.json │ │ ├── create_quota.go.en.po │ │ ├── create_quota.go.extracted.json │ │ ├── delete_org.go.en.json │ │ ├── delete_org.go.en.po │ │ ├── delete_org.go.extracted.json │ │ ├── delete_quota.go.en.json │ │ ├── delete_quota.go.en.po │ │ ├── delete_quota.go.extracted.json │ │ ├── org.go.en.json │ │ ├── org.go.en.po │ │ ├── org.go.extracted.json │ │ ├── orgs.go.en.json │ │ ├── orgs.go.en.po │ │ ├── orgs.go.extracted.json │ │ ├── quota.go.en.json │ │ ├── quota.go.en.po │ │ ├── quota.go.extracted.json │ │ ├── quotas.go.en.json │ │ ├── quotas.go.en.po │ │ ├── quotas.go.extracted.json │ │ ├── rename_org.go.en.json │ │ ├── rename_org.go.en.po │ │ ├── rename_org.go.extracted.json │ │ ├── set_quota.go.en.json │ │ ├── set_quota.go.en.po │ │ ├── set_quota.go.extracted.json │ │ ├── update_quota.go.en.json │ │ ├── update_quota.go.en.po │ │ └── update_quota.go.extracted.json │ └── input_files │ │ ├── org │ │ ├── create_org.go │ │ ├── delete_org.go │ │ ├── org.go │ │ ├── orgs.go │ │ ├── rename_org.go │ │ └── set_quota.go │ │ └── quota │ │ ├── create_quota.go │ │ ├── delete_quota.go │ │ ├── quota.go │ │ ├── quotas.go │ │ └── update_quota.go ├── f_option │ ├── expected_output │ │ ├── app.go.en.json │ │ ├── app.go.en.po │ │ ├── app.go.extracted.json │ │ ├── app │ │ │ ├── app.go.en.json │ │ │ ├── app.go.en.po │ │ │ └── app.go.extracted.json │ │ ├── issue16.go.en.json │ │ ├── issue4.go.en.json │ │ └── issue45.go.en.json │ └── input_files │ │ ├── app.go │ │ ├── issue16.go │ │ ├── issue4.go │ │ ├── issue45.go │ │ └── no_strings.go └── s_option │ ├── expected_output │ └── app.go.en.json │ └── input_files │ ├── app │ └── app.go │ └── matching_group.json ├── fixup ├── allgood │ ├── src │ │ └── code │ │ │ └── main.go │ └── translations │ │ ├── all.en_US.json │ │ └── all.zh_CN.json └── notsogood │ ├── add │ ├── src │ │ └── code │ │ │ ├── main.go │ │ │ └── mypackage │ │ │ └── thing.go │ └── translations │ │ ├── all.en_US.json │ │ └── all.zh_CN.json │ ├── delete │ ├── src │ │ └── code │ │ │ ├── main.go │ │ │ └── mypackage │ │ │ └── thing.go │ └── translations │ │ ├── all.en_US.json │ │ └── all.zh_CN.json │ ├── extra_foreign_key │ ├── src │ │ └── code │ │ │ ├── main.go │ │ │ └── mypackage │ │ │ └── thing.go │ └── translations │ │ ├── all.en_US.json │ │ └── all.zh_CN.json │ ├── missing_foreign_key │ ├── src │ │ └── code │ │ │ ├── main.go │ │ │ └── mypackage │ │ │ └── thing.go │ └── translations │ │ ├── all.en_US.json │ │ └── all.zh_CN.json │ ├── multiple_update │ ├── src │ │ └── code │ │ │ ├── main.go │ │ │ └── mypackage │ │ │ └── thing.go │ └── translations │ │ ├── all.en_US.json │ │ └── all.zh_CN.json │ ├── update │ ├── src │ │ └── code │ │ │ ├── main.go │ │ │ └── mypackage │ │ │ └── thing.go │ └── translations │ │ ├── all.en_US.json │ │ └── all.zh_CN.json │ └── update_add │ ├── src │ └── code │ │ ├── main.go │ │ └── mypackage │ │ └── thing.go │ └── translations │ ├── all.en_US.json │ └── all.zh_CN.json ├── merge_strings ├── d_option │ ├── expected_output │ │ └── all.en.json │ └── input_files │ │ ├── main.go.en.json │ │ ├── main.go.fr.json │ │ ├── main2.go.en.json │ │ └── reordered │ │ ├── main1.go.en.json │ │ └── main3.go.en.json ├── r_option │ ├── expected_output │ │ ├── all.en.json │ │ └── sub │ │ │ └── all.en.json │ └── input_files │ │ ├── main.go.en.json │ │ ├── main.go.fr.json │ │ ├── main2.go.en.json │ │ └── sub │ │ ├── main.go.en.json │ │ ├── main.go.fr.json │ │ └── main2.go.en.json └── source_language │ ├── expected_output │ └── all.fr.json │ └── input_files │ ├── main.go.fr.json │ └── main2.go.fr.json ├── rewrite_package ├── d_option │ ├── expected_output │ │ ├── doption │ │ │ ├── _en.all.json │ │ │ ├── _test.go.en.json │ │ │ ├── _test2.go.en.json │ │ │ ├── en.all.json │ │ │ ├── test.go.en.json │ │ │ └── test2.go.en.json │ │ ├── test.go │ │ ├── test2.go │ │ └── test3.go │ └── input_files │ │ ├── test.go │ │ ├── test2.go │ │ └── test3.go ├── f_option │ ├── expected_output │ │ ├── i18n_init.go │ │ ├── issue13.go │ │ ├── nested_dir │ │ │ ├── i18n_init.go │ │ │ └── test.go │ │ ├── test.go │ │ ├── test_interpolated_strings.go │ │ └── test_templated_strings.go │ └── input_files │ │ ├── a_really_bad_test.go │ │ ├── issue13.go │ │ ├── nested_dir │ │ └── test.go │ │ ├── test.go │ │ ├── test_interpolated_strings.go │ │ └── test_templated_strings.go ├── i18n_strings_filename_option │ ├── expected_output │ │ ├── test.go │ │ ├── test_interpolated_strings.go │ │ ├── test_interpolated_strings.go.en.json │ │ └── test_templated_strings.go │ └── input_files │ │ ├── _test_interpolated_strings.go.en.json │ │ ├── strings.json │ │ ├── test.go │ │ ├── test_interpolated_strings.go │ │ ├── test_interpolated_strings.go.en.json │ │ ├── test_templated_strings.go │ │ └── test_templated_strings.go.en.json └── init_code_snippet_filename │ ├── expected_output │ ├── i18n_init_default.go │ ├── i18n_init_from_template.go │ └── issue14.go │ └── input_files │ ├── init_code_snippet.go.template │ └── issue14.go ├── show_missing_strings └── d_option │ └── input_files │ ├── extra_strings │ ├── app.go.en.json │ └── code │ │ └── app.go │ ├── missing_strings │ ├── app.go.en.json │ └── code │ │ └── app.go │ └── no_missing_strings │ ├── app.go.en.json │ └── code │ └── app.go └── verify_strings ├── duplicate_keys └── input_files │ ├── quota.go.en.json │ └── quota.go.fr.json └── f_option └── input_files ├── quota.go.af.json ├── quota.go.cs.json ├── quota.go.de.json ├── quota.go.en.json ├── quota.go.es.json ├── quota.go.fr.json ├── quota.go.it.json ├── quota.go.ja.json ├── quota.go.vi.json └── quota.go.zh_CN.json /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "gomod" 9 | directory: "/" # Location of package manifests 10 | schedule: 11 | interval: "weekly" 12 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: "CodeQL" 13 | 14 | on: 15 | push: 16 | branches: [ "master" ] 17 | pull_request: 18 | # The branches below must be a subset of the branches above 19 | branches: [ "master" ] 20 | schedule: 21 | - cron: '39 19 * * 4' 22 | 23 | jobs: 24 | analyze: 25 | name: Analyze 26 | runs-on: ubuntu-latest 27 | permissions: 28 | actions: read 29 | contents: read 30 | security-events: write 31 | 32 | strategy: 33 | fail-fast: false 34 | matrix: 35 | language: [ 'go', 'javascript' ] 36 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] 37 | # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support 38 | 39 | steps: 40 | - name: Checkout repository 41 | uses: actions/checkout@v3 42 | 43 | # Initializes the CodeQL tools for scanning. 44 | - name: Initialize CodeQL 45 | uses: github/codeql-action/init@v2 46 | with: 47 | languages: ${{ matrix.language }} 48 | # If you wish to specify custom queries, you can do so here or in a config file. 49 | # By default, queries listed here will override any specified in a config file. 50 | # Prefix the list here with "+" to use these queries and those in the config file. 51 | 52 | # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs 53 | # queries: security-extended,security-and-quality 54 | 55 | 56 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 57 | # If this step fails, then you should remove it and run the build manually (see below) 58 | - name: Autobuild 59 | uses: github/codeql-action/autobuild@v2 60 | 61 | # ℹ️ Command-line programs to run using the OS shell. 62 | # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun 63 | 64 | # If the Autobuild fails above, remove it and uncomment the following three lines. 65 | # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. 66 | 67 | # - run: | 68 | # echo "Run, Build Application using script" 69 | # ./location_of_script_within_repo/buildscript.sh 70 | 71 | - name: Perform CodeQL Analysis 72 | uses: github/codeql-action/analyze@v2 73 | -------------------------------------------------------------------------------- /.github/workflows/go.yml: -------------------------------------------------------------------------------- 1 | name: Go 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | 11 | build: 12 | name: Build 13 | runs-on: ubuntu-latest 14 | steps: 15 | 16 | - name: Set up Go 1.x 17 | uses: actions/setup-go@v3 18 | with: 19 | go-version: '>=1.17' 20 | 21 | - name: Check out code into the Go module directory 22 | uses: actions/checkout@v3 23 | 24 | - name: Get dependencies 25 | run: | 26 | go get -v -t -d ./... 27 | if [ -f Gopkg.toml ]; then 28 | curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh 29 | dep ensure 30 | fi 31 | 32 | - name: Format 33 | run: go fmt ./... 34 | 35 | - name: Build 36 | run: ./bin/build 37 | 38 | - name: Test 39 | run: | 40 | export GOPATH=$(go env GOPATH)/bin 41 | ./bin/test 42 | 43 | - name: Validate 44 | run: ./bin/validate 45 | -------------------------------------------------------------------------------- /.github/workflows/greetings.yml: -------------------------------------------------------------------------------- 1 | name: Greetings 2 | 3 | on: [pull_request, issues] 4 | 5 | jobs: 6 | greeting: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/first-interaction@v1 10 | continue-on-error: true 11 | with: 12 | repo-token: ${{ secrets.GITHUB_TOKEN }} 13 | issue-message: 'Thanks for your contribution. Please contact me @maximilien to ensure follow-up.' 14 | pr-message: 'Thanks for your contribution. Please contact me @maximilien to ensure follow-up.' 15 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | name: Mark stale issues and pull requests 2 | 3 | on: 4 | schedule: 5 | - cron: "60 1 * * *" 6 | 7 | jobs: 8 | stale: 9 | 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - uses: actions/stale@v1 14 | with: 15 | repo-token: ${{ secrets.GITHUB_TOKEN }} 16 | stale-issue-message: 'This issue is staled for 60 days' 17 | stale-pr-message: 'This PR is staled for 60 days' 18 | stale-issue-label: 'no-issue-activity' 19 | stale-pr-label: 'no-pr-activity' 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Vim swap files 7 | *.swp 8 | 9 | # Folders 10 | _obj 11 | _test 12 | 13 | # Architecture specific extensions/prefixes 14 | *.[568vq] 15 | [568vq].out 16 | 17 | *.cgo1.go 18 | *.cgo2.c 19 | _cgo_defun.c 20 | _cgo_gotypes.go 21 | _cgo_export.* 22 | 23 | _testmain.go 24 | 25 | *.exe 26 | *.test 27 | 28 | *.go.*.po 29 | 30 | !**/expected_output/**/*.go.*.json 31 | !**/expected_output/**/*.go.*.po 32 | 33 | tmp 34 | out 35 | 36 | .DS_Store 37 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.18 4 | before_install: 5 | - go get github.com/onsi/ginkgo/... 6 | - go get github.com/onsi/gomega/... 7 | install: true 8 | script: bin/test 9 | branches: 10 | only: 11 | - master 12 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changes in v0.2.3 2 | - removed the main/* directory 3 | - added -q flag to checkup to allow qualifiers to be specified, so that i18n.T(...) can be used 4 | - update to README to match new checkup -q flag 5 | 6 | # Changes in v0.2.1 7 | - renamed executable to i18n4go 8 | - minor update to README 9 | 10 | # Changes in v0.1.2 11 | - fix for issue #22 12 | 13 | # Changes in v0.1.1 14 | - added Typical Workflow Diagram and minor clarifications to README 15 | - added version string to usage and this file to keep track of changes 16 | 17 | # Changes in v0.1.0 18 | - Historical, first release, not versioned 19 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | To contribute, please submit a Pull Request. The only thing that we ask that you do 2 | is to certify that the contribution (code, docs, etc) was done by you. You can do this with 3 | a very simple step: include a line in your first pull request comment such as: 4 | 5 | “DCO 1.1 Signed-off-by: Random J Developer " 6 | 7 | By doing this one simple thing you are telling the community that you wrote the code you are contributing or have the right to pass on the code that you are contributing. The DCO 1.1 referenced is the Developer Certificate of Origin that is used in the Linux Kernel community, you can find it [here](http://elinux.org/Developer_Certificate_Of_Origin "DCO 1.1"). 8 | -------------------------------------------------------------------------------- /bin/build: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright © 2015-2023 The Knative Authors 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -e 18 | 19 | echo -e "\n Formatting packages..." 20 | go fmt ./... 21 | 22 | echo -e "\nGenerating Binary..." 23 | go build -o $(dirname $0)/../out/i18n4go ./i18n4go/i18n4go.go 24 | -------------------------------------------------------------------------------- /bin/clean: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright © 2015-2023 The Knative Authors 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -e 18 | 19 | rm out/* -------------------------------------------------------------------------------- /bin/run: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright © 2015-2023 The Knative Authors 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -e 18 | 19 | $(dirname $0)/build 20 | go run -race $(dirname $0)/../i18n4go/i18n4go.go "$@" 21 | -------------------------------------------------------------------------------- /bin/test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright © 2015-2023 The Knative Authors 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | ( 18 | set -e 19 | 20 | function printStatus { 21 | if [ $? -eq 0 ]; then 22 | echo -e "\nSWEET SUITE SUCCESS" 23 | else 24 | echo -e "\nSUITE FAILURE" 25 | fi 26 | } 27 | 28 | trap printStatus EXIT 29 | 30 | echo -e "\n Cleaning build artifacts..." 31 | go clean 32 | 33 | echo -e "\n Formatting packages..." 34 | go fmt ./... 35 | 36 | echo -e "\n Integration Testing packages:" 37 | go test -count=1 ./integration/... -parallel 4 $@ 38 | ) 39 | -------------------------------------------------------------------------------- /bin/validate: -------------------------------------------------------------------------------- 1 | #!/bin/env bash 2 | 3 | # Copyright © 2015-2023 The Knative Authors 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | set -e 17 | 18 | echo -e "\nUpdate (Re)generated translation files..." 19 | 20 | PROJ_DIR=$(cd $(dirname $(dirname $0)) && pwd) 21 | if [[ -z $(command -v go-bindata) ]]; then 22 | echo -e "\nInstalling go-bindata..." 23 | # install outside of GO PATH 24 | pushd /tmp >/dev/null 25 | go install -a -v github.com/go-bindata/go-bindata/...@latest 26 | popd > /dev/null 27 | fi 28 | 29 | pushd $PROJ_DIR >/dev/null 30 | go-bindata -pkg resources -o resources -o i18n4go/resources/i18n_resources.go -nocompress i18n4go/i18n/resources/*.json 31 | echo -e "\nCompleted." 32 | 33 | popd >/dev/null 34 | 35 | echo -e "\nVerify translation messages" 36 | 37 | if [[ ! -f $PROJ_DIR/out/i18n4go ]]; then 38 | echo -e "\nMissing built bui18n4go binary..." 39 | exit 1 40 | fi 41 | 42 | pushd i18n4go >/dev/null 43 | $PROJ_DIR/out/i18n4go checkup -q i18n -v 44 | popd 45 | 46 | echo -e "\nComplete." 47 | -------------------------------------------------------------------------------- /docs/blog_post1.md: -------------------------------------------------------------------------------- 1 | # Introducing i18n4go - Go language tooling for internationalization (i18n) 2 | 3 | ## Abstract 4 | 5 | In this post we will give an introductory overview of the i18n4go tool which allows one to easily globalize any Go language program. The i18n4go toolset was extracted while globalizing the CLoudFoundry command line interface and is an example of the CloudFoundry community usage of the Go language as well as contributing back to that community, in effect cross pollinating both communities, as was done with the Ginko and Gomega toolsets. 6 | 7 | ## Introduction 8 | As the CloudFoundry project gets an increasingly global audience (users and developers) there is increasingly a need to globalize the parts of the system interfacing the main users. In particular, as IBM's Bluemix public installation of CF was announced, one of the gapping hole was to globalize the primary interface to CF from all users, the command line interface or CLI. Since the CF CLI is conversational by nature, it is a good candidate for internationalization (i18n), even if the majority of developers speak English, having the CLI converse in your own native tongue could make the whole experience more familiar and natural. 9 | 10 | So it was with these motivation that the IBM CF community team decided to take on the major task of converting the entire CLI code base for globalization. Working closely with our Pivotal colleagues, what transpired in the span of about two months is a complete update of the CLI to enable any human language and a release of the CLI in the default English as well as French along with a call to action to the community to submit new translations. The following blog post does not chronicle this exercise, but rather gives an introduction to the resulting tooling that was develop in the process. This tool is a general purpose Go language tool (written in Go) to help in globalizing any Go program. We call it: i18n4go. 11 | 12 | ### Organization 13 | 14 | The rest of this post is organized as follows. First we take a look at what related tools exist in the Go language community that are helpful in globalizing Go programs. Next we will give an overview of our approach, which is completely tools-driven. After that we will use a public OSS Go program that could make use of globalization and walk you through the steps to convert it for internationalization. We then complete with a summary of the typical workflow of a developer using i18n4go and briefly touch on future works. 15 | 16 | ## Related Tools 17 | 18 | Since the Go language community is rather young, there 19 | * i18n tooling for Java and Ruby 20 | * existing i18n tooling for Go language 21 | 22 | ## Architecture and Design 23 | 24 | * i18n problem 25 | * solving with tooling 26 | * similar tools 27 | * taking advantage of Go language's features 28 | 29 | ## Applying Tool 30 | 31 | * using workflow to CF CLI 32 | * using workflow to a small Go language program 33 | 34 | ## Typical Workflow 35 | 36 | * applying to Go projects 37 | * extracting strings 38 | * merging strings 39 | * rewriting code 40 | * creating translations 41 | * verifying translations 42 | * modifying strings 43 | * maintaining strings 44 | 45 | ## Conclusion and Future 46 | 47 | * recap of tool features 48 | * using tool on CF CLI 49 | * what is missing? 50 | * immediate next steps 51 | * future next steps 52 | 53 | ## References 54 | -------------------------------------------------------------------------------- /docs/images/typical-workflow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maximilien/i18n4go/8e4b0eee96160b18bb331fb747da97cac43a6225/docs/images/typical-workflow.png -------------------------------------------------------------------------------- /examples/demo1-i18n/build: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | export GOPATH=$(godep path):$GOPATH 5 | 6 | echo -e "\n Formatting packages..." 7 | go fmt ./... 8 | 9 | echo -e "\nGenerating Binary..." 10 | go build -o $(dirname $0)/out/demo1 demo1.go i18n_init.go i18n_resources.go 11 | -------------------------------------------------------------------------------- /examples/demo1-i18n/demo1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | const VERSION = "v0.0.1" 8 | 9 | func main() { 10 | fmt.Println(T("Hello from Goffer land and i18n4go")) 11 | fmt.Println("") 12 | fmt.Printf(T("Version {{.Arg0}}\n", map[string]interface{}{"Arg0": VERSION})) 13 | } 14 | -------------------------------------------------------------------------------- /examples/demo1-i18n/demo1.go.en.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Hello from Goffer land and i18n4go", 4 | "translation": "Hello from Goffer land and i18n4go" 5 | }, 6 | { 7 | "id": "Version {{.Arg0}}n", 8 | "translation": "Version {{.Arg0}}n" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /examples/demo1-i18n/en.all.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Hello from Goffer land and i18n4go", 4 | "translation": "Hello from Goffer land and i18n4go" 5 | }, 6 | { 7 | "id": "Version {{.Arg0}}\n", 8 | "translation": "Version {{.Arg0}}\n" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /examples/demo1-i18n/excluded.json: -------------------------------------------------------------------------------- 1 | { 2 | "excludedStrings" : [ 3 | "", 4 | " ", 5 | "\n", 6 | "\t", 7 | "\n\t", 8 | 9 | "v0.0.1", 10 | 11 | "extract_strings", 12 | "excluded.json", 13 | "i18n4go", 14 | ".en.json", 15 | ".extracted.json", 16 | "json:\"id\"", 17 | "json:\"filename\"", 18 | "json:\"excludedStrings\"", 19 | "json:\"translation\"", 20 | "json:\"value\"", 21 | "json:\"offset\"", 22 | "json:\"line\"", 23 | "json:\"column\"", 24 | "recursive:", 25 | ".json", 26 | ".po", 27 | ", column: ", 28 | ", line: ", 29 | ", offset: ", 30 | "msgid ", 31 | "msgstr ", 32 | "# filename: ", 33 | ".", 34 | "\\", 35 | "help", 36 | ".go", 37 | "", 38 | "/", 39 | "false", 40 | "true" 41 | ], 42 | "excludedRegexps" : [ 43 | "^\\d+$", 44 | "^-\\w$", 45 | "^\\w$", 46 | "^json:" 47 | ] 48 | } -------------------------------------------------------------------------------- /examples/demo1-i18n/generate-language-resources: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | go get github.com/jteeuwen/go-bindata/... 6 | 7 | echo " Generating i18n Resource file" 8 | go-bindata -pkg main -ignore ".go" -o ./i18n_resources.go ./i18n/resources/... 9 | -------------------------------------------------------------------------------- /examples/demo1-i18n/i18n/resources/de.all.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Hello from Goffer land and i18n4go", 4 | "translation": "Hallo von Goffer Land und i18n4go" 5 | }, 6 | { 7 | "id": "Version {{.Arg0}}\n", 8 | "translation": "Version {{.Arg0}}" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /examples/demo1-i18n/i18n/resources/de_DE.all.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Hello from Goffer land and i18n4go", 4 | "translation": "Hallo von Goffer Land und i18n4go" 5 | }, 6 | { 7 | "id": "Version {{.Arg0}}\n", 8 | "translation": "Version {{.Arg0}}" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /examples/demo1-i18n/i18n/resources/en_US.all.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Hello from Goffer land and i18n4go", 4 | "translation": "Hello from Goffer land and i18n4go" 5 | }, 6 | { 7 | "id": "Version {{.Arg0}}\n", 8 | "translation": "Version {{.Arg0}}\n" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /examples/demo1-i18n/i18n/resources/es.all.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Hello from Goffer land and i18n4go", 4 | "translation": "Saludos desde la tierra Goffer y i18n4go" 5 | }, 6 | { 7 | "id": "Version {{.Arg0}}\n", 8 | "translation": "Versión {{.Arg0}}" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /examples/demo1-i18n/i18n/resources/es_ES.all.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Hello from Goffer land and i18n4go", 4 | "translation": "Saludos desde la tierra Goffer y i18n4go" 5 | }, 6 | { 7 | "id": "Version {{.Arg0}}\n", 8 | "translation": "Versión {{.Arg0}}" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /examples/demo1-i18n/i18n/resources/fr.all.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Hello from Goffer land and i18n4go", 4 | "translation": "Bonjour de la terre et Goffer i18n4go" 5 | }, 6 | { 7 | "id": "Version {{.Arg0}}\n", 8 | "translation": "Version {{.Arg0}}" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /examples/demo1-i18n/i18n/resources/fr_FR.all.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Hello from Goffer land and i18n4go", 4 | "translation": "Bonjour de la terre des Goffer land et de i18n4go" 5 | }, 6 | { 7 | "id": "Version {{.Arg0}}\n", 8 | "translation": "Version {{.Arg0}}\n" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /examples/demo1-i18n/i18n/resources/zh.all.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Hello from Goffer land and i18n4go", 4 | "translation": "你好,从高佛尔的土地和i18n4go" 5 | }, 6 | { 7 | "id": "Version {{.Arg0}}\n", 8 | "translation": "版本{{.Arg0}}" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /examples/demo1-i18n/i18n/resources/zh_Hans.all.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Hello from Goffer land and i18n4go", 4 | "translation": "你好,从高佛尔的土地和i18n4go" 5 | }, 6 | { 7 | "id": "Version {{.Arg0}}\n", 8 | "translation": "版本{{.Arg0}}" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /examples/demo1/build: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | export GOPATH=$(godep path):$GOPATH 5 | 6 | echo -e "\n Formatting packages..." 7 | go fmt ./... 8 | 9 | echo -e "\nGenerating Binary..." 10 | go build -o $(dirname $0)/out/demo1 demo1.go i18n_init.go i18n_resources.go 11 | -------------------------------------------------------------------------------- /examples/demo1/demo1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | const VERSION = "v0.0.1" 8 | 9 | func main() { 10 | fmt.Println("Hello from Goffer land and i18n4go") 11 | fmt.Println("") 12 | fmt.Printf("Version %s\n", VERSION) 13 | } 14 | -------------------------------------------------------------------------------- /examples/demo1/demo1_script.txt: -------------------------------------------------------------------------------- 1 | # move to examples directory 2 | cd examples 3 | 4 | # basic extract strings w/o excluded.json WITH --dry-run 5 | 6 | i18n4go -c extract-strings -v --dry-run --output-flat -o demo1-i18n -f demo1/demo1.go 7 | 8 | # basic extract strings w/o excluded.json 9 | 10 | i18n4go -c extract-strings -v --output-flat -o demo1-i18n -f demo1/demo1.go 11 | 12 | # basic extract strings w demo1-i18n/excluded.json 13 | 14 | cp demo1/excluded.json demo1-i18n/excluded.json 15 | i18n4go -c extract-strings -v -e ./demo1-i18n/excluded.json --output-flat -o demo1-i18n -f demo1/demo1.go 16 | 17 | # cp go project files into demo1-i18n 18 | 19 | cp demo1/demo1.go demo1-i18n/demo1.go 20 | cp demo1/build demo1-i18n/build 21 | cp demo1/generate-language-resources demo1-i18n/generate-language-resources 22 | 23 | # rewrite package demo1 24 | 25 | i18n4go -c rewrite-package -v -d demo1-i18n --i18n-strings-filename demo1-i18n/demo1.go.en.json --init-code-snippet-filename i18n_init/cf_cli_i18n_init.go.template 26 | 27 | # extract string again to have strings with args 28 | 29 | i18n4go -c extract-strings -v -e ./demo1-i18n/excluded.json --output-flat -o demo1-i18n -f demo1-i18n/demo1.go 30 | 31 | # go into the new i18n project 32 | 33 | cd demo1-i18n 34 | 35 | # create i18n resources 36 | 37 | mkdir -p i18n/resources 38 | 39 | # merge translation to all.en.json 40 | 41 | i18n4go -c merge-strings -v --source-language en -d . 42 | 43 | # create translation files 44 | 45 | i18n4go -c create-translations -v --source-language en -f en.all.json --languages en_US,fr_FR,es_ES,de_DE,zh_Hans -o i18n/resources 46 | 47 | # generate resource assets 48 | 49 | ./generate-language-resources 50 | 51 | # build executable 52 | 53 | ./build 54 | 55 | # test and run 56 | 57 | ./out/demo1 58 | LANG=fr_FR ./out/demo1 59 | 60 | -------------------------------------------------------------------------------- /examples/demo1/excluded.json: -------------------------------------------------------------------------------- 1 | { 2 | "excludedStrings" : [ 3 | "", 4 | " ", 5 | "\n", 6 | "\t", 7 | "\n\t", 8 | 9 | "v0.0.1", 10 | 11 | "extract_strings", 12 | "excluded.json", 13 | "i18n4go", 14 | ".en.json", 15 | ".extracted.json", 16 | "json:\"id\"", 17 | "json:\"filename\"", 18 | "json:\"excludedStrings\"", 19 | "json:\"translation\"", 20 | "json:\"value\"", 21 | "json:\"offset\"", 22 | "json:\"line\"", 23 | "json:\"column\"", 24 | "recursive:", 25 | ".json", 26 | ".po", 27 | ", column: ", 28 | ", line: ", 29 | ", offset: ", 30 | "msgid ", 31 | "msgstr ", 32 | "# filename: ", 33 | ".", 34 | "\\", 35 | "help", 36 | ".go", 37 | "", 38 | "/", 39 | "false", 40 | "true" 41 | ], 42 | "excludedRegexps" : [ 43 | "^\\d+$", 44 | "^-\\w$", 45 | "^\\w$", 46 | "^json:" 47 | ] 48 | } -------------------------------------------------------------------------------- /examples/demo1/generate-language-resources: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | go get github.com/jteeuwen/go-bindata/... 6 | 7 | echo " Generating i18n Resource file" 8 | go-bindata -pkg main -ignore ".go" -o ./i18n_resources.go ./i18n/resources/... 9 | -------------------------------------------------------------------------------- /examples/excluded/excluded.json: -------------------------------------------------------------------------------- 1 | { 2 | "excludedStrings" : [ 3 | "", 4 | " ", 5 | "\n", 6 | "\t", 7 | "\n\t", 8 | 9 | "extract_strings", 10 | "excluded.json", 11 | "i18n4go", 12 | ".en.json", 13 | ".extracted.json", 14 | "json:\"id\"", 15 | "json:\"filename\"", 16 | "json:\"excludedStrings\"", 17 | "json:\"translation\"", 18 | "json:\"value\"", 19 | "json:\"offset\"", 20 | "json:\"line\"", 21 | "json:\"column\"", 22 | "recursive:", 23 | ".json", 24 | ".po", 25 | ", column: ", 26 | ", line: ", 27 | ", offset: ", 28 | "msgid ", 29 | "msgstr ", 30 | "# filename: ", 31 | ".", 32 | "\\", 33 | "help", 34 | ".go", 35 | "", 36 | "/", 37 | "false", 38 | "true" 39 | ], 40 | "excludedRegexps" : [ 41 | "^\\d+$", 42 | "^-\\w$", 43 | "^\\w$", 44 | "^json:" 45 | ] 46 | } 47 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/maximilien/i18n4go 2 | 3 | go 1.18 4 | 5 | require ( 6 | github.com/go-bindata/go-bindata/v3 v3.1.3 7 | github.com/nicksnyder/go-i18n/v2 v2.4.0 8 | github.com/onsi/ginkgo v1.16.5 9 | github.com/onsi/gomega v1.33.1 10 | github.com/pivotal-cf-experimental/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21 11 | github.com/spf13/cobra v1.8.1 12 | golang.org/x/text v0.16.0 13 | ) 14 | 15 | require ( 16 | github.com/cloudfoundry/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21 // indirect 17 | github.com/fsnotify/fsnotify v1.4.9 // indirect 18 | github.com/google/go-cmp v0.6.0 // indirect 19 | github.com/inconshreveable/mousetrap v1.1.0 // indirect 20 | github.com/kisielk/errcheck v1.2.0 // indirect 21 | github.com/nxadm/tail v1.4.8 // indirect 22 | github.com/spf13/pflag v1.0.5 // indirect 23 | golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f // indirect 24 | golang.org/x/mod v0.17.0 // indirect 25 | golang.org/x/net v0.25.0 // indirect 26 | golang.org/x/sync v0.7.0 // indirect 27 | golang.org/x/sys v0.20.0 // indirect 28 | golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect 29 | gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect 30 | gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect 31 | gopkg.in/yaml.v3 v3.0.1 // indirect 32 | ) 33 | -------------------------------------------------------------------------------- /i18n4go/cmds/cmd_interface.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2015-2023 The Knative Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package cmds 16 | 17 | import ( 18 | "github.com/maximilien/i18n4go/i18n4go/common" 19 | ) 20 | 21 | type CommandInterface interface { 22 | common.PrinterInterface 23 | Options() common.Options 24 | Run() error 25 | } 26 | -------------------------------------------------------------------------------- /i18n4go/cmds/types.go: -------------------------------------------------------------------------------- 1 | package cmds 2 | 3 | import ( 4 | "io" 5 | ) 6 | 7 | // I18NParams for creating commands. 8 | // Useful for inserting mocks for testing 9 | // and to have common parameters across commands. 10 | type I18NParams struct { 11 | Output io.Writer 12 | } 13 | -------------------------------------------------------------------------------- /i18n4go/cmds/version.go: -------------------------------------------------------------------------------- 1 | package cmds 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/maximilien/i18n4go/i18n4go/i18n" 7 | "github.com/spf13/cobra" 8 | ) 9 | 10 | var Version string 11 | var BuildDate string 12 | var GitRevision string 13 | 14 | // NewVersionCommand implements 'i18n version' command 15 | func NewVersionCommand(p *I18NParams) *cobra.Command { 16 | versionCmd := &cobra.Command{ 17 | Use: "version", 18 | Short: i18n.T("Show the version of the i18n client"), 19 | RunE: func(cmd *cobra.Command, args []string) error { 20 | fmt.Printf(i18n.T("Version: {{.Arg0}}\n", map[string]interface{}{"Arg0": Version})) 21 | fmt.Printf(i18n.T("Build Date: {{.Arg0}}\n", map[string]interface{}{"Arg0": BuildDate})) 22 | fmt.Printf(i18n.T("Git Revision: {{.Arg0}}\n", map[string]interface{}{"Arg0": GitRevision})) 23 | return nil 24 | }, 25 | } 26 | return versionCmd 27 | } 28 | -------------------------------------------------------------------------------- /i18n4go/common/ast.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2015-2023 The Knative Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package common 16 | 17 | import ( 18 | "errors" 19 | "fmt" 20 | 21 | "go/ast" 22 | 23 | "github.com/maximilien/i18n4go/i18n4go/i18n" 24 | ) 25 | 26 | func ImportsForASTFile(astFile *ast.File) (*ast.GenDecl, error) { 27 | for _, declaration := range astFile.Decls { 28 | decl, ok := declaration.(*ast.GenDecl) 29 | if !ok || len(decl.Specs) == 0 { 30 | continue 31 | } 32 | 33 | if _, ok = decl.Specs[0].(*ast.ImportSpec); ok { 34 | return decl, nil 35 | } 36 | } 37 | 38 | return nil, errors.New(fmt.Sprintf(i18n.T("Could not find imports for root node:\n\t{{.Arg0}}v\n", map[string]interface{}{"Arg0": astFile}))) 39 | } 40 | -------------------------------------------------------------------------------- /i18n4go/common/cmd.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2015-2023 The Knative Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package common 16 | 17 | type Options struct { 18 | CommandFlag string 19 | 20 | HelpFlag bool 21 | LongHelpFlag bool 22 | 23 | VerboseFlag bool 24 | DryRunFlag bool 25 | PoFlag bool 26 | MetaFlag bool 27 | 28 | SourceLanguageFlag string 29 | LanguagesFlag string 30 | GoogleTranslateApiKeyFlag string 31 | 32 | OutputDirFlag string 33 | OutputMatchImportFlag bool 34 | OutputMatchPackageFlag bool 35 | OutputFlatFlag bool 36 | 37 | ExcludedFilenameFlag string 38 | SubstringFilenameFlag string 39 | FilenameFlag string 40 | DirnameFlag string 41 | 42 | RecurseFlag bool 43 | 44 | IgnoreRegexpFlag string 45 | 46 | LanguageFilesFlag string 47 | 48 | I18nStringsFilenameFlag string 49 | I18nStringsDirnameFlag string 50 | 51 | RootPathFlag string 52 | 53 | InitCodeSnippetFilenameFlag string 54 | 55 | QualifierFlag string 56 | } 57 | 58 | type I18nStringInfo struct { 59 | ID string `json:"id"` 60 | Translation string `json:"translation"` 61 | } 62 | 63 | type StringInfo struct { 64 | Filename string `json:"filename"` 65 | Value string `json:"value"` 66 | Offset int `json:"offset"` 67 | Line int `json:"line"` 68 | Column int `json:"column"` 69 | } 70 | 71 | type ExcludedStrings struct { 72 | ExcludedStrings []string `json:"excludedStrings"` 73 | ExcludedRegexps []string `json:"excludedRegexps"` 74 | } 75 | 76 | type PrinterInterface interface { 77 | Println(a ...interface{}) (int, error) 78 | Printf(msg string, a ...interface{}) (int, error) 79 | } 80 | 81 | var BLANKS = []string{", ", "\t", "\n", "\n\t", "\t\n"} 82 | -------------------------------------------------------------------------------- /i18n4go/i18n/excluded.json: -------------------------------------------------------------------------------- 1 | { 2 | "excludedStrings": [ 3 | "%s.", 4 | "", 5 | "\"", 6 | " ", 7 | " ", 8 | "\n", 9 | ">", 10 | "\\<", 11 | "\\&", 12 | "&", 13 | "\t", 14 | "\n\t", 15 | "extract_strings", 16 | "excluded.json", 17 | "en_US", 18 | "i18n4go", 19 | ".en.json", 20 | ".extracted.json", 21 | "json:\"id\"", 22 | "json:\"filename\"", 23 | "json:\"excludedStrings\"", 24 | "json:\"translation\"", 25 | "json:\"value\"", 26 | "json:\"offset\"", 27 | "json:\"line\"", 28 | "json:\"column\"", 29 | "recursive:", 30 | ".json", 31 | ".po", 32 | ", column: ", 33 | ", line: ", 34 | ", offset: ", 35 | "msgid ", 36 | "msgstr ", 37 | "# filename: ", 38 | ".", 39 | "<", 40 | "\\", 41 | "help", 42 | ".go", 43 | "/", 44 | ",", 45 | "false", 46 | "true" 47 | ], 48 | "excludedRegexps": [ 49 | "^\\d+$", 50 | "^-\\w$", 51 | "^\\w$", 52 | "^json:", 53 | "^\\&.*", 54 | "^https:", 55 | "^%.*" 56 | ] 57 | } 58 | -------------------------------------------------------------------------------- /i18n4go/i18n/i18n_init.go: -------------------------------------------------------------------------------- 1 | package i18n 2 | 3 | import "path/filepath" 4 | 5 | var T TranslateFunc 6 | 7 | func init() { 8 | T = Init("", filepath.Join("i18n4go", GetResourcesPath()), func(asset string) ([]byte, error) { 9 | return Asset(asset) 10 | }) 11 | } 12 | -------------------------------------------------------------------------------- /i18n4go/i18n/i18n_init.go.template: -------------------------------------------------------------------------------- 1 | package __PACKAGE__NAME__ 2 | 3 | import ( 4 | "path/filepath" 5 | 6 | "github.com/maximilien/i18n4go/i18n4go/i18n" 7 | ) 8 | 9 | var T goi18n.TranslateFunc 10 | 11 | func init() { 12 | T = i18n.Init(__FULL_IMPORT_PATH__, i18n.GetResourcesPath(), func(asset string) ([]byte, error) { 13 | return Asset(asset) 14 | }) 15 | } 16 | -------------------------------------------------------------------------------- /integration/checkup/checkup_suite_test.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2015-2023 The Knative Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package checkup_test 16 | 17 | import ( 18 | "github.com/maximilien/i18n4go/integration/test_helpers" 19 | . "github.com/onsi/ginkgo" 20 | . "github.com/onsi/gomega" 21 | 22 | "testing" 23 | ) 24 | 25 | func TestCheckup(t *testing.T) { 26 | BeforeSuite(test_helpers.BuildExecutable) 27 | RegisterFailHandler(Fail) 28 | RunSpecs(t, "Checkup Suite") 29 | } 30 | -------------------------------------------------------------------------------- /integration/create_translations/create_translations_suite_test.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2015-2023 The Knative Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package create_translations_test 16 | 17 | import ( 18 | . "github.com/onsi/ginkgo" 19 | . "github.com/onsi/gomega" 20 | 21 | "github.com/maximilien/i18n4go/integration/test_helpers" 22 | "github.com/onsi/gomega/gexec" 23 | 24 | "testing" 25 | ) 26 | 27 | func TestVerifyStrings(t *testing.T) { 28 | BeforeSuite(test_helpers.BuildExecutable) 29 | 30 | AfterSuite(func() { 31 | gexec.CleanupBuildArtifacts() 32 | }) 33 | 34 | RegisterFailHandler(Fail) 35 | RunSpecs(t, "createTranslations Suite") 36 | } 37 | -------------------------------------------------------------------------------- /integration/extract_strings/extract_strings_suite_test.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2015-2023 The Knative Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package extract_strings_test 16 | 17 | import ( 18 | . "github.com/onsi/ginkgo" 19 | . "github.com/onsi/gomega" 20 | 21 | "github.com/maximilien/i18n4go/integration/test_helpers" 22 | "github.com/onsi/gomega/gexec" 23 | 24 | "testing" 25 | ) 26 | 27 | func TestExtractStrings(t *testing.T) { 28 | BeforeSuite(test_helpers.BuildExecutable) 29 | 30 | AfterSuite(func() { 31 | gexec.CleanupBuildArtifacts() 32 | }) 33 | 34 | RegisterFailHandler(Fail) 35 | RunSpecs(t, "ExtractStrings Suite") 36 | } 37 | -------------------------------------------------------------------------------- /integration/fixup/fixup_suite_test.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2015-2023 The Knative Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package fixup_test 16 | 17 | import ( 18 | "testing" 19 | 20 | "github.com/maximilien/i18n4go/integration/test_helpers" 21 | 22 | . "github.com/onsi/ginkgo" 23 | . "github.com/onsi/gomega" 24 | ) 25 | 26 | func TestCheckup(t *testing.T) { 27 | BeforeSuite(test_helpers.BuildExecutable) 28 | RegisterFailHandler(Fail) 29 | RunSpecs(t, "Fixup Suite") 30 | } 31 | -------------------------------------------------------------------------------- /integration/merge_strings/merge_strings_suite_test.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2015-2023 The Knative Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package merge_strings_test 16 | 17 | import ( 18 | . "github.com/onsi/ginkgo" 19 | . "github.com/onsi/gomega" 20 | 21 | "github.com/maximilien/i18n4go/integration/test_helpers" 22 | "github.com/onsi/gomega/gexec" 23 | 24 | "testing" 25 | ) 26 | 27 | func TestMergeStrings(t *testing.T) { 28 | BeforeSuite(test_helpers.BuildExecutable) 29 | 30 | AfterSuite(func() { 31 | gexec.CleanupBuildArtifacts() 32 | }) 33 | 34 | RegisterFailHandler(Fail) 35 | RunSpecs(t, "MergeStrings Suite") 36 | } 37 | -------------------------------------------------------------------------------- /integration/merge_strings/r_option_test.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2015-2023 The Knative Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package merge_strings_test 16 | 17 | import ( 18 | "os" 19 | "path/filepath" 20 | 21 | . "github.com/maximilien/i18n4go/integration/test_helpers" 22 | . "github.com/onsi/ginkgo" 23 | . "github.com/onsi/gomega" 24 | ) 25 | 26 | var _ = Describe("merge-strings -d dirName -r", func() { 27 | var ( 28 | fixturesPath string 29 | inputFilesPath string 30 | expectedFilesPath string 31 | ) 32 | 33 | BeforeEach(func() { 34 | _, err := os.Getwd() 35 | Ω(err).ShouldNot(HaveOccurred()) 36 | 37 | fixturesPath = filepath.Join("..", "..", "test_fixtures", "merge_strings") 38 | inputFilesPath = filepath.Join(fixturesPath, "r_option", "input_files") 39 | expectedFilesPath = filepath.Join(fixturesPath, "r_option", "expected_output") 40 | }) 41 | 42 | Context("Using legacy commands", func() { 43 | Context("can combine multiple language files per directory", func() { 44 | BeforeEach(func() { 45 | session := Runi18n("-c", "merge-strings", "-v", "-r", "-d", filepath.Join(inputFilesPath), "--source-language", "en") 46 | Ω(session.ExitCode()).Should(Equal(0)) 47 | }) 48 | 49 | AfterEach(func() { 50 | RemoveAllFiles( 51 | GetFilePath(inputFilesPath, "all.en.json"), 52 | GetFilePath(inputFilesPath+"/sub", "all.en.json"), 53 | ) 54 | }) 55 | 56 | It("all.en.json contains translations from both files", func() { 57 | CompareExpectedToGeneratedTraslationJson( 58 | GetFilePath(expectedFilesPath, "all.en.json"), 59 | GetFilePath(inputFilesPath, "all.en.json"), 60 | ) 61 | CompareExpectedToGeneratedTraslationJson( 62 | GetFilePath(expectedFilesPath+"/sub", "all.en.json"), 63 | GetFilePath(inputFilesPath+"/sub", "all.en.json"), 64 | ) 65 | }) 66 | }) 67 | }) 68 | 69 | Context("Using cobra commands", func() { 70 | Context("can combine multiple language files per directory", func() { 71 | BeforeEach(func() { 72 | session := Runi18n("merge-strings", "-v", "-r", "-d", filepath.Join(inputFilesPath), "--source-language", "en") 73 | Ω(session.ExitCode()).Should(Equal(0)) 74 | }) 75 | 76 | AfterEach(func() { 77 | RemoveAllFiles( 78 | GetFilePath(inputFilesPath, "all.en.json"), 79 | GetFilePath(inputFilesPath+"/sub", "all.en.json"), 80 | ) 81 | }) 82 | 83 | It("all.en.json contains translations from both files", func() { 84 | CompareExpectedToGeneratedTraslationJson( 85 | GetFilePath(expectedFilesPath, "all.en.json"), 86 | GetFilePath(inputFilesPath, "all.en.json"), 87 | ) 88 | CompareExpectedToGeneratedTraslationJson( 89 | GetFilePath(expectedFilesPath+"/sub", "all.en.json"), 90 | GetFilePath(inputFilesPath+"/sub", "all.en.json"), 91 | ) 92 | }) 93 | }) 94 | }) 95 | 96 | }) 97 | -------------------------------------------------------------------------------- /integration/merge_strings/source_language_test.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2015-2023 The Knative Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package merge_strings_test 16 | 17 | import ( 18 | "os" 19 | "path/filepath" 20 | 21 | . "github.com/maximilien/i18n4go/integration/test_helpers" 22 | . "github.com/onsi/ginkgo" 23 | . "github.com/onsi/gomega" 24 | ) 25 | 26 | var _ = Describe("merge-strings -d dirName -source-lanuage sourceLanguage", func() { 27 | var ( 28 | fixturesPath string 29 | inputFilesPath string 30 | expectedFilesPath string 31 | ) 32 | 33 | BeforeEach(func() { 34 | _, err := os.Getwd() 35 | Ω(err).ShouldNot(HaveOccurred()) 36 | 37 | fixturesPath = filepath.Join("..", "..", "test_fixtures", "merge_strings", "source_language") 38 | inputFilesPath = filepath.Join(fixturesPath, "input_files") 39 | expectedFilesPath = filepath.Join(fixturesPath, "expected_output") 40 | }) 41 | 42 | Context("can combine multiple language files", func() { 43 | BeforeEach(func() { 44 | session := Runi18n("-c", "merge-strings", "-v", "-d", filepath.Join(inputFilesPath), "--source-language", "fr") 45 | Ω(session.ExitCode()).Should(Equal(0)) 46 | }) 47 | 48 | AfterEach(func() { 49 | RemoveAllFiles( 50 | GetFilePath(inputFilesPath, "all.fr.json"), 51 | ) 52 | }) 53 | 54 | It("all.fr.json contains translations from both files", func() { 55 | CompareExpectedToGeneratedTraslationJson( 56 | GetFilePath(expectedFilesPath, "all.fr.json"), 57 | GetFilePath(inputFilesPath, "all.fr.json"), 58 | ) 59 | }) 60 | }) 61 | 62 | }) 63 | -------------------------------------------------------------------------------- /integration/rewrite_package/suite_test.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2015-2023 The Knative Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package rewrite_package_test 16 | 17 | import ( 18 | . "github.com/onsi/ginkgo" 19 | . "github.com/onsi/gomega" 20 | 21 | "github.com/maximilien/i18n4go/integration/test_helpers" 22 | "github.com/onsi/gomega/gexec" 23 | 24 | "testing" 25 | ) 26 | 27 | func TestRewritePackage(t *testing.T) { 28 | BeforeSuite(test_helpers.BuildExecutable) 29 | 30 | AfterSuite(func() { 31 | gexec.CleanupBuildArtifacts() 32 | }) 33 | 34 | RegisterFailHandler(Fail) 35 | RunSpecs(t, "rewrite-package Suite") 36 | } 37 | -------------------------------------------------------------------------------- /integration/show_missing_strings/show_missing_strings_suite_test.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2015-2023 The Knative Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package show_missing_strings_test 16 | 17 | import ( 18 | . "github.com/onsi/ginkgo" 19 | . "github.com/onsi/gomega" 20 | 21 | "github.com/maximilien/i18n4go/integration/test_helpers" 22 | "github.com/onsi/gomega/gexec" 23 | 24 | "testing" 25 | ) 26 | 27 | func TestShowMissingStrings(t *testing.T) { 28 | BeforeSuite(test_helpers.BuildExecutable) 29 | 30 | AfterSuite(func() { 31 | gexec.CleanupBuildArtifacts() 32 | }) 33 | 34 | RegisterFailHandler(Fail) 35 | RunSpecs(t, "Show Missing Strings Suite") 36 | } 37 | -------------------------------------------------------------------------------- /integration/test_helpers/build_executable.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2015-2023 The Knative Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package test_helpers 16 | 17 | import ( 18 | "github.com/onsi/gomega/gexec" 19 | 20 | . "github.com/onsi/gomega" 21 | ) 22 | 23 | var I18n4goExec string 24 | 25 | func BuildExecutable() { 26 | var err error 27 | I18n4goExec, err = gexec.Build("./../../i18n4go") 28 | Ω(err).ShouldNot(HaveOccurred()) 29 | } 30 | -------------------------------------------------------------------------------- /integration/verify_strings/duplicate_keys_test.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2015-2023 The Knative Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package verify_strings_test 16 | 17 | import ( 18 | "os" 19 | "path/filepath" 20 | 21 | . "github.com/maximilien/i18n4go/integration/test_helpers" 22 | . "github.com/onsi/ginkgo" 23 | . "github.com/onsi/gomega" 24 | "github.com/onsi/gomega/gbytes" 25 | ) 26 | 27 | var _ = Describe("verify-strings -f fileName", func() { 28 | var ( 29 | fixturesPath string 30 | inputFilesPath string 31 | expectedFilesPath string 32 | ) 33 | 34 | BeforeEach(func() { 35 | _, err := os.Getwd() 36 | Ω(err).ShouldNot(HaveOccurred()) 37 | 38 | Ω(err).ToNot(HaveOccurred()) 39 | 40 | fixturesPath = filepath.Join("..", "..", "test_fixtures", "verify_strings") 41 | inputFilesPath = filepath.Join(fixturesPath, "duplicate_keys", "input_files") 42 | expectedFilesPath = filepath.Join(fixturesPath, "duplicate_keys", "expected_output") 43 | }) 44 | Context("Using legacy commands", func() { 45 | Context("checks for duplicate keys", func() { 46 | It("should error", func() { 47 | session := Runi18n("-c", "verify-strings", "-v", "-f", filepath.Join(inputFilesPath, "quota.go.en.json"), "--languages", "\"fr\"", "-o", expectedFilesPath, "--source-language", "en") 48 | Ω(session.ExitCode()).Should(Equal(1)) 49 | Ω(session).Should(gbytes.Say("Duplicated key found: Show quota info")) 50 | }) 51 | }) 52 | }) 53 | 54 | Context("Using cobra commands", func() { 55 | Context("checks for duplicate keys", func() { 56 | It("should error", func() { 57 | session := Runi18n("verify-strings", "-v", "-f", filepath.Join(inputFilesPath, "quota.go.en.json"), "--languages", "\"fr\"", "-o", expectedFilesPath, "--source-language", "en") 58 | Ω(session.ExitCode()).Should(Equal(1)) 59 | Ω(session).Should(gbytes.Say("Duplicated key found: Show quota info")) 60 | }) 61 | }) 62 | }) 63 | 64 | }) 65 | -------------------------------------------------------------------------------- /integration/verify_strings/verify_strings_suite_test.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2015-2023 The Knative Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package verify_strings_test 16 | 17 | import ( 18 | . "github.com/onsi/ginkgo" 19 | . "github.com/onsi/gomega" 20 | 21 | "github.com/maximilien/i18n4go/integration/test_helpers" 22 | "github.com/onsi/gomega/gexec" 23 | 24 | "testing" 25 | ) 26 | 27 | func TestVerifyStrings(t *testing.T) { 28 | BeforeSuite(test_helpers.BuildExecutable) 29 | 30 | AfterSuite(func() { 31 | gexec.CleanupBuildArtifacts() 32 | }) 33 | 34 | RegisterFailHandler(Fail) 35 | RunSpecs(t, "VerifyStrings Suite") 36 | } 37 | -------------------------------------------------------------------------------- /slack/badge.svg: -------------------------------------------------------------------------------- 1 | slackslack1/101/10 -------------------------------------------------------------------------------- /slack/slack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maximilien/i18n4go/8e4b0eee96160b18bb331fb747da97cac43a6225/slack/slack.png -------------------------------------------------------------------------------- /test_fixtures/checkup/allgood/src/code/main.go: -------------------------------------------------------------------------------- 1 | package code 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Println(T("Translated hello world!")) 7 | } 8 | -------------------------------------------------------------------------------- /test_fixtures/checkup/allgood/translations/en_US.all.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Translated hello world!", 4 | "translation": "Translated hello world!" 5 | } 6 | ] 7 | -------------------------------------------------------------------------------- /test_fixtures/checkup/allgood/translations/zh_CN.all.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Translated hello world!", 4 | "translation": "你好世界!" 5 | } 6 | ] 7 | -------------------------------------------------------------------------------- /test_fixtures/checkup/fileformat/src/code/main.go: -------------------------------------------------------------------------------- 1 | package code 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Println(T("Translated hello world!")) 7 | } 8 | -------------------------------------------------------------------------------- /test_fixtures/checkup/fileformat/translations/all.en_US.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Translated hello world!", 4 | "translation": "Translated hello world!" 5 | } 6 | ] 7 | -------------------------------------------------------------------------------- /test_fixtures/checkup/fileformat/translations/all.zh_CN.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Translated hello world!", 4 | "translation": "你好世界!" 5 | } 6 | ] 7 | -------------------------------------------------------------------------------- /test_fixtures/checkup/notsogood/src/code/main.go: -------------------------------------------------------------------------------- 1 | package code 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Println(T("Translated hello world!")) 7 | fmt.Printf(T("Heal the world")) 8 | } 9 | -------------------------------------------------------------------------------- /test_fixtures/checkup/notsogood/src/code/mypackage/thing.go: -------------------------------------------------------------------------------- 1 | package mypackage 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func myFunc() { 8 | fmt.Println(T("And the entire human race")) 9 | } 10 | -------------------------------------------------------------------------------- /test_fixtures/checkup/notsogood/translations/en_US.all.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Translated hello world!", 4 | "translation": "Translated hello world!" 5 | }, 6 | { 7 | "id": "Make it a better place", 8 | "translation": "Make it a better place" 9 | }, 10 | { 11 | "id": "And the entire human race", 12 | "translation": "And the entire human race" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /test_fixtures/checkup/notsogood/translations/zh_CN.all.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Translated hello world!", 4 | "translation": "你好世界!" 5 | }, 6 | { 7 | "id": "Make it a better place", 8 | "translation": "创造一个更好的地方" 9 | }, 10 | { 11 | "id": "For you and for me", 12 | "translation": "为你,为我" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /test_fixtures/checkup/qualified/src/code/main.go: -------------------------------------------------------------------------------- 1 | package code 2 | 3 | import ( 4 | "fmt" 5 | 6 | i18n "github.com/maximilien/i18n4go/i18n4go/cmds" 7 | ) 8 | 9 | func main() { 10 | fmt.Println(i18n.T("Translated hello world!")) 11 | } 12 | -------------------------------------------------------------------------------- /test_fixtures/checkup/qualified/translations/en_US.all.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Translated hello world!", 4 | "translation": "Translated hello world!" 5 | } 6 | ] 7 | -------------------------------------------------------------------------------- /test_fixtures/checkup/qualified/translations/zh_CN.all.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Translated hello world!", 4 | "translation": "你好世界!" 5 | } 6 | ] 7 | -------------------------------------------------------------------------------- /test_fixtures/checkup/variable/src/code/main.go: -------------------------------------------------------------------------------- 1 | package code 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | locale := "Translated hello world!" 7 | fmt.Println(T(locale)) 8 | locale = "For you and for me" 9 | fmt.Println(T(locale)) 10 | locale = "I like bananas" 11 | fmt.Println(T(locale)) 12 | } 13 | -------------------------------------------------------------------------------- /test_fixtures/checkup/variable/translations/en_US.all.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Translated hello world!", 4 | "translation": "Translated hello world!" 5 | }, 6 | { 7 | "id": "For you and for me", 8 | "translation": "For you and for me" 9 | }, 10 | { 11 | "id": "I like bananas", 12 | "translation": "I like bananas" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /test_fixtures/checkup/variable/translations/zh_CN.all.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Translated hello world!", 4 | "translation": "你好世界!" 5 | }, 6 | { 7 | "id": "For you and for me", 8 | "translation": "为你,为我" 9 | }, 10 | { 11 | "id": "I like bananas", 12 | "translation": "我喜欢吃香蕉" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /test_fixtures/create_translations/f_option/input_files/quota.go.en.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Show quota info", 4 | "translation": "Show quota info" 5 | }, 6 | { 7 | "id": "Routes", 8 | "translation": "Routes" 9 | }, 10 | { 11 | "id": "Services", 12 | "translation": "Services" 13 | }, 14 | { 15 | "id": "CF_NAME quota QUOTA", 16 | "translation": "CF_NAME quota QUOTA" 17 | }, 18 | { 19 | "id": "Getting quota {{.QuotaName}} info as {{.Username}}...", 20 | "translation": "Getting quota {{.QuotaName}} info as {{.Username}}..." 21 | }, 22 | { 23 | "id": "Memory", 24 | "translation": "Memory" 25 | }, 26 | { 27 | "id": "Paid service plans", 28 | "translation": "Paid service plans" 29 | } 30 | ] 31 | -------------------------------------------------------------------------------- /test_fixtures/create_translations/f_option/input_files/quota.go.ja.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/expected_output/create_org.go.en.json: -------------------------------------------------------------------------------- 1 | [{"id":"Create an org","translation":"Create an org"},{"id":"CF_NAME create-org ORG","translation":"CF_NAME create-org ORG"},{"id":" target -o ","translation":" target -o "},{"id":"create-org","translation":"create-org"},{"id":"co","translation":"co"},{"id":"Incorrect Usage","translation":"Incorrect Usage"},{"id":"Creating org %s as %s...","translation":"Creating org %s as %s..."},{"id":"Org %s already exists","translation":"Org %s already exists"},{"id":"\nTIP: Use '%s' to target new org","translation":"\nTIP: Use '%s' to target new org"}] 2 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/expected_output/create_org.go.en.po: -------------------------------------------------------------------------------- 1 | # filename: d_option/input_files/org/create_org.go, offset: 793, line: 29, column: 16 2 | msgid "create-org" 3 | msgstr "create-org" 4 | 5 | # filename: d_option/input_files/org/create_org.go, offset: 822, line: 30, column: 16 6 | msgid "co" 7 | msgstr "co" 8 | 9 | # filename: d_option/input_files/org/create_org.go, offset: 1093, line: 38, column: 20 10 | msgid "Incorrect Usage" 11 | msgstr "Incorrect Usage" 12 | 13 | # filename: d_option/input_files/org/create_org.go, offset: 1323, line: 52, column: 13 14 | msgid "Creating org %s as %s..." 15 | msgstr "Creating org %s as %s..." 16 | 17 | # filename: d_option/input_files/org/create_org.go, offset: 1610, line: 60, column: 16 18 | msgid "Org %s already exists" 19 | msgstr "Org %s already exists" 20 | 21 | # filename: d_option/input_files/org/create_org.go, offset: 1725, line: 68, column: 13 22 | msgid "\nTIP: Use '%s' to target new org" 23 | msgstr "\nTIP: Use '%s' to target new org" 24 | 25 | # filename: d_option/input_files/org/create_org.go, offset: 843, line: 31, column: 16 26 | msgid "Create an org" 27 | msgstr "Create an org" 28 | 29 | # filename: d_option/input_files/org/create_org.go, offset: 875, line: 32, column: 16 30 | msgid "CF_NAME create-org ORG" 31 | msgstr "CF_NAME create-org ORG" 32 | 33 | # filename: d_option/input_files/org/create_org.go, offset: 1794, line: 68, column: 82 34 | msgid " target -o " 35 | msgstr " target -o " 36 | 37 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/expected_output/create_org.go.extracted.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/create_org.go", 4 | "value": "co", 5 | "offset": 489, 6 | "line": 21, 7 | "column": 16 8 | }, 9 | { 10 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/create_org.go", 11 | "value": "Incorrect Usage", 12 | "offset": 760, 13 | "line": 29, 14 | "column": 20 15 | }, 16 | { 17 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/create_org.go", 18 | "value": "Creating org %s as %s...", 19 | "offset": 990, 20 | "line": 43, 21 | "column": 13 22 | }, 23 | { 24 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/create_org.go", 25 | "value": "\nTIP: Use '%s' to target new org", 26 | "offset": 1392, 27 | "line": 59, 28 | "column": 13 29 | }, 30 | { 31 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/create_org.go", 32 | "value": " target -o ", 33 | "offset": 1461, 34 | "line": 59, 35 | "column": 82 36 | }, 37 | { 38 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/create_org.go", 39 | "value": "create-org", 40 | "offset": 460, 41 | "line": 20, 42 | "column": 16 43 | }, 44 | { 45 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/create_org.go", 46 | "value": "Create an org", 47 | "offset": 510, 48 | "line": 22, 49 | "column": 16 50 | }, 51 | { 52 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/create_org.go", 53 | "value": "CF_NAME create-org ORG", 54 | "offset": 542, 55 | "line": 23, 56 | "column": 16 57 | }, 58 | { 59 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/create_org.go", 60 | "value": "Org %s already exists", 61 | "offset": 1277, 62 | "line": 51, 63 | "column": 16 64 | } 65 | ] -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/expected_output/create_quota.go.en.json: -------------------------------------------------------------------------------- 1 | [{"id":"Define a new resource quota","translation":"Define a new resource quota"},{"id":"Total amount of memory (e.g. 1024M, 1G, 10G)","translation":"Total amount of memory (e.g. 1024M, 1G, 10G)"},{"id":"Total number of routes","translation":"Total number of routes"},{"id":"s","translation":"s"},{"id":"Invalid memory limit: %s\n%s","translation":"Invalid memory limit: %s\n%s"},{"id":"Quota Definition %s already exists","translation":"Quota Definition %s already exists"},{"id":"CF_NAME create-quota QUOTA [-m MEMORY] [-r ROUTES] [-s SERVICE_INSTANCES] [--allow-paid-service-plans]","translation":"CF_NAME create-quota QUOTA [-m MEMORY] [-r ROUTES] [-s SERVICE_INSTANCES] [--allow-paid-service-plans]"},{"id":"Creating quota %s as %s...","translation":"Creating quota %s as %s..."},{"id":"create-quota","translation":"create-quota"},{"id":"m","translation":"m"},{"id":"r","translation":"r"},{"id":"Total number of service instances","translation":"Total number of service instances"},{"id":"allow-paid-service-plans","translation":"allow-paid-service-plans"},{"id":"Can provision instances of paid service plans","translation":"Can provision instances of paid service plans"}] 2 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/expected_output/create_quota.go.en.po: -------------------------------------------------------------------------------- 1 | # filename: d_option/input_files/quota/create_quota.go, offset: 933, line: 33, column: 16 2 | msgid "Define a new resource quota" 3 | msgstr "Define a new resource quota" 4 | 5 | # filename: d_option/input_files/quota/create_quota.go, offset: 1141, line: 36, column: 36 6 | msgid "Total amount of memory (e.g. 1024M, 1G, 10G)" 7 | msgstr "Total amount of memory (e.g. 1024M, 1G, 10G)" 8 | 9 | # filename: d_option/input_files/quota/create_quota.go, offset: 1222, line: 37, column: 33 10 | msgid "Total number of routes" 11 | msgstr "Total number of routes" 12 | 13 | # filename: d_option/input_files/quota/create_quota.go, offset: 2385, line: 80, column: 37 14 | msgid "s" 15 | msgstr "s" 16 | 17 | # filename: d_option/input_files/quota/create_quota.go, offset: 2162, line: 69, column: 18 18 | msgid "Invalid memory limit: %s\n%s" 19 | msgstr "Invalid memory limit: %s\n%s" 20 | 21 | # filename: d_option/input_files/quota/create_quota.go, offset: 2644, line: 92, column: 15 22 | msgid "Quota Definition %s already exists" 23 | msgstr "Quota Definition %s already exists" 24 | 25 | # filename: d_option/input_files/quota/create_quota.go, offset: 979, line: 34, column: 16 26 | msgid "CF_NAME create-quota QUOTA [-m MEMORY] [-r ROUTES] [-s SERVICE_INSTANCES] [--allow-paid-service-plans]" 27 | msgstr "CF_NAME create-quota QUOTA [-m MEMORY] [-r ROUTES] [-s SERVICE_INSTANCES] [--allow-paid-service-plans]" 28 | 29 | # filename: d_option/input_files/quota/create_quota.go, offset: 1844, line: 57, column: 13 30 | msgid "Creating quota %s as %s..." 31 | msgstr "Creating quota %s as %s..." 32 | 33 | # filename: d_option/input_files/quota/create_quota.go, offset: 1641, line: 46, column: 33 34 | msgid "create-quota" 35 | msgstr "create-quota" 36 | 37 | # filename: d_option/input_files/quota/create_quota.go, offset: 2039, line: 65, column: 32 38 | msgid "m" 39 | msgstr "m" 40 | 41 | # filename: d_option/input_files/quota/create_quota.go, offset: 2315, line: 76, column: 35 42 | msgid "r" 43 | msgstr "r" 44 | 45 | # filename: d_option/input_files/quota/create_quota.go, offset: 1281, line: 38, column: 33 46 | msgid "Total number of service instances" 47 | msgstr "Total number of service instances" 48 | 49 | # filename: d_option/input_files/quota/create_quota.go, offset: 2412, line: 83, column: 19 50 | msgid "allow-paid-service-plans" 51 | msgstr "allow-paid-service-plans" 52 | 53 | # filename: d_option/input_files/quota/create_quota.go, offset: 1376, line: 39, column: 58 54 | msgid "Can provision instances of paid service plans" 55 | msgstr "Can provision instances of paid service plans" 56 | 57 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/expected_output/delete_org.go.en.json: -------------------------------------------------------------------------------- 1 | [{"id":"Delete an org","translation":"Delete an org"},{"id":"CF_NAME delete-org ORG [-f]","translation":"CF_NAME delete-org ORG [-f]"},{"id":"Force deletion without confirmation","translation":"Force deletion without confirmation"},{"id":"Incorrect Usage","translation":"Incorrect Usage"},{"id":"org","translation":"org"},{"id":"Org %s does not exist.","translation":"Org %s does not exist."},{"id":"delete-org","translation":"delete-org"},{"id":"f","translation":"f"},{"id":"Deleting org %s as %s...","translation":"Deleting org %s as %s..."}] 2 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/expected_output/delete_org.go.en.po: -------------------------------------------------------------------------------- 1 | # filename: d_option/input_files/org/delete_org.go, offset: 907, line: 32, column: 16 2 | msgid "Delete an org" 3 | msgstr "Delete an org" 4 | 5 | # filename: d_option/input_files/org/delete_org.go, offset: 939, line: 33, column: 16 6 | msgid "CF_NAME delete-org ORG [-f]" 7 | msgstr "CF_NAME delete-org ORG [-f]" 8 | 9 | # filename: d_option/input_files/org/delete_org.go, offset: 1025, line: 35, column: 35 10 | msgid "Force deletion without confirmation" 11 | msgstr "Force deletion without confirmation" 12 | 13 | # filename: d_option/input_files/org/delete_org.go, offset: 1263, line: 42, column: 20 14 | msgid "Incorrect Usage" 15 | msgstr "Incorrect Usage" 16 | 17 | # filename: d_option/input_files/org/delete_org.go, offset: 1541, line: 55, column: 44 18 | msgid "org" 19 | msgstr "org" 20 | 21 | # filename: d_option/input_files/org/delete_org.go, offset: 1855, line: 71, column: 15 22 | msgid "Org %s does not exist." 23 | msgstr "Org %s does not exist." 24 | 25 | # filename: d_option/input_files/org/delete_org.go, offset: 878, line: 31, column: 16 26 | msgid "delete-org" 27 | msgstr "delete-org" 28 | 29 | # filename: d_option/input_files/org/delete_org.go, offset: 1491, line: 54, column: 13 30 | msgid "f" 31 | msgstr "f" 32 | 33 | # filename: d_option/input_files/org/delete_org.go, offset: 1589, line: 60, column: 13 34 | msgid "Deleting org %s as %s..." 35 | msgstr "Deleting org %s as %s..." 36 | 37 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/expected_output/delete_org.go.extracted.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/delete_org.go", 4 | "value": "Delete an org", 5 | "offset": 567, 6 | "line": 23, 7 | "column": 16 8 | }, 9 | { 10 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/delete_org.go", 11 | "value": "f", 12 | "offset": 1151, 13 | "line": 45, 14 | "column": 13 15 | }, 16 | { 17 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/delete_org.go", 18 | "value": "delete-org", 19 | "offset": 538, 20 | "line": 22, 21 | "column": 16 22 | }, 23 | { 24 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/delete_org.go", 25 | "value": "CF_NAME delete-org ORG [-f]", 26 | "offset": 599, 27 | "line": 24, 28 | "column": 16 29 | }, 30 | { 31 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/delete_org.go", 32 | "value": "Force deletion without confirmation", 33 | "offset": 685, 34 | "line": 26, 35 | "column": 35 36 | }, 37 | { 38 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/delete_org.go", 39 | "value": "Incorrect Usage", 40 | "offset": 923, 41 | "line": 33, 42 | "column": 20 43 | }, 44 | { 45 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/delete_org.go", 46 | "value": "org", 47 | "offset": 1201, 48 | "line": 46, 49 | "column": 44 50 | }, 51 | { 52 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/delete_org.go", 53 | "value": "Deleting org %s as %s...", 54 | "offset": 1249, 55 | "line": 51, 56 | "column": 13 57 | }, 58 | { 59 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/delete_org.go", 60 | "value": "Org %s does not exist.", 61 | "offset": 1515, 62 | "line": 62, 63 | "column": 15 64 | } 65 | ] -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/expected_output/delete_quota.go.en.json: -------------------------------------------------------------------------------- 1 | [{"id":"Delete a quota","translation":"Delete a quota"},{"id":"CF_NAME delete-quota QUOTA [-f]","translation":"CF_NAME delete-quota QUOTA [-f]"},{"id":"Incorrect Usage","translation":"Incorrect Usage"},{"id":"Deleting quota %s as %s...","translation":"Deleting quota %s as %s..."},{"id":"delete-quota","translation":"delete-quota"},{"id":"f","translation":"f"},{"id":"Force deletion without confirmation","translation":"Force deletion without confirmation"},{"id":"quota","translation":"quota"},{"id":"Quota %s does not exist","translation":"Quota %s does not exist"}] 2 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/expected_output/delete_quota.go.en.po: -------------------------------------------------------------------------------- 1 | # filename: d_option/input_files/quota/delete_quota.go, offset: 863, line: 31, column: 16 2 | msgid "Delete a quota" 3 | msgstr "Delete a quota" 4 | 5 | # filename: d_option/input_files/quota/delete_quota.go, offset: 896, line: 32, column: 16 6 | msgid "CF_NAME delete-quota QUOTA [-f]" 7 | msgstr "CF_NAME delete-quota QUOTA [-f]" 8 | 9 | # filename: d_option/input_files/quota/delete_quota.go, offset: 1226, line: 41, column: 20 10 | msgid "Incorrect Usage" 11 | msgstr "Incorrect Usage" 12 | 13 | # filename: d_option/input_files/quota/delete_quota.go, offset: 1589, line: 62, column: 13 14 | msgid "Deleting quota %s as %s..." 15 | msgstr "Deleting quota %s as %s..." 16 | 17 | # filename: d_option/input_files/quota/delete_quota.go, offset: 1271, line: 42, column: 27 18 | msgid "delete-quota" 19 | msgstr "delete-quota" 20 | 21 | # filename: d_option/input_files/quota/delete_quota.go, offset: 1480, line: 55, column: 13 22 | msgid "f" 23 | msgstr "f" 24 | 25 | # filename: d_option/input_files/quota/delete_quota.go, offset: 986, line: 34, column: 35 26 | msgid "Force deletion without confirmation" 27 | msgstr "Force deletion without confirmation" 28 | 29 | # filename: d_option/input_files/quota/delete_quota.go, offset: 1522, line: 56, column: 36 30 | msgid "quota" 31 | msgstr "quota" 32 | 33 | # filename: d_option/input_files/quota/delete_quota.go, offset: 1879, line: 73, column: 15 34 | msgid "Quota %s does not exist" 35 | msgstr "Quota %s does not exist" 36 | 37 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/expected_output/delete_quota.go.extracted.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/quota/delete_quota.go", 4 | "value": "Delete a quota", 5 | "offset": 564, 6 | "line": 23, 7 | "column": 16 8 | }, 9 | { 10 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/quota/delete_quota.go", 11 | "value": "CF_NAME delete-quota QUOTA [-f]", 12 | "offset": 597, 13 | "line": 24, 14 | "column": 16 15 | }, 16 | { 17 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/quota/delete_quota.go", 18 | "value": "f", 19 | "offset": 1181, 20 | "line": 47, 21 | "column": 13 22 | }, 23 | { 24 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/quota/delete_quota.go", 25 | "value": "Incorrect Usage", 26 | "offset": 927, 27 | "line": 33, 28 | "column": 20 29 | }, 30 | { 31 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/quota/delete_quota.go", 32 | "value": "delete-quota", 33 | "offset": 972, 34 | "line": 34, 35 | "column": 27 36 | }, 37 | { 38 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/quota/delete_quota.go", 39 | "value": "Force deletion without confirmation", 40 | "offset": 687, 41 | "line": 26, 42 | "column": 35 43 | }, 44 | { 45 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/quota/delete_quota.go", 46 | "value": "quota", 47 | "offset": 1223, 48 | "line": 48, 49 | "column": 36 50 | }, 51 | { 52 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/quota/delete_quota.go", 53 | "value": "Deleting quota %s as %s...", 54 | "offset": 1290, 55 | "line": 54, 56 | "column": 13 57 | }, 58 | { 59 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/quota/delete_quota.go", 60 | "value": "Quota %s does not exist", 61 | "offset": 1580, 62 | "line": 65, 63 | "column": 15 64 | } 65 | ] -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/expected_output/org.go.en.json: -------------------------------------------------------------------------------- 1 | [{"id":"org","translation":"org"},{"id":"Show org info","translation":"Show org info"},{"id":"CF_NAME org ORG","translation":"CF_NAME org ORG"},{"id":"Incorrect Usage","translation":"Incorrect Usage"},{"id":"Getting info for org %s as %s...","translation":"Getting info for org %s as %s..."},{"id":"\n%s:","translation":"\n%s:"},{"id":"%s (%dM memory limit, %d routes, %d services, paid services %s)","translation":"%s (%dM memory limit, %d routes, %d services, paid services %s)"},{"id":" domains: %s","translation":" domains: %s"},{"id":" quota: %s","translation":" quota: %s"},{"id":" spaces: %s","translation":" spaces: %s"}] 2 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/expected_output/org.go.en.po: -------------------------------------------------------------------------------- 1 | # filename: d_option/input_files/org/org.go, offset: 715, line: 30, column: 16 2 | msgid "org" 3 | msgstr "org" 4 | 5 | # filename: d_option/input_files/org/org.go, offset: 737, line: 31, column: 16 6 | msgid "Show org info" 7 | msgstr "Show org info" 8 | 9 | # filename: d_option/input_files/org/org.go, offset: 769, line: 32, column: 16 10 | msgid "CF_NAME org ORG" 11 | msgstr "CF_NAME org ORG" 12 | 13 | # filename: d_option/input_files/org/org.go, offset: 979, line: 38, column: 20 14 | msgid "Incorrect Usage" 15 | msgstr "Incorrect Usage" 16 | 17 | # filename: d_option/input_files/org/org.go, offset: 1312, line: 54, column: 13 18 | msgid "Getting info for org %s as %s..." 19 | msgstr "Getting info for org %s as %s..." 20 | 21 | # filename: d_option/input_files/org/org.go, offset: 1465, line: 59, column: 13 22 | msgid "\n%s:" 23 | msgstr "\n%s:" 24 | 25 | # filename: d_option/input_files/org/org.go, offset: 1772, line: 72, column: 26 26 | msgid "%s (%dM memory limit, %d routes, %d services, paid services %s)" 27 | msgstr "%s (%dM memory limit, %d routes, %d services, paid services %s)" 28 | 29 | # filename: d_option/input_files/org/org.go, offset: 1976, line: 75, column: 13 30 | msgid " domains: %s" 31 | msgstr " domains: %s" 32 | 33 | # filename: d_option/input_files/org/org.go, offset: 2060, line: 76, column: 13 34 | msgid " quota: %s" 35 | msgstr " quota: %s" 36 | 37 | # filename: d_option/input_files/org/org.go, offset: 2125, line: 77, column: 13 38 | msgid " spaces: %s" 39 | msgstr " spaces: %s" 40 | 41 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/expected_output/org.go.extracted.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/org.go", 4 | "value": "Getting info for org %s as %s...", 5 | "offset": 1019, 6 | "line": 44, 7 | "column": 13 8 | }, 9 | { 10 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/org.go", 11 | "value": "%s (%dM memory limit, %d routes, %d services, paid services %s)", 12 | "offset": 1479, 13 | "line": 62, 14 | "column": 26 15 | }, 16 | { 17 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/org.go", 18 | "value": " domains: %s", 19 | "offset": 1683, 20 | "line": 65, 21 | "column": 13 22 | }, 23 | { 24 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/org.go", 25 | "value": " spaces: %s", 26 | "offset": 1832, 27 | "line": 67, 28 | "column": 13 29 | }, 30 | { 31 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/org.go", 32 | "value": "org", 33 | "offset": 422, 34 | "line": 20, 35 | "column": 16 36 | }, 37 | { 38 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/org.go", 39 | "value": "Show org info", 40 | "offset": 444, 41 | "line": 21, 42 | "column": 16 43 | }, 44 | { 45 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/org.go", 46 | "value": "CF_NAME org ORG", 47 | "offset": 476, 48 | "line": 22, 49 | "column": 16 50 | }, 51 | { 52 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/org.go", 53 | "value": "Incorrect Usage", 54 | "offset": 686, 55 | "line": 28, 56 | "column": 20 57 | }, 58 | { 59 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/org.go", 60 | "value": "\n%s:", 61 | "offset": 1172, 62 | "line": 49, 63 | "column": 13 64 | }, 65 | { 66 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/org.go", 67 | "value": " quota: %s", 68 | "offset": 1767, 69 | "line": 66, 70 | "column": 13 71 | } 72 | ] -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/expected_output/orgs.go.en.json: -------------------------------------------------------------------------------- 1 | [{"id":"orgs","translation":"orgs"},{"id":"o","translation":"o"},{"id":"List all orgs","translation":"List all orgs"},{"id":"CF_NAME orgs","translation":"CF_NAME orgs"},{"id":"Getting orgs as %s...\n","translation":"Getting orgs as %s...\n"},{"id":"name","translation":"name"},{"id":"Failed fetching orgs.\n%s","translation":"Failed fetching orgs.\n%s"},{"id":"No orgs found","translation":"No orgs found"}] 2 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/expected_output/orgs.go.en.po: -------------------------------------------------------------------------------- 1 | # filename: d_option/input_files/org/orgs.go, offset: 755, line: 28, column: 16 2 | msgid "orgs" 3 | msgstr "orgs" 4 | 5 | # filename: d_option/input_files/org/orgs.go, offset: 778, line: 29, column: 16 6 | msgid "o" 7 | msgstr "o" 8 | 9 | # filename: d_option/input_files/org/orgs.go, offset: 798, line: 30, column: 16 10 | msgid "List all orgs" 11 | msgstr "List all orgs" 12 | 13 | # filename: d_option/input_files/org/orgs.go, offset: 830, line: 31, column: 16 14 | msgid "CF_NAME orgs" 15 | msgstr "CF_NAME orgs" 16 | 17 | # filename: d_option/input_files/org/orgs.go, offset: 1142, line: 43, column: 13 18 | msgid "Getting orgs as %s...\n" 19 | msgstr "Getting orgs as %s...\n" 20 | 21 | # filename: d_option/input_files/org/orgs.go, offset: 1267, line: 46, column: 33 22 | msgid "name" 23 | msgstr "name" 24 | 25 | # filename: d_option/input_files/org/orgs.go, offset: 1465, line: 56, column: 17 26 | msgid "Failed fetching orgs.\n%s" 27 | msgstr "Failed fetching orgs.\n%s" 28 | 29 | # filename: d_option/input_files/org/orgs.go, offset: 1541, line: 61, column: 14 30 | msgid "No orgs found" 31 | msgstr "No orgs found" 32 | 33 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/expected_output/orgs.go.extracted.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/orgs.go", 4 | "value": "orgs", 5 | "offset": 456, 6 | "line": 20, 7 | "column": 16 8 | }, 9 | { 10 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/orgs.go", 11 | "value": "o", 12 | "offset": 479, 13 | "line": 21, 14 | "column": 16 15 | }, 16 | { 17 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/orgs.go", 18 | "value": "List all orgs", 19 | "offset": 499, 20 | "line": 22, 21 | "column": 16 22 | }, 23 | { 24 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/orgs.go", 25 | "value": "CF_NAME orgs", 26 | "offset": 531, 27 | "line": 23, 28 | "column": 16 29 | }, 30 | { 31 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/orgs.go", 32 | "value": "Getting orgs as %s...\n", 33 | "offset": 843, 34 | "line": 35, 35 | "column": 13 36 | }, 37 | { 38 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/orgs.go", 39 | "value": "name", 40 | "offset": 968, 41 | "line": 38, 42 | "column": 33 43 | }, 44 | { 45 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/orgs.go", 46 | "value": "Failed fetching orgs.\n%s", 47 | "offset": 1166, 48 | "line": 48, 49 | "column": 17 50 | }, 51 | { 52 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/orgs.go", 53 | "value": "No orgs found", 54 | "offset": 1242, 55 | "line": 53, 56 | "column": 14 57 | } 58 | ] -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/expected_output/quota.go.en.json: -------------------------------------------------------------------------------- 1 | [{"id":"Show quota info","translation":"Show quota info"},{"id":"quotas","translation":"quotas"},{"id":"Routes","translation":"Routes"},{"id":"%d","translation":"%d"},{"id":"Services","translation":"Services"},{"id":"quota","translation":"quota"},{"id":"CF_NAME quota QUOTA","translation":"CF_NAME quota QUOTA"},{"id":"Getting quota %s info as %s...","translation":"Getting quota %s info as %s..."},{"id":"Memory","translation":"Memory"},{"id":"Paid service plans","translation":"Paid service plans"}] 2 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/expected_output/quota.go.en.po: -------------------------------------------------------------------------------- 1 | # filename: d_option/input_files/quota/quota.go, offset: 773, line: 30, column: 16 2 | msgid "quota" 3 | msgstr "quota" 4 | 5 | # filename: d_option/input_files/quota/quota.go, offset: 797, line: 31, column: 16 6 | msgid "CF_NAME quota QUOTA" 7 | msgstr "CF_NAME quota QUOTA" 8 | 9 | # filename: d_option/input_files/quota/quota.go, offset: 1263, line: 48, column: 13 10 | msgid "Getting quota %s info as %s..." 11 | msgstr "Getting quota %s info as %s..." 12 | 13 | # filename: d_option/input_files/quota/quota.go, offset: 1521, line: 58, column: 21 14 | msgid "Memory" 15 | msgstr "Memory" 16 | 17 | # filename: d_option/input_files/quota/quota.go, offset: 1756, line: 61, column: 21 18 | msgid "Paid service plans" 19 | msgstr "Paid service plans" 20 | 21 | # filename: d_option/input_files/quota/quota.go, offset: 835, line: 32, column: 16 22 | msgid "Show quota info" 23 | msgstr "Show quota info" 24 | 25 | # filename: d_option/input_files/quota/quota.go, offset: 1063, line: 38, column: 33 26 | msgid "quotas" 27 | msgstr "quotas" 28 | 29 | # filename: d_option/input_files/quota/quota.go, offset: 1614, line: 59, column: 21 30 | msgid "Routes" 31 | msgstr "Routes" 32 | 33 | # filename: d_option/input_files/quota/quota.go, offset: 1707, line: 60, column: 45 34 | msgid "%d" 35 | msgstr "%d" 36 | 37 | # filename: d_option/input_files/quota/quota.go, offset: 1683, line: 60, column: 21 38 | msgid "Services" 39 | msgstr "Services" 40 | 41 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/expected_output/quota.go.extracted.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/quota/quota.go", 4 | "value": "quota", 5 | "offset": 463, 6 | "line": 21, 7 | "column": 16 8 | }, 9 | { 10 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/quota/quota.go", 11 | "value": "Show quota info", 12 | "offset": 525, 13 | "line": 23, 14 | "column": 16 15 | }, 16 | { 17 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/quota/quota.go", 18 | "value": "Getting quota %s info as %s...", 19 | "offset": 953, 20 | "line": 39, 21 | "column": 13 22 | }, 23 | { 24 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/quota/quota.go", 25 | "value": "Routes", 26 | "offset": 1304, 27 | "line": 50, 28 | "column": 21 29 | }, 30 | { 31 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/quota/quota.go", 32 | "value": "Services", 33 | "offset": 1373, 34 | "line": 51, 35 | "column": 21 36 | }, 37 | { 38 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/quota/quota.go", 39 | "value": "Paid service plans", 40 | "offset": 1446, 41 | "line": 52, 42 | "column": 21 43 | }, 44 | { 45 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/quota/quota.go", 46 | "value": "CF_NAME quota QUOTA", 47 | "offset": 487, 48 | "line": 22, 49 | "column": 16 50 | }, 51 | { 52 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/quota/quota.go", 53 | "value": "quotas", 54 | "offset": 753, 55 | "line": 29, 56 | "column": 33 57 | }, 58 | { 59 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/quota/quota.go", 60 | "value": "Memory", 61 | "offset": 1211, 62 | "line": 49, 63 | "column": 21 64 | }, 65 | { 66 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/quota/quota.go", 67 | "value": "%d", 68 | "offset": 1397, 69 | "line": 51, 70 | "column": 45 71 | } 72 | ] -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/expected_output/quotas.go.en.json: -------------------------------------------------------------------------------- 1 | [{"id":"List available usage quotas","translation":"List available usage quotas"},{"id":"CF_NAME quotas","translation":"CF_NAME quotas"},{"id":"name","translation":"name"},{"id":"routes","translation":"routes"},{"id":"service instances","translation":"service instances"},{"id":"paid service plans","translation":"paid service plans"},{"id":"quotas","translation":"quotas"},{"id":"Getting quotas as %s...","translation":"Getting quotas as %s..."},{"id":"memory limit","translation":"memory limit"},{"id":"%d","translation":"%d"}] 2 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/expected_output/quotas.go.en.po: -------------------------------------------------------------------------------- 1 | # filename: d_option/input_files/quota/quotas.go, offset: 815, line: 31, column: 16 2 | msgid "List available usage quotas" 3 | msgstr "List available usage quotas" 4 | 5 | # filename: d_option/input_files/quota/quotas.go, offset: 861, line: 32, column: 16 6 | msgid "CF_NAME quotas" 7 | msgstr "CF_NAME quotas" 8 | 9 | # filename: d_option/input_files/quota/quotas.go, offset: 1441, line: 55, column: 46 10 | msgid "name" 11 | msgstr "name" 12 | 13 | # filename: d_option/input_files/quota/quotas.go, offset: 1465, line: 55, column: 70 14 | msgid "routes" 15 | msgstr "routes" 16 | 17 | # filename: d_option/input_files/quota/quotas.go, offset: 1475, line: 55, column: 80 18 | msgid "service instances" 19 | msgstr "service instances" 20 | 21 | # filename: d_option/input_files/quota/quotas.go, offset: 1496, line: 55, column: 101 22 | msgid "paid service plans" 23 | msgstr "paid service plans" 24 | 25 | # filename: d_option/input_files/quota/quotas.go, offset: 790, line: 30, column: 16 26 | msgid "quotas" 27 | msgstr "quotas" 28 | 29 | # filename: d_option/input_files/quota/quotas.go, offset: 1181, line: 44, column: 13 30 | msgid "Getting quotas as %s..." 31 | msgstr "Getting quotas as %s..." 32 | 33 | # filename: d_option/input_files/quota/quotas.go, offset: 1449, line: 55, column: 54 34 | msgid "memory limit" 35 | msgstr "memory limit" 36 | 37 | # filename: d_option/input_files/quota/quotas.go, offset: 1710, line: 62, column: 16 38 | msgid "%d" 39 | msgstr "%d" 40 | 41 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/expected_output/quotas.go.extracted.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/quota/quotas.go", 4 | "value": "quotas", 5 | "offset": 480, 6 | "line": 21, 7 | "column": 16 8 | }, 9 | { 10 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/quota/quotas.go", 11 | "value": "Getting quotas as %s...", 12 | "offset": 871, 13 | "line": 35, 14 | "column": 13 15 | }, 16 | { 17 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/quota/quotas.go", 18 | "value": "memory limit", 19 | "offset": 1139, 20 | "line": 46, 21 | "column": 54 22 | }, 23 | { 24 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/quota/quotas.go", 25 | "value": "routes", 26 | "offset": 1155, 27 | "line": 46, 28 | "column": 70 29 | }, 30 | { 31 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/quota/quotas.go", 32 | "value": "service instances", 33 | "offset": 1165, 34 | "line": 46, 35 | "column": 80 36 | }, 37 | { 38 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/quota/quotas.go", 39 | "value": "%d", 40 | "offset": 1400, 41 | "line": 53, 42 | "column": 16 43 | }, 44 | { 45 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/quota/quotas.go", 46 | "value": "List available usage quotas", 47 | "offset": 505, 48 | "line": 22, 49 | "column": 16 50 | }, 51 | { 52 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/quota/quotas.go", 53 | "value": "CF_NAME quotas", 54 | "offset": 551, 55 | "line": 23, 56 | "column": 16 57 | }, 58 | { 59 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/quota/quotas.go", 60 | "value": "name", 61 | "offset": 1131, 62 | "line": 46, 63 | "column": 46 64 | }, 65 | { 66 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/quota/quotas.go", 67 | "value": "paid service plans", 68 | "offset": 1186, 69 | "line": 46, 70 | "column": 101 71 | } 72 | ] -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/expected_output/rename_org.go.en.json: -------------------------------------------------------------------------------- 1 | [{"id":"rename-org","translation":"rename-org"},{"id":"Rename an org","translation":"Rename an org"},{"id":"CF_NAME rename-org ORG NEW_ORG","translation":"CF_NAME rename-org ORG NEW_ORG"},{"id":"Incorrect Usage","translation":"Incorrect Usage"},{"id":"Renaming org %s to %s as %s...","translation":"Renaming org %s to %s as %s..."}] 2 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/expected_output/rename_org.go.en.po: -------------------------------------------------------------------------------- 1 | # filename: d_option/input_files/org/rename_org.go, offset: 806, line: 30, column: 16 2 | msgid "rename-org" 3 | msgstr "rename-org" 4 | 5 | # filename: d_option/input_files/org/rename_org.go, offset: 835, line: 31, column: 16 6 | msgid "Rename an org" 7 | msgstr "Rename an org" 8 | 9 | # filename: d_option/input_files/org/rename_org.go, offset: 867, line: 32, column: 16 10 | msgid "CF_NAME rename-org ORG NEW_ORG" 11 | msgstr "CF_NAME rename-org ORG NEW_ORG" 12 | 13 | # filename: d_option/input_files/org/rename_org.go, offset: 1094, line: 38, column: 20 14 | msgid "Incorrect Usage" 15 | msgstr "Incorrect Usage" 16 | 17 | # filename: d_option/input_files/org/rename_org.go, offset: 1452, line: 54, column: 13 18 | msgid "Renaming org %s to %s as %s..." 19 | msgstr "Renaming org %s to %s as %s..." 20 | 21 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/expected_output/rename_org.go.extracted.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/rename_org.go", 4 | "value": "rename-org", 5 | "offset": 538, 6 | "line": 22, 7 | "column": 16 8 | }, 9 | { 10 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/rename_org.go", 11 | "value": "Rename an org", 12 | "offset": 567, 13 | "line": 23, 14 | "column": 16 15 | }, 16 | { 17 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/rename_org.go", 18 | "value": "CF_NAME rename-org ORG NEW_ORG", 19 | "offset": 599, 20 | "line": 24, 21 | "column": 16 22 | }, 23 | { 24 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/rename_org.go", 25 | "value": "Incorrect Usage", 26 | "offset": 826, 27 | "line": 30, 28 | "column": 20 29 | }, 30 | { 31 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/rename_org.go", 32 | "value": "Renaming org %s to %s as %s...", 33 | "offset": 1184, 34 | "line": 46, 35 | "column": 13 36 | } 37 | ] -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/expected_output/set_quota.go.en.json: -------------------------------------------------------------------------------- 1 | [{"id":"set-quota","translation":"set-quota"},{"id":"Assign a quota to an org","translation":"Assign a quota to an org"},{"id":"CF_NAME set-quota ORG QUOTA\n\n","translation":"CF_NAME set-quota ORG QUOTA\n\n"},{"id":"TIP:\n","translation":"TIP:\n"},{"id":" View allowable quotas with 'CF_NAME quotas'","translation":" View allowable quotas with 'CF_NAME quotas'"},{"id":"Incorrect Usage","translation":"Incorrect Usage"},{"id":"Setting quota %s to org %s as %s...","translation":"Setting quota %s to org %s as %s..."}] 2 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/expected_output/set_quota.go.en.po: -------------------------------------------------------------------------------- 1 | # filename: d_option/input_files/org/set_quota.go, offset: 793, line: 30, column: 16 2 | msgid "set-quota" 3 | msgstr "set-quota" 4 | 5 | # filename: d_option/input_files/org/set_quota.go, offset: 821, line: 31, column: 16 6 | msgid "Assign a quota to an org" 7 | msgstr "Assign a quota to an org" 8 | 9 | # filename: d_option/input_files/org/set_quota.go, offset: 858, line: 32, column: 10 10 | msgid "CF_NAME set-quota ORG QUOTA\n\n" 11 | msgstr "CF_NAME set-quota ORG QUOTA\n\n" 12 | 13 | # filename: d_option/input_files/org/set_quota.go, offset: 897, line: 33, column: 4 14 | msgid "TIP:\n" 15 | msgstr "TIP:\n" 16 | 17 | # filename: d_option/input_files/org/set_quota.go, offset: 911, line: 34, column: 4 18 | msgid " View allowable quotas with 'CF_NAME quotas'" 19 | msgstr " View allowable quotas with 'CF_NAME quotas'" 20 | 21 | # filename: d_option/input_files/org/set_quota.go, offset: 1153, line: 40, column: 20 22 | msgid "Incorrect Usage" 23 | msgstr "Incorrect Usage" 24 | 25 | # filename: d_option/input_files/org/set_quota.go, offset: 1633, line: 64, column: 13 26 | msgid "Setting quota %s to org %s as %s..." 27 | msgstr "Setting quota %s to org %s as %s..." 28 | 29 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/expected_output/set_quota.go.extracted.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/set_quota.go", 4 | "value": "set-quota", 5 | "offset": 525, 6 | "line": 22, 7 | "column": 16 8 | }, 9 | { 10 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/set_quota.go", 11 | "value": "Assign a quota to an org", 12 | "offset": 553, 13 | "line": 23, 14 | "column": 16 15 | }, 16 | { 17 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/set_quota.go", 18 | "value": "CF_NAME set-quota ORG QUOTA\n\n", 19 | "offset": 590, 20 | "line": 24, 21 | "column": 10 22 | }, 23 | { 24 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/set_quota.go", 25 | "value": "TIP:\n", 26 | "offset": 629, 27 | "line": 25, 28 | "column": 4 29 | }, 30 | { 31 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/set_quota.go", 32 | "value": " View allowable quotas with 'CF_NAME quotas'", 33 | "offset": 643, 34 | "line": 26, 35 | "column": 4 36 | }, 37 | { 38 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/set_quota.go", 39 | "value": "Incorrect Usage", 40 | "offset": 885, 41 | "line": 32, 42 | "column": 20 43 | }, 44 | { 45 | "filename": "../../test_fixtures/extract_strings/d_option/input_files/org/set_quota.go", 46 | "value": "Setting quota %s to org %s as %s...", 47 | "offset": 1365, 48 | "line": 56, 49 | "column": 13 50 | } 51 | ] -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/expected_output/update_quota.go.en.json: -------------------------------------------------------------------------------- 1 | [{"id":"Update an existing resource quota","translation":"Update an existing resource quota"},{"id":"m","translation":"m"},{"id":"n","translation":"n"},{"id":"Total number of service instances","translation":"Total number of service instances"},{"id":"Please choose either allow or disallow. Both flags are not permitted to be passed in the same command. ","translation":"Please choose either allow or disallow. Both flags are not permitted to be passed in the same command. "},{"id":"Total amount of memory (e.g. 1024M, 1G, 10G)","translation":"Total amount of memory (e.g. 1024M, 1G, 10G)"},{"id":"New name","translation":"New name"},{"id":"Can provision instances of paid service plans","translation":"Can provision instances of paid service plans"},{"id":"update-quota","translation":"update-quota"},{"id":"CF_NAME update-quota QUOTA [-m MEMORY] [-n NEW_NAME] [-r ROUTES] [-s SERVICE_INSTANCES] [--allow-paid-service-plans | --disallow-paid-service-plans]","translation":"CF_NAME update-quota QUOTA [-m MEMORY] [-n NEW_NAME] [-r ROUTES] [-s SERVICE_INSTANCES] [--allow-paid-service-plans | --disallow-paid-service-plans]"},{"id":"r","translation":"r"},{"id":"s","translation":"s"},{"id":"allow-paid-service-plans","translation":"allow-paid-service-plans"},{"id":"Updating quota %s as %s...","translation":"Updating quota %s as %s..."},{"id":"Total number of routes","translation":"Total number of routes"},{"id":"disallow-paid-service-plans","translation":"disallow-paid-service-plans"},{"id":"Cannot provision instances of paid service plans","translation":"Cannot provision instances of paid service plans"}] 2 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/expected_output/update_quota.go.en.po: -------------------------------------------------------------------------------- 1 | # filename: d_option/input_files/quota/update_quota.go, offset: 2644, line: 80, column: 28 2 | msgid "update-quota" 3 | msgstr "update-quota" 4 | 5 | # filename: d_option/input_files/quota/update_quota.go, offset: 906, line: 32, column: 16 6 | msgid "CF_NAME update-quota QUOTA [-m MEMORY] [-n NEW_NAME] [-r ROUTES] [-s SERVICE_INSTANCES] [--allow-paid-service-plans | --disallow-paid-service-plans]" 7 | msgstr "CF_NAME update-quota QUOTA [-m MEMORY] [-n NEW_NAME] [-r ROUTES] [-s SERVICE_INSTANCES] [--allow-paid-service-plans | --disallow-paid-service-plans]" 8 | 9 | # filename: d_option/input_files/quota/update_quota.go, offset: 2862, line: 95, column: 29 10 | msgid "r" 11 | msgstr "r" 12 | 13 | # filename: d_option/input_files/quota/update_quota.go, offset: 2806, line: 91, column: 31 14 | msgid "s" 15 | msgstr "s" 16 | 17 | # filename: d_option/input_files/quota/update_quota.go, offset: 2097, line: 62, column: 30 18 | msgid "allow-paid-service-plans" 19 | msgstr "allow-paid-service-plans" 20 | 21 | # filename: d_option/input_files/quota/update_quota.go, offset: 2883, line: 98, column: 13 22 | msgid "Updating quota %s as %s..." 23 | msgstr "Updating quota %s as %s..." 24 | 25 | # filename: d_option/input_files/quota/update_quota.go, offset: 1243, line: 36, column: 33 26 | msgid "Total number of routes" 27 | msgstr "Total number of routes" 28 | 29 | # filename: d_option/input_files/quota/update_quota.go, offset: 2157, line: 63, column: 33 30 | msgid "disallow-paid-service-plans" 31 | msgstr "disallow-paid-service-plans" 32 | 33 | # filename: d_option/input_files/quota/update_quota.go, offset: 1507, line: 39, column: 61 34 | msgid "Cannot provision instances of paid service plans" 35 | msgstr "Cannot provision instances of paid service plans" 36 | 37 | # filename: d_option/input_files/quota/update_quota.go, offset: 854, line: 31, column: 16 38 | msgid "Update an existing resource quota" 39 | msgstr "Update an existing resource quota" 40 | 41 | # filename: d_option/input_files/quota/update_quota.go, offset: 2584, line: 77, column: 58 42 | msgid "m" 43 | msgstr "m" 44 | 45 | # filename: d_option/input_files/quota/update_quota.go, offset: 2748, line: 87, column: 25 46 | msgid "n" 47 | msgstr "n" 48 | 49 | # filename: d_option/input_files/quota/update_quota.go, offset: 1302, line: 37, column: 33 50 | msgid "Total number of service instances" 51 | msgstr "Total number of service instances" 52 | 53 | # filename: d_option/input_files/quota/update_quota.go, offset: 2252, line: 65, column: 17 54 | msgid "Please choose either allow or disallow. Both flags are not permitted to be passed in the same command. " 55 | msgstr "Please choose either allow or disallow. Both flags are not permitted to be passed in the same command. " 56 | 57 | # filename: d_option/input_files/quota/update_quota.go, offset: 1114, line: 34, column: 36 58 | msgid "Total amount of memory (e.g. 1024M, 1G, 10G)" 59 | msgstr "Total amount of memory (e.g. 1024M, 1G, 10G)" 60 | 61 | # filename: d_option/input_files/quota/update_quota.go, offset: 1198, line: 35, column: 36 62 | msgid "New name" 63 | msgstr "New name" 64 | 65 | # filename: d_option/input_files/quota/update_quota.go, offset: 1397, line: 38, column: 58 66 | msgid "Can provision instances of paid service plans" 67 | msgstr "Can provision instances of paid service plans" 68 | 69 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/input_files/org/create_org.go: -------------------------------------------------------------------------------- 1 | package organization 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | ) 7 | 8 | type CreateOrg struct { 9 | } 10 | 11 | type CommandMetadata struct { 12 | Name string 13 | ShortName string 14 | Description string 15 | Usage string 16 | } 17 | 18 | func (command CreateOrg) Metadata() CommandMetadata { 19 | return CommandMetadata{ 20 | Name: "create-org", 21 | ShortName: "co", 22 | Description: "Create an org", 23 | Usage: "CF_NAME create-org ORG", 24 | } 25 | } 26 | 27 | func (cmd CreateOrg) GetRequirements(err error) { 28 | err = errors.New("Incorrect Usage") 29 | } 30 | 31 | func (cmd CreateOrg) Run() { 32 | var name, username string 33 | fmt.Printf("Creating org %s as %s...", name, username) 34 | fmt.Printf("Org %s already exists", name) 35 | fmt.Printf("\nTIP: Use '%s' to target new org", name+" target -o "+name) 36 | } 37 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/input_files/org/delete_org.go: -------------------------------------------------------------------------------- 1 | package organization 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | ) 7 | 8 | type DeleteOrg struct { 9 | } 10 | 11 | type CommandMetadata struct { 12 | Name string 13 | ShortName string 14 | Description string 15 | Usage string 16 | } 17 | 18 | type BoolFlag struct { 19 | Name string 20 | Usage string 21 | } 22 | 23 | func (command *DeleteOrg) Metadata() CommandMetadata { 24 | return CommandMetadata{ 25 | Name: "delete-org", 26 | Description: "Delete an org", 27 | Usage: "CF_NAME delete-org ORG [-f]", 28 | Flags: fmt.Printf(BoolFlag{Name: "f", Usage: "Force deletion without confirmation"}), 29 | } 30 | } 31 | 32 | func (cmd *DeleteOrg) GetRequirements(err error) { 33 | err = errors.New("Incorrect Usage") 34 | } 35 | 36 | func (cmd *DeleteOrg) Run() { 37 | var orgName, username string 38 | 39 | fmt.Println("f") 40 | fmt.Println("org", orgName) 41 | 42 | fmt.Printf("Deleting org %s as %s...", orgName, username) 43 | fmt.Printf("Org %s does not exist.", orgName) 44 | return 45 | } 46 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/input_files/org/org.go: -------------------------------------------------------------------------------- 1 | package organization 2 | 3 | import () 4 | 5 | type ShowOrg struct { 6 | ui terminal.UI 7 | config configuration.Reader 8 | orgReq requirements.OrganizationRequirement 9 | } 10 | 11 | func NewShowOrg(ui terminal.UI, config configuration.Reader) (cmd *ShowOrg) { 12 | cmd = new(ShowOrg) 13 | cmd.ui = ui 14 | cmd.config = config 15 | return 16 | } 17 | 18 | func (command *ShowOrg) Metadata() command_metadata.CommandMetadata { 19 | return command_metadata.CommandMetadata{ 20 | Name: "org", 21 | Description: "Show org info", 22 | Usage: "CF_NAME org ORG", 23 | } 24 | } 25 | 26 | func (cmd *ShowOrg) GetRequirements(requirementsFactory requirements.Factory, c *cli.Context) (reqs []requirements.Requirement, err error) { 27 | if len(c.Args()) != 1 { 28 | err = errors.New("Incorrect Usage") 29 | cmd.ui.FailWithUsage(c) 30 | return 31 | } 32 | 33 | cmd.orgReq = requirementsFactory.NewOrganizationRequirement(c.Args()[0]) 34 | reqs = []requirements.Requirement{ 35 | requirementsFactory.NewLoginRequirement(), 36 | cmd.orgReq, 37 | } 38 | 39 | return 40 | } 41 | 42 | func (cmd *ShowOrg) Run(c *cli.Context) { 43 | org := cmd.orgReq.GetOrganization() 44 | cmd.ui.Say("Getting info for org %s as %s...", 45 | terminal.EntityNameColor(org.Name), 46 | terminal.EntityNameColor(cmd.config.Username()), 47 | ) 48 | cmd.ui.Ok() 49 | cmd.ui.Say("\n%s:", terminal.EntityNameColor(org.Name)) 50 | 51 | domains := []string{} 52 | for _, domain := range org.Domains { 53 | domains = append(domains, domain.Name) 54 | } 55 | 56 | spaces := []string{} 57 | for _, space := range org.Spaces { 58 | spaces = append(spaces, space.Name) 59 | } 60 | 61 | quota := org.QuotaDefinition 62 | orgQuota := fmt.Sprintf("%s (%dM memory limit, %d routes, %d services, paid services %s)", 63 | quota.Name, quota.MemoryLimit, quota.RoutesLimit, quota.ServicesLimit, formatters.Allowed(quota.NonBasicServicesAllowed)) 64 | 65 | cmd.ui.Say(" domains: %s", terminal.EntityNameColor(strings.Join(domains, ", "))) 66 | cmd.ui.Say(" quota: %s", terminal.EntityNameColor(orgQuota)) 67 | cmd.ui.Say(" spaces: %s", terminal.EntityNameColor(strings.Join(spaces, ", "))) 68 | } 69 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/input_files/org/orgs.go: -------------------------------------------------------------------------------- 1 | package organization 2 | 3 | import () 4 | 5 | type ListOrgs struct { 6 | ui terminal.UI 7 | config configuration.Reader 8 | orgRepo api.OrganizationRepository 9 | } 10 | 11 | func NewListOrgs(ui terminal.UI, config configuration.Reader, orgRepo api.OrganizationRepository) (cmd ListOrgs) { 12 | cmd.ui = ui 13 | cmd.config = config 14 | cmd.orgRepo = orgRepo 15 | return 16 | } 17 | 18 | func (command ListOrgs) Metadata() command_metadata.CommandMetadata { 19 | return command_metadata.CommandMetadata{ 20 | Name: "orgs", 21 | ShortName: "o", 22 | Description: "List all orgs", 23 | Usage: "CF_NAME orgs", 24 | } 25 | } 26 | 27 | func (cmd ListOrgs) GetRequirements(requirementsFactory requirements.Factory, c *cli.Context) (reqs []requirements.Requirement, err error) { 28 | reqs = []requirements.Requirement{ 29 | requirementsFactory.NewLoginRequirement(), 30 | } 31 | return 32 | } 33 | 34 | func (cmd ListOrgs) Run(c *cli.Context) { 35 | cmd.ui.Say("Getting orgs as %s...\n", terminal.EntityNameColor(cmd.config.Username())) 36 | 37 | noOrgs := true 38 | table := cmd.ui.Table([]string{"name"}) 39 | 40 | apiErr := cmd.orgRepo.ListOrgs(func(org models.Organization) bool { 41 | table.Add([]string{org.Name}) 42 | noOrgs = false 43 | return true 44 | }) 45 | table.Print() 46 | 47 | if apiErr != nil { 48 | cmd.ui.Failed("Failed fetching orgs.\n%s", apiErr) 49 | return 50 | } 51 | 52 | if noOrgs { 53 | cmd.ui.Say("No orgs found") 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/input_files/org/rename_org.go: -------------------------------------------------------------------------------- 1 | package organization 2 | 3 | import () 4 | 5 | type RenameOrg struct { 6 | ui terminal.UI 7 | config configuration.ReadWriter 8 | orgRepo api.OrganizationRepository 9 | orgReq requirements.OrganizationRequirement 10 | } 11 | 12 | func NewRenameOrg(ui terminal.UI, config configuration.ReadWriter, orgRepo api.OrganizationRepository) (cmd *RenameOrg) { 13 | cmd = new(RenameOrg) 14 | cmd.ui = ui 15 | cmd.config = config 16 | cmd.orgRepo = orgRepo 17 | return 18 | } 19 | 20 | func (command *RenameOrg) Metadata() command_metadata.CommandMetadata { 21 | return command_metadata.CommandMetadata{ 22 | Name: "rename-org", 23 | Description: "Rename an org", 24 | Usage: "CF_NAME rename-org ORG NEW_ORG", 25 | } 26 | } 27 | 28 | func (cmd *RenameOrg) GetRequirements(requirementsFactory requirements.Factory, c *cli.Context) (reqs []requirements.Requirement, err error) { 29 | if len(c.Args()) != 2 { 30 | err = errors.New("Incorrect Usage") 31 | cmd.ui.FailWithUsage(c) 32 | return 33 | } 34 | cmd.orgReq = requirementsFactory.NewOrganizationRequirement(c.Args()[0]) 35 | reqs = []requirements.Requirement{ 36 | requirementsFactory.NewLoginRequirement(), 37 | cmd.orgReq, 38 | } 39 | return 40 | } 41 | 42 | func (cmd *RenameOrg) Run(c *cli.Context) { 43 | org := cmd.orgReq.GetOrganization() 44 | newName := c.Args()[1] 45 | 46 | cmd.ui.Say("Renaming org %s to %s as %s...", 47 | terminal.EntityNameColor(org.Name), 48 | terminal.EntityNameColor(newName), 49 | terminal.EntityNameColor(cmd.config.Username()), 50 | ) 51 | 52 | apiErr := cmd.orgRepo.Rename(org.Guid, newName) 53 | if apiErr != nil { 54 | cmd.ui.Failed(apiErr.Error()) 55 | return 56 | } 57 | cmd.ui.Ok() 58 | 59 | if org.Guid == cmd.config.OrganizationFields().Guid { 60 | org.Name = newName 61 | cmd.config.SetOrganizationFields(org.OrganizationFields) 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/input_files/org/set_quota.go: -------------------------------------------------------------------------------- 1 | package organization 2 | 3 | import () 4 | 5 | type SetQuota struct { 6 | ui terminal.UI 7 | config configuration.Reader 8 | quotaRepo api.QuotaRepository 9 | orgReq requirements.OrganizationRequirement 10 | } 11 | 12 | func NewSetQuota(ui terminal.UI, config configuration.Reader, quotaRepo api.QuotaRepository) (cmd *SetQuota) { 13 | cmd = new(SetQuota) 14 | cmd.ui = ui 15 | cmd.config = config 16 | cmd.quotaRepo = quotaRepo 17 | return 18 | } 19 | 20 | func (command *SetQuota) Metadata() command_metadata.CommandMetadata { 21 | return command_metadata.CommandMetadata{ 22 | Name: "set-quota", 23 | Description: "Assign a quota to an org", 24 | Usage: "CF_NAME set-quota ORG QUOTA\n\n" + 25 | "TIP:\n" + 26 | " View allowable quotas with 'CF_NAME quotas'", 27 | } 28 | } 29 | 30 | func (cmd *SetQuota) GetRequirements(requirementsFactory requirements.Factory, c *cli.Context) (reqs []requirements.Requirement, err error) { 31 | if len(c.Args()) != 2 { 32 | err = errors.New("Incorrect Usage") 33 | cmd.ui.FailWithUsage(c) 34 | return 35 | } 36 | 37 | cmd.orgReq = requirementsFactory.NewOrganizationRequirement(c.Args()[0]) 38 | 39 | reqs = []requirements.Requirement{ 40 | requirementsFactory.NewLoginRequirement(), 41 | cmd.orgReq, 42 | } 43 | return 44 | } 45 | 46 | func (cmd *SetQuota) Run(c *cli.Context) { 47 | org := cmd.orgReq.GetOrganization() 48 | quotaName := c.Args()[1] 49 | quota, apiErr := cmd.quotaRepo.FindByName(quotaName) 50 | 51 | if apiErr != nil { 52 | cmd.ui.Failed(apiErr.Error()) 53 | return 54 | } 55 | 56 | cmd.ui.Say("Setting quota %s to org %s as %s...", 57 | terminal.EntityNameColor(quota.Name), 58 | terminal.EntityNameColor(org.Name), 59 | terminal.EntityNameColor(cmd.config.Username()), 60 | ) 61 | 62 | apiErr = cmd.quotaRepo.AssignQuotaToOrg(org.Guid, quota.Guid) 63 | if apiErr != nil { 64 | cmd.ui.Failed(apiErr.Error()) 65 | return 66 | } 67 | 68 | cmd.ui.Ok() 69 | } 70 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/input_files/quota/create_quota.go: -------------------------------------------------------------------------------- 1 | package quota 2 | 3 | import () 4 | 5 | type CreateQuota struct { 6 | ui terminal.UI 7 | config configuration.Reader 8 | quotaRepo api.QuotaRepository 9 | } 10 | 11 | func NewCreateQuota(ui terminal.UI, config configuration.Reader, quotaRepo api.QuotaRepository) CreateQuota { 12 | return CreateQuota{ 13 | ui: ui, 14 | config: config, 15 | quotaRepo: quotaRepo, 16 | } 17 | } 18 | 19 | func (command CreateQuota) Metadata() command_metadata.CommandMetadata { 20 | return command_metadata.CommandMetadata{ 21 | Name: "create-quota", 22 | Description: "Define a new resource quota", 23 | Usage: "CF_NAME create-quota QUOTA [-m MEMORY] [-r ROUTES] [-s SERVICE_INSTANCES] [--allow-paid-service-plans]", 24 | Flags: []cli.Flag{ 25 | flag_helpers.NewStringFlag("m", "Total amount of memory (e.g. 1024M, 1G, 10G)"), 26 | flag_helpers.NewIntFlag("r", "Total number of routes"), 27 | flag_helpers.NewIntFlag("s", "Total number of service instances"), 28 | cli.BoolFlag{Name: "allow-paid-service-plans", Usage: "Can provision instances of paid service plans"}, 29 | }, 30 | } 31 | } 32 | 33 | func (cmd CreateQuota) GetRequirements(requirementsFactory requirements.Factory, context *cli.Context) ([]requirements.Requirement, error) { 34 | if len(context.Args()) != 1 { 35 | cmd.ui.FailWithUsage(context, "create-quota") 36 | } 37 | 38 | return []requirements.Requirement{ 39 | requirementsFactory.NewLoginRequirement(), 40 | }, nil 41 | } 42 | 43 | func (cmd CreateQuota) Run(context *cli.Context) { 44 | name := context.Args()[0] 45 | 46 | cmd.ui.Say("Creating quota %s as %s...", 47 | terminal.EntityNameColor(name), 48 | terminal.EntityNameColor(cmd.config.Username())) 49 | 50 | quota := models.QuotaFields{ 51 | Name: name, 52 | } 53 | 54 | memoryLimit := context.String("m") 55 | if memoryLimit != "" { 56 | parsedMemory, err := formatters.ToMegabytes(memoryLimit) 57 | if err != nil { 58 | cmd.ui.Failed("Invalid memory limit: %s\n%s", memoryLimit, err) 59 | } 60 | 61 | quota.MemoryLimit = parsedMemory 62 | } 63 | 64 | if context.IsSet("r") { 65 | quota.RoutesLimit = context.Int("r") 66 | } 67 | 68 | if context.IsSet("s") { 69 | quota.ServicesLimit = context.Int("s") 70 | } 71 | 72 | if context.IsSet("allow-paid-service-plans") { 73 | quota.NonBasicServicesAllowed = true 74 | } 75 | 76 | err := cmd.quotaRepo.Create(quota) 77 | 78 | httpErr, ok := err.(errors.HttpError) 79 | if ok && httpErr.ErrorCode() == errors.QUOTA_EXISTS { 80 | cmd.ui.Ok() 81 | cmd.ui.Warn("Quota Definition %s already exists", quota.Name) 82 | return 83 | } 84 | 85 | if err != nil { 86 | cmd.ui.Failed(err.Error()) 87 | } 88 | 89 | cmd.ui.Ok() 90 | } 91 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/input_files/quota/delete_quota.go: -------------------------------------------------------------------------------- 1 | package quota 2 | 3 | import () 4 | 5 | type DeleteQuota struct { 6 | ui terminal.UI 7 | config configuration.Reader 8 | quotaRepo api.QuotaRepository 9 | orgReq requirements.OrganizationRequirement 10 | } 11 | 12 | func NewDeleteQuota(ui terminal.UI, config configuration.Reader, quotaRepo api.QuotaRepository) (cmd *DeleteQuota) { 13 | cmd = new(DeleteQuota) 14 | cmd.ui = ui 15 | cmd.config = config 16 | cmd.quotaRepo = quotaRepo 17 | return 18 | } 19 | 20 | func (command *DeleteQuota) Metadata() command_metadata.CommandMetadata { 21 | return command_metadata.CommandMetadata{ 22 | Name: "delete-quota", 23 | Description: "Delete a quota", 24 | Usage: "CF_NAME delete-quota QUOTA [-f]", 25 | Flags: []cli.Flag{ 26 | cli.BoolFlag{Name: "f", Usage: "Force deletion without confirmation"}, 27 | }, 28 | } 29 | } 30 | 31 | func (cmd *DeleteQuota) GetRequirements(requirementsFactory requirements.Factory, c *cli.Context) (reqs []requirements.Requirement, err error) { 32 | if len(c.Args()) != 1 { 33 | err = errors.New("Incorrect Usage") 34 | cmd.ui.FailWithUsage(c, "delete-quota") 35 | return 36 | } 37 | 38 | reqs = []requirements.Requirement{ 39 | requirementsFactory.NewLoginRequirement(), 40 | } 41 | return 42 | } 43 | 44 | func (cmd *DeleteQuota) Run(c *cli.Context) { 45 | quotaName := c.Args()[0] 46 | 47 | if !c.Bool("f") { 48 | response := cmd.ui.ConfirmDelete("quota", quotaName) 49 | if !response { 50 | return 51 | } 52 | } 53 | 54 | cmd.ui.Say("Deleting quota %s as %s...", 55 | terminal.EntityNameColor(quotaName), 56 | terminal.EntityNameColor(cmd.config.Username()), 57 | ) 58 | 59 | quota, apiErr := cmd.quotaRepo.FindByName(quotaName) 60 | 61 | switch (apiErr).(type) { 62 | case nil: // no error 63 | case *errors.ModelNotFoundError: 64 | cmd.ui.Ok() 65 | cmd.ui.Warn("Quota %s does not exist", quotaName) 66 | return 67 | default: 68 | cmd.ui.Failed(apiErr.Error()) 69 | } 70 | 71 | apiErr = cmd.quotaRepo.Delete(quota.Guid) 72 | if apiErr != nil { 73 | cmd.ui.Failed(apiErr.Error()) 74 | } 75 | 76 | cmd.ui.Ok() 77 | } 78 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/input_files/quota/quota.go: -------------------------------------------------------------------------------- 1 | package quota 2 | 3 | import () 4 | 5 | type showQuota struct { 6 | ui terminal.UI 7 | config configuration.Reader 8 | quotaRepo api.QuotaRepository 9 | } 10 | 11 | func NewShowQuota(ui terminal.UI, config configuration.Reader, quotaRepo api.QuotaRepository) *showQuota { 12 | return &showQuota{ 13 | ui: ui, 14 | config: config, 15 | quotaRepo: quotaRepo, 16 | } 17 | } 18 | 19 | func (command *showQuota) Metadata() command_metadata.CommandMetadata { 20 | return command_metadata.CommandMetadata{ 21 | Name: "quota", 22 | Usage: "CF_NAME quota QUOTA", 23 | Description: "Show quota info", 24 | } 25 | } 26 | 27 | func (cmd *showQuota) GetRequirements(requirementsFactory requirements.Factory, context *cli.Context) ([]requirements.Requirement, error) { 28 | if len(context.Args()) != 1 { 29 | cmd.ui.FailWithUsage(context, "quotas") 30 | } 31 | 32 | return []requirements.Requirement{ 33 | requirementsFactory.NewLoginRequirement(), 34 | }, nil 35 | } 36 | 37 | func (cmd *showQuota) Run(context *cli.Context) { 38 | quotaName := context.Args()[0] 39 | cmd.ui.Say("Getting quota %s info as %s...", quotaName, cmd.config.Username()) 40 | 41 | quota, err := cmd.quotaRepo.FindByName(quotaName) 42 | if err != nil { 43 | cmd.ui.Failed(err.Error()) 44 | } 45 | 46 | cmd.ui.Ok() 47 | 48 | table := terminal.NewTable(cmd.ui, []string{"", ""}) 49 | table.Add([]string{"Memory", formatters.ByteSize(quota.MemoryLimit * formatters.MEGABYTE)}) 50 | table.Add([]string{"Routes", fmt.Sprintf("%d", quota.RoutesLimit)}) 51 | table.Add([]string{"Services", fmt.Sprintf("%d", quota.ServicesLimit)}) 52 | table.Add([]string{"Paid service plans", formatters.Allowed(quota.NonBasicServicesAllowed)}) 53 | table.Print() 54 | } 55 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/input_files/quota/quotas.go: -------------------------------------------------------------------------------- 1 | package quota 2 | 3 | import () 4 | 5 | type ListQuotas struct { 6 | ui terminal.UI 7 | config configuration.Reader 8 | quotaRepo api.QuotaRepository 9 | } 10 | 11 | func NewListQuotas(ui terminal.UI, config configuration.Reader, quotaRepo api.QuotaRepository) (cmd *ListQuotas) { 12 | cmd = new(ListQuotas) 13 | cmd.ui = ui 14 | cmd.config = config 15 | cmd.quotaRepo = quotaRepo 16 | return 17 | } 18 | 19 | func (command *ListQuotas) Metadata() command_metadata.CommandMetadata { 20 | return command_metadata.CommandMetadata{ 21 | Name: "quotas", 22 | Description: "List available usage quotas", 23 | Usage: "CF_NAME quotas", 24 | } 25 | } 26 | 27 | func (cmd *ListQuotas) GetRequirements(requirementsFactory requirements.Factory, c *cli.Context) (reqs []requirements.Requirement, err error) { 28 | reqs = []requirements.Requirement{ 29 | requirementsFactory.NewLoginRequirement(), 30 | } 31 | return 32 | } 33 | 34 | func (cmd *ListQuotas) Run(c *cli.Context) { 35 | cmd.ui.Say("Getting quotas as %s...", terminal.EntityNameColor(cmd.config.Username())) 36 | 37 | quotas, apiErr := cmd.quotaRepo.FindAll() 38 | 39 | if apiErr != nil { 40 | cmd.ui.Failed(apiErr.Error()) 41 | return 42 | } 43 | cmd.ui.Ok() 44 | cmd.ui.Say("") 45 | 46 | table := terminal.NewTable(cmd.ui, []string{"name", "memory limit", "routes", "service instances", "paid service plans"}) 47 | 48 | for _, quota := range quotas { 49 | table.Add([]string{ 50 | quota.Name, 51 | formatters.ByteSize(quota.MemoryLimit * formatters.MEGABYTE), 52 | fmt.Sprintf("%d", quota.RoutesLimit), 53 | fmt.Sprintf("%d", quota.ServicesLimit), 54 | formatters.Allowed(quota.NonBasicServicesAllowed), 55 | }) 56 | } 57 | 58 | table.Print() 59 | } 60 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/d_option/input_files/quota/update_quota.go: -------------------------------------------------------------------------------- 1 | package quota 2 | 3 | import () 4 | 5 | type updateQuota struct { 6 | ui terminal.UI 7 | config configuration.Reader 8 | quotaRepo api.QuotaRepository 9 | } 10 | 11 | func NewUpdateQuota(ui terminal.UI, config configuration.Reader, quotaRepo api.QuotaRepository) *updateQuota { 12 | return &updateQuota{ 13 | ui: ui, 14 | config: config, 15 | quotaRepo: quotaRepo, 16 | } 17 | } 18 | 19 | func (command *updateQuota) Metadata() command_metadata.CommandMetadata { 20 | return command_metadata.CommandMetadata{ 21 | Name: "update-quota", 22 | Description: "Update an existing resource quota", 23 | Usage: "CF_NAME update-quota QUOTA [-m MEMORY] [-n NEW_NAME] [-r ROUTES] [-s SERVICE_INSTANCES] [--allow-paid-service-plans | --disallow-paid-service-plans]", 24 | Flags: []cli.Flag{ 25 | flag_helpers.NewStringFlag("m", "Total amount of memory (e.g. 1024M, 1G, 10G)"), 26 | flag_helpers.NewStringFlag("n", "New name"), 27 | flag_helpers.NewIntFlag("r", "Total number of routes"), 28 | flag_helpers.NewIntFlag("s", "Total number of service instances"), 29 | cli.BoolFlag{Name: "allow-paid-service-plans", Usage: "Can provision instances of paid service plans"}, 30 | cli.BoolFlag{Name: "disallow-paid-service-plans", Usage: "Cannot provision instances of paid service plans"}, 31 | }, 32 | } 33 | } 34 | 35 | func (cmd *updateQuota) GetRequirements(requirementsFactory requirements.Factory, context *cli.Context) ([]requirements.Requirement, error) { 36 | if len(context.Args()) != 1 { 37 | cmd.ui.FailWithUsage(context, "update-quota") 38 | } 39 | 40 | return []requirements.Requirement{ 41 | requirementsFactory.NewLoginRequirement(), 42 | }, nil 43 | } 44 | 45 | func (cmd *updateQuota) Run(c *cli.Context) { 46 | oldQuotaName := c.Args()[0] 47 | quota, err := cmd.quotaRepo.FindByName(oldQuotaName) 48 | 49 | if err != nil { 50 | cmd.ui.Failed(err.Error()) 51 | } 52 | 53 | allowPaidServices := c.Bool("allow-paid-service-plans") 54 | disallowPaidServices := c.Bool("disallow-paid-service-plans") 55 | if allowPaidServices && disallowPaidServices { 56 | cmd.ui.Failed("Please choose either allow or disallow. Both flags are not permitted to be passed in the same command. ") 57 | } 58 | 59 | if allowPaidServices { 60 | quota.NonBasicServicesAllowed = true 61 | } 62 | 63 | if disallowPaidServices { 64 | quota.NonBasicServicesAllowed = false 65 | } 66 | 67 | if c.String("m") != "" { 68 | memory, formatError := formatters.ToMegabytes(c.String("m")) 69 | 70 | if formatError != nil { 71 | cmd.ui.FailWithUsage(c, "update-quota") 72 | } 73 | 74 | quota.MemoryLimit = memory 75 | } 76 | 77 | if c.String("n") != "" { 78 | quota.Name = c.String("n") 79 | } 80 | 81 | if c.IsSet("s") { 82 | quota.ServicesLimit = c.Int("s") 83 | } 84 | 85 | if c.IsSet("r") { 86 | quota.RoutesLimit = c.Int("r") 87 | } 88 | 89 | cmd.ui.Say("Updating quota %s as %s...", 90 | terminal.EntityNameColor(oldQuotaName), 91 | terminal.EntityNameColor(cmd.config.Username())) 92 | 93 | err = cmd.quotaRepo.Update(quota) 94 | if err != nil { 95 | cmd.ui.Failed(err.Error()) 96 | } 97 | cmd.ui.Ok() 98 | } 99 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/f_option/expected_output/app.go.en.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "{{.Title \"NAME:\"}}\n {{.Name}} - {{.Usage}}\n\n{{.Title \"USAGE:\"}}\n [environment variables] {{.Name}} [global options] command [arguments...] [command options]\n\n{{.Title \"VERSION:\"}}\n {{.Version}}\n\n{{.Title \"BUILD TIME:\"}}\n {{.Compiled}}\n {{range .Commands}}\n{{.SubTitle .Name}}{{range .CommandSubGroups}}\n{{range .}} {{.Name}} {{.Description}}\n{{end}}{{end}}{{end}}\n{{.Title \"ENVIRONMENT VARIABLES\"}}\n CF_COLOR=false Do not colorize output\n CF_HOME=path/to/dir/ Override path to default config directory\n CF_STAGING_TIMEOUT=15 Max wait time for buildpack staging, in minutes\n CF_STARTUP_TIMEOUT=5 Max wait time for app instance startup, in minutes\n CF_TRACE=true Print API request diagnostics to stdout\n CF_TRACE=path/to/trace.log Append API request diagnostics to a log file\n HTTP_PROXY=proxy.example.com:8080 Enable HTTP proxying for API requests\n\n{{.Title \"GLOBAL OPTIONS\"}}\n --version, -v Print the version\n --help, -h Show help\n", 4 | "translation": "{{.Title \"NAME:\"}}\n {{.Name}} - {{.Usage}}\n\n{{.Title \"USAGE:\"}}\n [environment variables] {{.Name}} [global options] command [arguments...] [command options]\n\n{{.Title \"VERSION:\"}}\n {{.Version}}\n\n{{.Title \"BUILD TIME:\"}}\n {{.Compiled}}\n {{range .Commands}}\n{{.SubTitle .Name}}{{range .CommandSubGroups}}\n{{range .}} {{.Name}} {{.Description}}\n{{end}}{{end}}{{end}}\n{{.Title \"ENVIRONMENT VARIABLES\"}}\n CF_COLOR=false Do not colorize output\n CF_HOME=path/to/dir/ Override path to default config directory\n CF_STAGING_TIMEOUT=15 Max wait time for buildpack staging, in minutes\n CF_STARTUP_TIMEOUT=5 Max wait time for app instance startup, in minutes\n CF_TRACE=true Print API request diagnostics to stdout\n CF_TRACE=path/to/trace.log Append API request diagnostics to a log file\n HTTP_PROXY=proxy.example.com:8080 Enable HTTP proxying for API requests\n\n{{.Title \"GLOBAL OPTIONS\"}}\n --version, -v Print the version\n --help, -h Show help\n" 5 | }, 6 | { 7 | "id": "help", 8 | "translation": "help" 9 | }, 10 | { 11 | "id": "h", 12 | "translation": "h" 13 | }, 14 | { 15 | "id": "Show help", 16 | "translation": "Show help" 17 | }, 18 | { 19 | "id": "\n%s\n%s\n\n", 20 | "translation": "\n%s\n%s\n\n" 21 | }, 22 | { 23 | "id": "Jan 2, 2006 3:04PM", 24 | "translation": "Jan 2, 2006 3:04PM" 25 | }, 26 | { 27 | "id": "CF_NAME", 28 | "translation": "CF_NAME" 29 | }, 30 | { 31 | "id": "%s help [COMMAND]", 32 | "translation": "%s help [COMMAND]" 33 | }, 34 | { 35 | "id": "VERSION:", 36 | "translation": "VERSION:" 37 | } 38 | ] -------------------------------------------------------------------------------- /test_fixtures/extract_strings/f_option/expected_output/app.go.extracted.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "filename": "../../test_fixtures/extract_strings/f_option/input_files/app.go", 4 | "value": "Show help", 5 | "offset": 1332, 6 | "line": 36, 7 | "column": 16 8 | }, 9 | { 10 | "filename": "../../test_fixtures/extract_strings/f_option/input_files/app.go", 11 | "value": "%s help [COMMAND]", 12 | "offset": 1372, 13 | "line": 37, 14 | "column": 28 15 | }, 16 | { 17 | "filename": "../../test_fixtures/extract_strings/f_option/input_files/app.go", 18 | "value": "VERSION:", 19 | "offset": 1710, 20 | "line": 50, 21 | "column": 59 22 | }, 23 | { 24 | "filename": "../../test_fixtures/extract_strings/f_option/input_files/app.go", 25 | "value": "Jan 2, 2006 3:04PM", 26 | "offset": 1873, 27 | "line": 57, 28 | "column": 36 29 | }, 30 | { 31 | "filename": "../../test_fixtures/extract_strings/f_option/input_files/app.go", 32 | "value": "{{.Title \"NAME:\"}}\n {{.Name}} - {{.Usage}}\n\n{{.Title \"USAGE:\"}}\n [environment variables] {{.Name}} [global options] command [arguments...] [command options]\n\n{{.Title \"VERSION:\"}}\n {{.Version}}\n\n{{.Title \"BUILD TIME:\"}}\n {{.Compiled}}\n {{range .Commands}}\n{{.SubTitle .Name}}{{range .CommandSubGroups}}\n{{range .}} {{.Name}} {{.Description}}\n{{end}}{{end}}{{end}}\n{{.Title \"ENVIRONMENT VARIABLES\"}}\n CF_COLOR=false Do not colorize output\n CF_HOME=path/to/dir/ Override path to default config directory\n CF_STAGING_TIMEOUT=15 Max wait time for buildpack staging, in minutes\n CF_STARTUP_TIMEOUT=5 Max wait time for app instance startup, in minutes\n CF_TRACE=true Print API request diagnostics to stdout\n CF_TRACE=path/to/trace.log Append API request diagnostics to a log file\n HTTP_PROXY=proxy.example.com:8080 Enable HTTP proxying for API requests\n\n{{.Title \"GLOBAL OPTIONS\"}}\n --version, -v Print the version\n --help, -h Show help\n", 33 | "offset": 35, 34 | "line": 3, 35 | "column": 23 36 | }, 37 | { 38 | "filename": "../../test_fixtures/extract_strings/f_option/input_files/app.go", 39 | "value": "help", 40 | "offset": 1289, 41 | "line": 34, 42 | "column": 16 43 | }, 44 | { 45 | "filename": "../../test_fixtures/extract_strings/f_option/input_files/app.go", 46 | "value": "h", 47 | "offset": 1312, 48 | "line": 35, 49 | "column": 16 50 | }, 51 | { 52 | "filename": "../../test_fixtures/extract_strings/f_option/input_files/app.go", 53 | "value": "\n%s\n%s\n\n", 54 | "offset": 1673, 55 | "line": 50, 56 | "column": 22 57 | }, 58 | { 59 | "filename": "../../test_fixtures/extract_strings/f_option/input_files/app.go", 60 | "value": "CF_NAME", 61 | "offset": 2455, 62 | "line": 79, 63 | "column": 48 64 | } 65 | ] -------------------------------------------------------------------------------- /test_fixtures/extract_strings/f_option/expected_output/app/app.go.en.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "help", 4 | "translation": "help" 5 | }, 6 | { 7 | "id": "%s help [COMMAND]", 8 | "translation": "%s help [COMMAND]" 9 | }, 10 | { 11 | "id": "VERSION:", 12 | "translation": "VERSION:" 13 | }, 14 | { 15 | "id": "CF_NAME", 16 | "translation": "CF_NAME" 17 | }, 18 | { 19 | "id": "{{.Title \"NAME:\"}}\n {{.Name}} - {{.Usage}}\n\n{{.Title \"USAGE:\"}}\n [environment variables] {{.Name}} [global options] command [arguments...] [command options]\n\n{{.Title \"VERSION:\"}}\n {{.Version}}\n\n{{.Title \"BUILD TIME:\"}}\n {{.Compiled}}\n {{range .Commands}}\n{{.SubTitle .Name}}{{range .CommandSubGroups}}\n{{range .}} {{.Name}} {{.Description}}\n{{end}}{{end}}{{end}}\n{{.Title \"ENVIRONMENT VARIABLES\"}}\n CF_COLOR=false Do not colorize output\n CF_HOME=path/to/dir/ Override path to default config directory\n CF_STAGING_TIMEOUT=15 Max wait time for buildpack staging, in minutes\n CF_STARTUP_TIMEOUT=5 Max wait time for app instance startup, in minutes\n CF_TRACE=true Print API request diagnostics to stdout\n CF_TRACE=path/to/trace.log Append API request diagnostics to a log file\n HTTP_PROXY=proxy.example.com:8080 Enable HTTP proxying for API requests\n\n{{.Title \"GLOBAL OPTIONS\"}}\n --version, -v Print the version\n --help, -h Show help\n", 20 | "translation": "{{.Title \"NAME:\"}}\n {{.Name}} - {{.Usage}}\n\n{{.Title \"USAGE:\"}}\n [environment variables] {{.Name}} [global options] command [arguments...] [command options]\n\n{{.Title \"VERSION:\"}}\n {{.Version}}\n\n{{.Title \"BUILD TIME:\"}}\n {{.Compiled}}\n {{range .Commands}}\n{{.SubTitle .Name}}{{range .CommandSubGroups}}\n{{range .}} {{.Name}} {{.Description}}\n{{end}}{{end}}{{end}}\n{{.Title \"ENVIRONMENT VARIABLES\"}}\n CF_COLOR=false Do not colorize output\n CF_HOME=path/to/dir/ Override path to default config directory\n CF_STAGING_TIMEOUT=15 Max wait time for buildpack staging, in minutes\n CF_STARTUP_TIMEOUT=5 Max wait time for app instance startup, in minutes\n CF_TRACE=true Print API request diagnostics to stdout\n CF_TRACE=path/to/trace.log Append API request diagnostics to a log file\n HTTP_PROXY=proxy.example.com:8080 Enable HTTP proxying for API requests\n\n{{.Title \"GLOBAL OPTIONS\"}}\n --version, -v Print the version\n --help, -h Show help\n" 21 | }, 22 | { 23 | "id": "h", 24 | "translation": "h" 25 | }, 26 | { 27 | "id": "Show help", 28 | "translation": "Show help" 29 | }, 30 | { 31 | "id": "\n%s\n%s\n\n", 32 | "translation": "\n%s\n%s\n\n" 33 | }, 34 | { 35 | "id": "Jan 2, 2006 3:04PM", 36 | "translation": "Jan 2, 2006 3:04PM" 37 | } 38 | ] 39 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/f_option/expected_output/app/app.go.en.po: -------------------------------------------------------------------------------- 1 | # filename: f_option/input_files/app.go, offset: 1289, line: 34, column: 16 2 | msgid "help" 3 | msgstr "help" 4 | 5 | # filename: f_option/input_files/app.go, offset: 1372, line: 37, column: 28 6 | msgid "%s help [COMMAND]" 7 | msgstr "%s help [COMMAND]" 8 | 9 | # filename: f_option/input_files/app.go, offset: 1710, line: 50, column: 59 10 | msgid "VERSION:" 11 | msgstr "VERSION:" 12 | 13 | # filename: f_option/input_files/app.go, offset: 2455, line: 79, column: 48 14 | msgid "CF_NAME" 15 | msgstr "CF_NAME" 16 | 17 | # filename: f_option/input_files/app.go, offset: 35, line: 3, column: 23 18 | msgid "{{.Title \"NAME:\"}}\n {{.Name}} - {{.Usage}}\n\n{{.Title \"USAGE:\"}}\n [environment variables] {{.Name}} [global options] command [arguments...] [command options]\n\n{{.Title \"VERSION:\"}}\n {{.Version}}\n\n{{.Title \"BUILD TIME:\"}}\n {{.Compiled}}\n {{range .Commands}}\n{{.SubTitle .Name}}{{range .CommandSubGroups}}\n{{range .}} {{.Name}} {{.Description}}\n{{end}}{{end}}{{end}}\n{{.Title \"ENVIRONMENT VARIABLES\"}}\n CF_COLOR=false Do not colorize output\n CF_HOME=path/to/dir/ Override path to default config directory\n CF_STAGING_TIMEOUT=15 Max wait time for buildpack staging, in minutes\n CF_STARTUP_TIMEOUT=5 Max wait time for app instance startup, in minutes\n CF_TRACE=true Print API request diagnostics to stdout\n CF_TRACE=path/to/trace.log Append API request diagnostics to a log file\n HTTP_PROXY=proxy.example.com:8080 Enable HTTP proxying for API requests\n\n{{.Title \"GLOBAL OPTIONS\"}}\n --version, -v Print the version\n --help, -h Show help\n" 19 | msgstr "{{.Title \"NAME:\"}}\n {{.Name}} - {{.Usage}}\n\n{{.Title \"USAGE:\"}}\n [environment variables] {{.Name}} [global options] command [arguments...] [command options]\n\n{{.Title \"VERSION:\"}}\n {{.Version}}\n\n{{.Title \"BUILD TIME:\"}}\n {{.Compiled}}\n {{range .Commands}}\n{{.SubTitle .Name}}{{range .CommandSubGroups}}\n{{range .}} {{.Name}} {{.Description}}\n{{end}}{{end}}{{end}}\n{{.Title \"ENVIRONMENT VARIABLES\"}}\n CF_COLOR=false Do not colorize output\n CF_HOME=path/to/dir/ Override path to default config directory\n CF_STAGING_TIMEOUT=15 Max wait time for buildpack staging, in minutes\n CF_STARTUP_TIMEOUT=5 Max wait time for app instance startup, in minutes\n CF_TRACE=true Print API request diagnostics to stdout\n CF_TRACE=path/to/trace.log Append API request diagnostics to a log file\n HTTP_PROXY=proxy.example.com:8080 Enable HTTP proxying for API requests\n\n{{.Title \"GLOBAL OPTIONS\"}}\n --version, -v Print the version\n --help, -h Show help\n" 20 | 21 | # filename: f_option/input_files/app.go, offset: 1312, line: 35, column: 16 22 | msgid "h" 23 | msgstr "h" 24 | 25 | # filename: f_option/input_files/app.go, offset: 1332, line: 36, column: 16 26 | msgid "Show help" 27 | msgstr "Show help" 28 | 29 | # filename: f_option/input_files/app.go, offset: 1673, line: 50, column: 22 30 | msgid "\n%s\n%s\n\n" 31 | msgstr "\n%s\n%s\n\n" 32 | 33 | # filename: f_option/input_files/app.go, offset: 1873, line: 57, column: 36 34 | msgid "Jan 2, 2006 3:04PM" 35 | msgstr "Jan 2, 2006 3:04PM" 36 | 37 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/f_option/expected_output/app/app.go.extracted.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "filename": "../../test_fixtures/extract_strings/f_option/input_files/app.go", 4 | "value": "{{.Title \"NAME:\"}}\n {{.Name}} - {{.Usage}}\n\n{{.Title \"USAGE:\"}}\n [environment variables] {{.Name}} [global options] command [arguments...] [command options]\n\n{{.Title \"VERSION:\"}}\n {{.Version}}\n\n{{.Title \"BUILD TIME:\"}}\n {{.Compiled}}\n {{range .Commands}}\n{{.SubTitle .Name}}{{range .CommandSubGroups}}\n{{range .}} {{.Name}} {{.Description}}\n{{end}}{{end}}{{end}}\n{{.Title \"ENVIRONMENT VARIABLES\"}}\n CF_COLOR=false Do not colorize output\n CF_HOME=path/to/dir/ Override path to default config directory\n CF_STAGING_TIMEOUT=15 Max wait time for buildpack staging, in minutes\n CF_STARTUP_TIMEOUT=5 Max wait time for app instance startup, in minutes\n CF_TRACE=true Print API request diagnostics to stdout\n CF_TRACE=path/to/trace.log Append API request diagnostics to a log file\n HTTP_PROXY=proxy.example.com:8080 Enable HTTP proxying for API requests\n\n{{.Title \"GLOBAL OPTIONS\"}}\n --version, -v Print the version\n --help, -h Show help\n", 5 | "offset": 35, 6 | "line": 3, 7 | "column": 23 8 | }, 9 | { 10 | "filename": "../../test_fixtures/extract_strings/f_option/input_files/app.go", 11 | "value": "help", 12 | "offset": 1289, 13 | "line": 34, 14 | "column": 16 15 | }, 16 | { 17 | "filename": "../../test_fixtures/extract_strings/f_option/input_files/app.go", 18 | "value": "h", 19 | "offset": 1312, 20 | "line": 35, 21 | "column": 16 22 | }, 23 | { 24 | "filename": "../../test_fixtures/extract_strings/f_option/input_files/app.go", 25 | "value": "Show help", 26 | "offset": 1332, 27 | "line": 36, 28 | "column": 16 29 | }, 30 | { 31 | "filename": "../../test_fixtures/extract_strings/f_option/input_files/app.go", 32 | "value": "VERSION:", 33 | "offset": 1710, 34 | "line": 50, 35 | "column": 59 36 | }, 37 | { 38 | "filename": "../../test_fixtures/extract_strings/f_option/input_files/app.go", 39 | "value": "Jan 2, 2006 3:04PM", 40 | "offset": 1873, 41 | "line": 57, 42 | "column": 36 43 | }, 44 | { 45 | "filename": "../../test_fixtures/extract_strings/f_option/input_files/app.go", 46 | "value": "%s help [COMMAND]", 47 | "offset": 1372, 48 | "line": 37, 49 | "column": 28 50 | }, 51 | { 52 | "filename": "../../test_fixtures/extract_strings/f_option/input_files/app.go", 53 | "value": "\n%s\n%s\n\n", 54 | "offset": 1673, 55 | "line": 50, 56 | "column": 22 57 | }, 58 | { 59 | "filename": "../../test_fixtures/extract_strings/f_option/input_files/app.go", 60 | "value": "CF_NAME", 61 | "offset": 2455, 62 | "line": 79, 63 | "column": 48 64 | } 65 | ] -------------------------------------------------------------------------------- /test_fixtures/extract_strings/f_option/expected_output/issue16.go.en.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "translated", 4 | "translation": "translated" 5 | }, 6 | { 7 | "id": "foo", 8 | "translation": "foo" 9 | }, 10 | { 11 | "id": "This is a string which has been {{.Translated}}.", 12 | "translation": "This is a string which has been {{.Translated}}." 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/f_option/expected_output/issue4.go.en.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Unsure how hard this is to fix, but I noticed that > would be translated to its unicode/ascii value.", 4 | "translation": "Unsure how hard this is to fix, but I noticed that > would be translated to its unicode/ascii value." 5 | }, 6 | { 7 | "id": "I am assuming this means <> would not be correctly extracted as well.", 8 | "translation": "I am assuming this means <> would not be correctly extracted as well." 9 | }, 10 | { 11 | "id": "GitHub: issue #4", 12 | "translation": "GitHub: issue #4" 13 | } 14 | ] -------------------------------------------------------------------------------- /test_fixtures/extract_strings/f_option/expected_output/issue45.go.en.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "translated", 4 | "translation": "translated" 5 | }, 6 | { 7 | "id": "This is a string which has been {{.Translated}}.", 8 | "translation": "This is a string which has been {{.Translated}}." 9 | }, 10 | { 11 | "id": "This is another string which has been {{.Translated}}.", 12 | "translation": "This is another string which has been {{.Translated}}." 13 | } 14 | ] -------------------------------------------------------------------------------- /test_fixtures/extract_strings/f_option/input_files/app.go: -------------------------------------------------------------------------------- 1 | package app 2 | 3 | var appHelpTemplate = `{{.Title "NAME:"}} 4 | {{.Name}} - {{.Usage}} 5 | 6 | {{.Title "USAGE:"}} 7 | [environment variables] {{.Name}} [global options] command [arguments...] [command options] 8 | 9 | {{.Title "VERSION:"}} 10 | {{.Version}} 11 | 12 | {{.Title "BUILD TIME:"}} 13 | {{.Compiled}} 14 | {{range .Commands}} 15 | {{.SubTitle .Name}}{{range .CommandSubGroups}} 16 | {{range .}} {{.Name}} {{.Description}} 17 | {{end}}{{end}}{{end}} 18 | {{.Title "ENVIRONMENT VARIABLES"}} 19 | CF_COLOR=false Do not colorize output 20 | CF_HOME=path/to/dir/ Override path to default config directory 21 | CF_STAGING_TIMEOUT=15 Max wait time for buildpack staging, in minutes 22 | CF_STARTUP_TIMEOUT=5 Max wait time for app instance startup, in minutes 23 | CF_TRACE=true Print API request diagnostics to stdout 24 | CF_TRACE=path/to/trace.log Append API request diagnostics to a log file 25 | HTTP_PROXY=proxy.example.com:8080 Enable HTTP proxying for API requests 26 | 27 | {{.Title "GLOBAL OPTIONS"}} 28 | --version, -v Print the version 29 | --help, -h Show help 30 | ` 31 | 32 | func NewApp(cmdRunner command_runner.Runner, metadatas ...command_metadata.CommandMetadata) (app *cli.App) { 33 | helpCommand := cli.Command{ 34 | Name: "help", 35 | ShortName: "h", 36 | Description: "Show help", 37 | Usage: fmt.Sprintf("%s help [COMMAND]", cf.Name()), 38 | Action: func(c *cli.Context) { 39 | args := c.Args() 40 | if len(args) > 0 { 41 | cli.ShowCommandHelp(c, args[0]) 42 | } else { 43 | showAppHelp(appHelpTemplate, c.App) 44 | } 45 | }, 46 | } 47 | cli.HelpPrinter = showAppHelp 48 | cli.AppHelpTemplate = appHelpTemplate 49 | 50 | trace.Logger.Printf("\n%s\n%s\n\n", terminal.HeaderColor("VERSION:"), cf.Version) 51 | 52 | app = cli.NewApp() 53 | app.Usage = cf.Usage 54 | app.Version = cf.Version 55 | app.Action = helpCommand.Action 56 | 57 | compiledAtTime, err := time.Parse("Jan 2, 2006 3:04PM", cf.BuiltOnDate) 58 | 59 | if err == nil { 60 | app.Compiled = compiledAtTime 61 | } else { 62 | err = nil 63 | app.Compiled = time.Now() 64 | } 65 | 66 | app.Commands = []cli.Command{helpCommand} 67 | 68 | for _, metadata := range metadatas { 69 | app.Commands = append(app.Commands, getCommand(metadata, cmdRunner)) 70 | } 71 | return 72 | } 73 | 74 | func getCommand(metadata command_metadata.CommandMetadata, runner command_runner.Runner) cli.Command { 75 | return cli.Command{ 76 | Name: metadata.Name, 77 | ShortName: metadata.ShortName, 78 | Description: metadata.Description, 79 | Usage: strings.Replace(metadata.Usage, "CF_NAME", cf.Name(), -1), 80 | Action: func(context *cli.Context) { 81 | runner.RunCmdByName(metadata.Name, context) 82 | }, 83 | Flags: metadata.Flags, 84 | SkipFlagParsing: metadata.SkipFlagParsing, 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/f_option/input_files/issue16.go: -------------------------------------------------------------------------------- 1 | package app 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | translatedString := "translated" 7 | 8 | T("This is a string which has been {{.Translated}}.", map[string]interface{}{"Translated": translatedString}) 9 | 10 | inputs := map[string]string{ 11 | "test1": "foo", 12 | } 13 | 14 | fmt.Println(inputs["test1"]) 15 | } 16 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/f_option/input_files/issue4.go: -------------------------------------------------------------------------------- 1 | package app 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func Issue4() { 8 | description := "Unsure how hard this is to fix, but I noticed that > would be translated to its unicode/ascii value." 9 | moreInfo := "I am assuming this means <> would not be correctly extracted as well." 10 | 11 | fmt.Println("GitHub: issue #4") 12 | fmt.Println(description) 13 | fmt.Println(moreInfo) 14 | } 15 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/f_option/input_files/issue45.go: -------------------------------------------------------------------------------- 1 | package app 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | ) 7 | 8 | func main() { 9 | translatedString := "translated" 10 | 11 | err := test() 12 | if err != nil { 13 | fmt.Println(err.Error()) 14 | } 15 | 16 | err = errors.New(T("This is another string which has been {{.Translated}}.", map[string]interface{}{"Translated": translatedString})) 17 | if err != nil { 18 | fmt.Println(err.Error()) 19 | } 20 | } 21 | 22 | func test49() { 23 | if true { 24 | return errors.New(T("This is a string which has been {{.Translated}}.", map[string]interface{}{"Translated": translatedString})) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/f_option/input_files/no_strings.go: -------------------------------------------------------------------------------- 1 | package app 2 | 3 | import ( 4 | "io/ioutil" 5 | "os" 6 | "path/filepath" 7 | "strconv" 8 | "sync" 9 | "time" 10 | ) 11 | 12 | func TempDir(namePrefix string, cb func(tmpDir string, err error)) { 13 | tmpDir, err := ioutil.TempDir("", namePrefix) 14 | 15 | defer func() { 16 | os.RemoveAll(tmpDir) 17 | }() 18 | 19 | cb(tmpDir, err) 20 | } 21 | 22 | func TempFile(namePrefix string, cb func(tmpFile *os.File, err error)) { 23 | tmpFile, err := ioutil.TempFile("", namePrefix) 24 | 25 | defer func() { 26 | tmpFile.Close() 27 | os.Remove(tmpFile.Name()) 28 | }() 29 | 30 | cb(tmpFile, err) 31 | } 32 | 33 | // TempPath generates a random file path in tmp, but does 34 | // NOT create the actual directory 35 | func TempPath(namePrefix string) string { 36 | return filepath.Join(os.TempDir(), namePrefix, nextSuffix()) 37 | } 38 | 39 | // copied from http://golang.org/src/pkg/io/ioutil/tempfile.go 40 | // Random number state. 41 | // We generate random temporary file names so that there's a good 42 | // chance the file doesn't exist yet - keeps the number of tries in 43 | // TempFile to a minimum. 44 | var rand uint32 45 | var randmu sync.Mutex 46 | 47 | func reseed() uint32 { 48 | return uint32(time.Now().UnixNano() + int64(os.Getpid())) 49 | } 50 | 51 | func nextSuffix() string { 52 | randmu.Lock() 53 | r := rand 54 | if r == 0 { 55 | r = reseed() 56 | } 57 | r = r*1664525 + 1013904223 // constants from Numerical Recipes 58 | rand = r 59 | randmu.Unlock() 60 | return strconv.Itoa(int(1e9 + r%1e9))[1:] 61 | } 62 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/s_option/expected_output/app.go.en.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "a string", 4 | "translation": "a string" 5 | }, 6 | { 7 | "id": "show the app details", 8 | "translation": "show the app details" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/s_option/input_files/app/app.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | s := "a string" 7 | fmt.Println(s) 8 | newStruct := mystruct{ 9 | mystring: s, 10 | } 11 | fmt.Println(newStruct.mystring) 12 | } 13 | 14 | type mystruct struct { 15 | mystring string `command:"app" description:"show the app details"` 16 | } 17 | -------------------------------------------------------------------------------- /test_fixtures/extract_strings/s_option/input_files/matching_group.json: -------------------------------------------------------------------------------- 1 | { 2 | "captureGroupSubstrings": [ 3 | "`.*description:\"(.*)\".*`" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /test_fixtures/fixup/allgood/src/code/main.go: -------------------------------------------------------------------------------- 1 | package code 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Println(T("Translated hello world!")) 7 | } 8 | -------------------------------------------------------------------------------- /test_fixtures/fixup/allgood/translations/all.en_US.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Translated hello world!", 4 | "translation": "Translated hello world!" 5 | } 6 | ] -------------------------------------------------------------------------------- /test_fixtures/fixup/allgood/translations/all.zh_CN.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Translated hello world!", 4 | "translation": "你好世界!" 5 | } 6 | ] -------------------------------------------------------------------------------- /test_fixtures/fixup/notsogood/add/src/code/main.go: -------------------------------------------------------------------------------- 1 | package code 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Println(T("Translated hello world!")) 7 | fmt.Printf(T("Heal the world")) 8 | } 9 | -------------------------------------------------------------------------------- /test_fixtures/fixup/notsogood/add/src/code/mypackage/thing.go: -------------------------------------------------------------------------------- 1 | package mypackage 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func myFunc() { 8 | fmt.Println(T("And the entire human race")) 9 | } 10 | -------------------------------------------------------------------------------- /test_fixtures/fixup/notsogood/add/translations/all.en_US.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Translated hello world!", 4 | "translation": "Translated hello world!" 5 | }, 6 | { 7 | "id": "And the entire human race", 8 | "translation": "And the entire human race" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /test_fixtures/fixup/notsogood/add/translations/all.zh_CN.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Translated hello world!", 4 | "translation": "你好世界!" 5 | }, 6 | { 7 | "id": "And the entire human race", 8 | "translation": "为你,为我" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /test_fixtures/fixup/notsogood/delete/src/code/main.go: -------------------------------------------------------------------------------- 1 | package code 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Println(T("Translated hello world!")) 7 | fmt.Printf("Heal the world") 8 | } 9 | -------------------------------------------------------------------------------- /test_fixtures/fixup/notsogood/delete/src/code/mypackage/thing.go: -------------------------------------------------------------------------------- 1 | package mypackage 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func myFunc() { 8 | fmt.Println(T("And the entire human race")) 9 | fmt.Println("Tomatoes") 10 | } 11 | -------------------------------------------------------------------------------- /test_fixtures/fixup/notsogood/delete/translations/all.en_US.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Translated hello world!", 4 | "translation": "Translated hello world!" 5 | }, 6 | { 7 | "id": "And the entire human race", 8 | "translation": "And the entire human race" 9 | }, 10 | { 11 | "id": "Heal the world", 12 | "translation": "Heal the world" 13 | } 14 | ] -------------------------------------------------------------------------------- /test_fixtures/fixup/notsogood/delete/translations/all.zh_CN.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Translated hello world!", 4 | "translation": "你好世界!" 5 | }, 6 | { 7 | "id": "And the entire human race", 8 | "translation": "为你,为我" 9 | }, 10 | { 11 | "id": "Heal the world", 12 | "translation": "Heal the world" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /test_fixtures/fixup/notsogood/extra_foreign_key/src/code/main.go: -------------------------------------------------------------------------------- 1 | package code 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Println(T("Translated hello world!")) 7 | fmt.Printf("Heal the world") 8 | } 9 | -------------------------------------------------------------------------------- /test_fixtures/fixup/notsogood/extra_foreign_key/src/code/mypackage/thing.go: -------------------------------------------------------------------------------- 1 | package mypackage 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func myFunc() { 8 | fmt.Println(T("And the entire human race")) 9 | fmt.Println("Tomatoes") 10 | } 11 | -------------------------------------------------------------------------------- /test_fixtures/fixup/notsogood/extra_foreign_key/translations/all.en_US.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Translated hello world!", 4 | "translation": "Translated hello world!" 5 | }, 6 | { 7 | "id": "And the entire human race", 8 | "translation": "And the entire human race" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /test_fixtures/fixup/notsogood/extra_foreign_key/translations/all.zh_CN.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Translated hello world!", 4 | "translation": "你好世界!" 5 | }, 6 | { 7 | "id": "For you and for me", 8 | "translation": "为你,为我" 9 | }, 10 | { 11 | "id": "I'm the extra key", 12 | "translation": "I'm the extra key" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /test_fixtures/fixup/notsogood/missing_foreign_key/src/code/main.go: -------------------------------------------------------------------------------- 1 | package code 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Println(T("Translated hello world!")) 7 | fmt.Println(T("I'm the extra key")) 8 | fmt.Printf("Heal the world") 9 | } 10 | -------------------------------------------------------------------------------- /test_fixtures/fixup/notsogood/missing_foreign_key/src/code/mypackage/thing.go: -------------------------------------------------------------------------------- 1 | package mypackage 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func myFunc() { 8 | fmt.Println(T("And the entire human race")) 9 | fmt.Println("Tomatoes") 10 | } 11 | -------------------------------------------------------------------------------- /test_fixtures/fixup/notsogood/missing_foreign_key/translations/all.en_US.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Translated hello world!", 4 | "translation": "Translated hello world!" 5 | }, 6 | { 7 | "id": "And the entire human race", 8 | "translation": "And the entire human race" 9 | }, 10 | { 11 | "id": "I'm the extra key", 12 | "translation": "I'm the extra key" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /test_fixtures/fixup/notsogood/missing_foreign_key/translations/all.zh_CN.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Translated hello world!", 4 | "translation": "你好世界!" 5 | }, 6 | { 7 | "id": "And the entire human race", 8 | "translation": "为你,为我" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /test_fixtures/fixup/notsogood/multiple_update/src/code/main.go: -------------------------------------------------------------------------------- 1 | package code 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Println(T("Translated hello world!")) 7 | fmt.Println(T("I like apples.")) 8 | fmt.Println(T("messin things up with this added")) 9 | fmt.Printf("Heal the world") 10 | } 11 | -------------------------------------------------------------------------------- /test_fixtures/fixup/notsogood/multiple_update/src/code/mypackage/thing.go: -------------------------------------------------------------------------------- 1 | package mypackage 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func myFunc() { 8 | fmt.Println(T("And the entire human race")) 9 | fmt.Println(T("Tomato")) 10 | } 11 | -------------------------------------------------------------------------------- /test_fixtures/fixup/notsogood/multiple_update/translations/all.en_US.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Translated hello world!", 4 | "translation": "Translated hello world!", 5 | "Dirty": false 6 | }, 7 | { 8 | "id": "And the entire human race", 9 | "translation": "And the entire human race", 10 | "Dirty": false 11 | }, 12 | { 13 | "id": "Potato", 14 | "translation": "Potato", 15 | "Dirty": false 16 | }, 17 | { 18 | "id": "I like bananas.", 19 | "translation": "I like bananas.", 20 | "Dirty": true 21 | } 22 | ] 23 | -------------------------------------------------------------------------------- /test_fixtures/fixup/notsogood/multiple_update/translations/all.zh_CN.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Translated hello world!", 4 | "translation": "你好世界!", 5 | "Dirty": false 6 | }, 7 | { 8 | "id": "For you and for me", 9 | "translation": "为你,为我", 10 | "Dirty": false 11 | }, 12 | { 13 | "id": "Potato", 14 | "translation": "土豆", 15 | "Dirty": true 16 | }, 17 | { 18 | "id": "I like bananas.", 19 | "translation": "我喜欢吃香蕉", 20 | "Dirty": true 21 | } 22 | ] 23 | -------------------------------------------------------------------------------- /test_fixtures/fixup/notsogood/update/src/code/main.go: -------------------------------------------------------------------------------- 1 | package code 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Println(T("Translated hello world!")) 7 | fmt.Println(T("I like apples.")) 8 | fmt.Printf("Heal the world") 9 | } 10 | -------------------------------------------------------------------------------- /test_fixtures/fixup/notsogood/update/src/code/mypackage/thing.go: -------------------------------------------------------------------------------- 1 | package mypackage 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func myFunc() { 8 | fmt.Println(T("And the entire human race")) 9 | fmt.Println("Tomatoes") 10 | } 11 | -------------------------------------------------------------------------------- /test_fixtures/fixup/notsogood/update/translations/all.en_US.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Translated hello world!", 4 | "translation": "Translated hello world!" 5 | }, 6 | { 7 | "id": "And the entire human race", 8 | "translation": "And the entire human race" 9 | }, 10 | { 11 | "id": "I like bananas.", 12 | "translation": "I like bananas." 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /test_fixtures/fixup/notsogood/update/translations/all.zh_CN.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Translated hello world!", 4 | "translation": "你好世界!" 5 | }, 6 | { 7 | "id": "And the entire human race", 8 | "translation": "为你,为我" 9 | }, 10 | { 11 | "id": "I like bananas.", 12 | "translation": "我喜欢吃香蕉" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /test_fixtures/fixup/notsogood/update_add/src/code/main.go: -------------------------------------------------------------------------------- 1 | package code 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Println(T("Translated hello world!")) 7 | fmt.Println(T("I like apples.")) 8 | fmt.Printf("Heal the world") 9 | } 10 | -------------------------------------------------------------------------------- /test_fixtures/fixup/notsogood/update_add/src/code/mypackage/thing.go: -------------------------------------------------------------------------------- 1 | package mypackage 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func myFunc() { 8 | fmt.Println(T("And the entire human race")) 9 | fmt.Println("Tomatoes") 10 | } 11 | -------------------------------------------------------------------------------- /test_fixtures/fixup/notsogood/update_add/translations/all.en_US.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Translated hello world!", 4 | "translation": "Translated hello world!" 5 | }, 6 | { 7 | "id": "And the entire human race", 8 | "translation": "And the entire human race" 9 | }, 10 | { 11 | "id": "I like bananas.", 12 | "translation": "I like bananas." 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /test_fixtures/fixup/notsogood/update_add/translations/all.zh_CN.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Translated hello world!", 4 | "translation": "你好世界!" 5 | }, 6 | { 7 | "id": "For you and for me", 8 | "translation": "为你,为我" 9 | }, 10 | { 11 | "id": "I like bananas.", 12 | "translation": "我喜欢吃香蕉" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /test_fixtures/merge_strings/d_option/input_files/main.go.en.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Total files parsed:", 4 | "translation": "Total files parsed:" 5 | }, 6 | { 7 | "id": "verbose mode where lots of output is generated during execution", 8 | "translation": "verbose mode where lots of output is generated during execution" 9 | }, 10 | { 11 | "id": "the excluded JSON file name, all strings there will be excluded", 12 | "translation": "the excluded JSON file name, all strings there will be excluded" 13 | }, 14 | { 15 | "id": "recursively extract strings from all files in the same directory as filename or dirName", 16 | "translation": "recursively extract strings from all files in the same directory as filename or dirName" 17 | }, 18 | { 19 | "id": "the file name for which strings are extracted", 20 | "translation": "the file name for which strings are extracted" 21 | }, 22 | { 23 | "id": "An unexpected type of error", 24 | "translation": "An unexpected type of error" 25 | }, 26 | { 27 | "id": "Total time:", 28 | "translation": "Total time:" 29 | }, 30 | { 31 | "id": "output directory where the translation files will be placed", 32 | "translation": "output directory where the translation files will be placed" 33 | }, 34 | { 35 | "id": "generated files are created in the specified output directory", 36 | "translation": "generated files are created in the specified output directory" 37 | }, 38 | { 39 | "id": "the dir name for which all .go files will have their strings extracted", 40 | "translation": "the dir name for which all .go files will have their strings extracted" 41 | }, 42 | { 43 | "id": "want to extract strings from file or directory", 44 | "translation": "want to extract strings from file or directory" 45 | }, 46 | { 47 | "id": "the source language of the file, typically also part of the file name, e.g., \"en_US\"", 48 | "translation": "the source language of the file, typically also part of the file name, e.g., \"en_US\"" 49 | }, 50 | { 51 | "id": "Total extracted strings:", 52 | "translation": "Total extracted strings:" 53 | }, 54 | { 55 | "id": "create translation files for different languages using a source file", 56 | "translation": "create translation files for different languages using a source file" 57 | }, 58 | { 59 | "id": "prints the usage", 60 | "translation": "prints the usage" 61 | }, 62 | { 63 | "id": "your public Google Translate API key which is used to generate translations (charge is applicable)", 64 | "translation": "your public Google Translate API key which is used to generate translations (charge is applicable)" 65 | }, 66 | { 67 | "id": "generated files are created in directory to match the package name", 68 | "translation": "generated files are created in directory to match the package name" 69 | }, 70 | { 71 | "id": "generate standard .po file for translation", 72 | "translation": "generate standard .po file for translation" 73 | }, 74 | { 75 | "id": "prevents any output files from being created", 76 | "translation": "prevents any output files from being created" 77 | }, 78 | { 79 | "id": "a perl-style regular expression for files to ignore, e.g., \".*test.*\"", 80 | "translation": "a perl-style regular expression for files to ignore, e.g., \".*test.*\"" 81 | } 82 | ] -------------------------------------------------------------------------------- /test_fixtures/merge_strings/d_option/input_files/main.go.fr.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Total files parsed:", 4 | "translation": "Total files parsed:" 5 | }, 6 | { 7 | "id": "verbose mode where lots of output is generated during execution", 8 | "translation": "verbose mode where lots of output is generated during execution" 9 | }, 10 | { 11 | "id": "the excluded JSON file name, all strings there will be excluded", 12 | "translation": "the excluded JSON file name, all strings there will be excluded" 13 | }, 14 | { 15 | "id": "recursively extract strings from all files in the same directory as filename or dirName", 16 | "translation": "recursively extract strings from all files in the same directory as filename or dirName" 17 | }, 18 | { 19 | "id": "the file name for which strings are extracted", 20 | "translation": "the file name for which strings are extracted" 21 | }, 22 | { 23 | "id": "An unexpected type of error", 24 | "translation": "An unexpected type of error" 25 | }, 26 | { 27 | "id": "Total time:", 28 | "translation": "Total time:" 29 | }, 30 | { 31 | "id": "output directory where the translation files will be placed", 32 | "translation": "output directory where the translation files will be placed" 33 | }, 34 | { 35 | "id": "generated files are created in the specified output directory", 36 | "translation": "generated files are created in the specified output directory" 37 | }, 38 | { 39 | "id": "the dir name for which all .go files will have their strings extracted", 40 | "translation": "the dir name for which all .go files will have their strings extracted" 41 | }, 42 | { 43 | "id": "want to extract strings from file or directory", 44 | "translation": "want to extract strings from file or directory" 45 | }, 46 | { 47 | "id": "the source language of the file, typically also part of the file name, e.g., \"en_US\"", 48 | "translation": "the source language of the file, typically also part of the file name, e.g., \"en_US\"" 49 | }, 50 | { 51 | "id": "Total extracted strings:", 52 | "translation": "Total extracted strings:" 53 | }, 54 | { 55 | "id": "create translation files for different languages using a source file", 56 | "translation": "create translation files for different languages using a source file" 57 | }, 58 | { 59 | "id": "prints the usage", 60 | "translation": "prints the usage" 61 | }, 62 | { 63 | "id": "your public Google Translate API key which is used to generate translations (charge is applicable)", 64 | "translation": "your public Google Translate API key which is used to generate translations (charge is applicable)" 65 | }, 66 | { 67 | "id": "generated files are created in directory to match the package name", 68 | "translation": "generated files are created in directory to match the package name" 69 | }, 70 | { 71 | "id": "generate standard .po file for translation", 72 | "translation": "generate standard .po file for translation" 73 | }, 74 | { 75 | "id": "prevents any output files from being created", 76 | "translation": "prevents any output files from being created" 77 | }, 78 | { 79 | "id": "a perl-style regular expression for files to ignore, e.g., \".*test.*\"", 80 | "translation": "a perl-style regular expression for files to ignore, e.g., \".*test.*\"" 81 | } 82 | ] -------------------------------------------------------------------------------- /test_fixtures/merge_strings/d_option/input_files/main2.go.en.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Total files parsed:", 4 | "translation": "Total files parsed:" 5 | }, 6 | { 7 | "id": "Potato", 8 | "translation": "Potato bananana cream pie" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /test_fixtures/merge_strings/d_option/input_files/reordered/main1.go.en.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Potato", 4 | "translation": "Potato bananana cream pie" 5 | }, 6 | { 7 | "id": "Total files parsed:", 8 | "translation": "Total files parsed:" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /test_fixtures/merge_strings/r_option/input_files/main2.go.en.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Total files parsed:", 4 | "translation": "Total files parsed:" 5 | }, 6 | { 7 | "id": "Potato", 8 | "translation": "Potato bananana cream pie" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /test_fixtures/merge_strings/r_option/input_files/sub/main2.go.en.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Total files parsed:", 4 | "translation": "Total files parsed:" 5 | }, 6 | { 7 | "id": "Potato", 8 | "translation": "Potato bananana cream pie22222222" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /test_fixtures/merge_strings/source_language/input_files/main2.go.fr.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "potato", 4 | "translation": "yuck" 5 | }, 6 | { 7 | "id": "verbose mode where lots of output is generated during execution", 8 | "translation": "verbose mode where lots of output is generated during execution" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/d_option/expected_output/doption/_en.all.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "cruel", 4 | "translation": "cruel" 5 | }, 6 | { 7 | "id": "Bye from %s", 8 | "translation": "Bye from %s" 9 | }, 10 | { 11 | "id": "Evil", 12 | "translation": "Evil" 13 | }, 14 | { 15 | "id": "Hello %s world!", 16 | "translation": "Hello %s world!" 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/d_option/expected_output/doption/_test.go.en.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "cruel", 4 | "translation": "cruel" 5 | }, 6 | { 7 | "id": "Hello %s world!", 8 | "translation": "Hello %s world!" 9 | }, 10 | { 11 | "id": "Bye from %s", 12 | "translation": "Bye from %s" 13 | }, 14 | { 15 | "id": "Evil", 16 | "translation": "Evil" 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/d_option/expected_output/doption/_test2.go.en.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "cruel", 4 | "translation": "cruel" 5 | }, 6 | { 7 | "id": "Hello %s world!", 8 | "translation": "Hello %s world!" 9 | }, 10 | { 11 | "id": "Bye from %s", 12 | "translation": "Bye from %s" 13 | }, 14 | { 15 | "id": "Evil", 16 | "translation": "Evil" 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/d_option/expected_output/doption/en.all.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "cruel", 4 | "translation": "cruel" 5 | }, 6 | { 7 | "id": "Evil", 8 | "translation": "Evil" 9 | }, 10 | { 11 | "id": "Bye from {{.Arg0}}", 12 | "translation": "Bye from {{.Arg0}}" 13 | }, 14 | { 15 | "id": "Hello {{.Arg0}} world!", 16 | "translation": "Hello {{.Arg0}} world!" 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/d_option/expected_output/doption/test.go.en.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "cruel", 4 | "translation": "cruel" 5 | }, 6 | { 7 | "id": "Bye from {{.Arg0}}", 8 | "translation": "Bye from {{.Arg0}}" 9 | }, 10 | { 11 | "id": "Evil", 12 | "translation": "Evil" 13 | }, 14 | { 15 | "id": "Hello {{.Arg0}} world!", 16 | "translation": "Hello {{.Arg0}} world!" 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/d_option/expected_output/doption/test2.go.en.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "cruel", 4 | "translation": "cruel" 5 | }, 6 | { 7 | "id": "Hello {{.Arg0}} world!", 8 | "translation": "Hello {{.Arg0}} world!" 9 | }, 10 | { 11 | "id": "Evil", 12 | "translation": "Evil" 13 | }, 14 | { 15 | "id": "Bye from {{.Arg0}}", 16 | "translation": "Bye from {{.Arg0}}" 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/d_option/expected_output/test.go: -------------------------------------------------------------------------------- 1 | package doption 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func DOption() string { 8 | name := T("cruel") 9 | fmt.Printf(T("Hello {{.Arg0}} world!", map[string]interface{}{"Arg0": name})) 10 | printf(T("Hello {{.Arg0}} world!", map[string]interface{}{"Arg0": name})) 11 | 12 | fmt.Printf(T("Bye from {{.Arg0}}", map[string]interface{}{"Arg0": T("Evil")})) 13 | } 14 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/d_option/expected_output/test2.go: -------------------------------------------------------------------------------- 1 | package doption 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func DOption2() string { 8 | name := T("cruel") 9 | fmt.Printf(T("Bye from {{.Arg0}}", map[string]interface{}{"Arg0": T("Evil")})) 10 | 11 | for i := range 10 { 12 | fmt.Printf(T("Hello {{.Arg0}} world!", map[string]interface{}{"Arg0": name})) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/d_option/expected_output/test3.go: -------------------------------------------------------------------------------- 1 | package doption 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func DOption3() string { 8 | name := "Tim" 9 | fmt.Printf("Hello cruel world! from %s", name) 10 | } 11 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/d_option/input_files/test.go: -------------------------------------------------------------------------------- 1 | package doption 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func DOption() string { 8 | name := "cruel" 9 | fmt.Printf("Hello %s world!", name) 10 | printf("Hello %s world!", name) 11 | 12 | fmt.Printf("Bye from %s", "Evil") 13 | } 14 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/d_option/input_files/test2.go: -------------------------------------------------------------------------------- 1 | package doption 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func DOption2() string { 8 | name := "cruel" 9 | fmt.Printf("Bye from %s", "Evil") 10 | 11 | for i := range 10 { 12 | fmt.Printf("Hello %s world!", name) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/d_option/input_files/test3.go: -------------------------------------------------------------------------------- 1 | package doption 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func DOption3() string { 8 | name := "Tim" 9 | fmt.Printf("Hello cruel world! from %s", name) 10 | } 11 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/f_option/expected_output/i18n_init.go: -------------------------------------------------------------------------------- 1 | package input_files 2 | 3 | import ( 4 | "path/filepath" 5 | 6 | "github.com/maximilien/i18n4go/i18n4go/i18n" 7 | ) 8 | 9 | var T i18n.TranslateFunc 10 | 11 | func init() { 12 | T = i18n.Init(filepath.Join("test_fixtures", "rewrite_package", "f_option", "input_files"), i18n.GetResourcesPath(), func(asset string) ([]byte, error) { 13 | return Asset(asset) 14 | }) 15 | } 16 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/f_option/expected_output/issue13.go: -------------------------------------------------------------------------------- 1 | package input_files 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "path/filepath" 7 | ) 8 | 9 | func Issue13() string { 10 | someString := T("hello") 11 | fmt.Println(someString, T("world")) 12 | fmt.Println(someString, T("hello"), T("world")) 13 | 14 | fmt.Println(someString, T("Hello world {{.Arg0}}", map[string]interface{}{"Arg0": someString})) 15 | fmt.Println(someString, T("Hello world {{.Arg0}}", map[string]interface{}{"Arg0": fmt.Printf(T("my_world"))})) 16 | fmt.Println(someString, T("Hello world {{.Arg0}}", map[string]interface{}{"Arg0": T("my_world")})) 17 | 18 | return fmt.Sprint(10, T("world")) 19 | } 20 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/f_option/expected_output/nested_dir/i18n_init.go: -------------------------------------------------------------------------------- 1 | package nested_dir 2 | 3 | import ( 4 | "path/filepath" 5 | 6 | "github.com/maximilien/i18n4go/i18n4go/i18n" 7 | ) 8 | 9 | var T i18n.TranslateFunc 10 | 11 | func init() { 12 | T = i18n.Init(filepath.Join("test_fixtures", "rewrite_package", "f_option", "input_files", "nested_dir"), i18n.GetResourcesPath(), func(asset string) ([]byte, error) { 13 | return Asset(asset) 14 | }) 15 | } 16 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/f_option/expected_output/nested_dir/test.go: -------------------------------------------------------------------------------- 1 | package nested_dir 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "path/filepath" 7 | ) 8 | 9 | type t struct { 10 | myString string 11 | } 12 | 13 | func Something() string { 14 | someString := T("hello") 15 | var anotherString string = T("world") 16 | println(someString, anotherString) 17 | 18 | yetAnotherString := []string{T("tricky tests")} 19 | var moreStrings []string 20 | moreStrings = []string{T("are"), T("tricky")} 21 | println(yetAnotherString, moreStrings) 22 | 23 | mappyMap := map[string]string{T("hello"): T("world")} 24 | println(mappyMap) 25 | 26 | myT := t{myString: T("my string")} 27 | println(myT) 28 | 29 | trickyT := t{T("this is a tricky case")} 30 | println(trickyT) 31 | 32 | fmt.Printf(T("HAI")) 33 | if os.Getenv(T("SOMETHING")) { 34 | fmt.Printf(filepath.Clean(os.Getenv(T("something")))) 35 | } 36 | 37 | return T("enqueuedequeueenqueuebananapants") 38 | } 39 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/f_option/expected_output/test.go: -------------------------------------------------------------------------------- 1 | package input_files 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "path/filepath" 7 | ) 8 | 9 | type t struct { 10 | myString string 11 | } 12 | 13 | func myPrint() { 14 | println(T("isn't that grand")) 15 | } 16 | 17 | func Something() string { 18 | myPrint() // a trivial case 19 | 20 | someString := T("hello") 21 | var anotherString string = T("world") 22 | println(someString, anotherString) 23 | 24 | yetAnotherString := []string{T("tricky tests")} 25 | var moreStrings []string 26 | moreStrings = []string{T("are"), T("tricky")} 27 | println(yetAnotherString, moreStrings) 28 | 29 | mappyMap := map[string]string{T("hello"): T("world")} 30 | println(mappyMap) 31 | println(mappyMap[T("hello")]) 32 | 33 | myT := t{myString: T("my string")} 34 | println(myT.myString) 35 | 36 | trickyT := t{T("this is a tricky case")} 37 | println(trickyT.myString) 38 | 39 | concatenatedStrings := T("foo") + T(" ") + T("bar") 40 | println(concatenatedStrings) 41 | 42 | fmt.Printf(T("HAI")) 43 | if os.Getenv(T("SOMETHING")) != T("") { 44 | fmt.Printf(filepath.Clean(os.Getenv(T("SOMETHING")))) 45 | } 46 | 47 | fmt.Println(T("hello") + T("world")) 48 | 49 | return T("enqueuedequeueenqueuebananapants") 50 | } 51 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/f_option/expected_output/test_interpolated_strings.go: -------------------------------------------------------------------------------- 1 | package input_files 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | func Interpolated() string { 9 | name := T("cruel") 10 | myName := T("evil") 11 | fmt.Printf(T("Hello {{.Arg0}} world!", map[string]interface{}{"Arg0": name})) 12 | fmt.Printf(T("Hello {{.Arg0}} world!, bye from {{.Arg1}}", map[string]interface{}{"Arg0": name, "Arg1": myName})) 13 | 14 | fmt.Printf(T("Hello {{.Arg0}}({{.Arg1}}) world!, bye from {{.Arg2}}", map[string]interface{}{"Arg0": 10, "Arg1": name, "Arg2": T("Evil")})) 15 | 16 | fmt.Printf(T("Hello {{.Arg0}} world!", map[string]interface{}{"Arg0": name})) 17 | fmt.Printf(T("Hello {{.Arg0}} world! {{.Arg1}}", map[string]interface{}{"Arg0": name, "Arg1": name})) 18 | } 19 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/f_option/expected_output/test_templated_strings.go: -------------------------------------------------------------------------------- 1 | package input_files 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | func Templated() string { 9 | name := T("cruel") 10 | myName := T("evil") 11 | fmt.Println(T("Hello {{.Name}} world!", map[string]interface{}{"Name": name})) 12 | fmt.Println(T("Hello {{.Name}} world!, bye from {{.MyName}}", map[string]interface{}{"Name": name, "MyName": myName})) 13 | fmt.Println(T("Hello {{.Name}} world!", map[string]interface{}{"Name": T("Evil")})) 14 | 15 | //These should not have a map[string]interface{} 16 | fmt.Println(T("Hello {{Not complex}} world! I am"), name) 17 | fmt.Println(T("Hello {{}}"), myName) 18 | 19 | fmt.Println(T("Hello {{.Name}} world!", map[string]interface{}{"Name": strings.ToUpper(name)})) 20 | fmt.Println(T("Hello {{.Name}} world!", map[string]interface{}{"Name": strings.ToUpper(T("Hi"))})) 21 | fmt.Println(T("Hello {{.Name}} world! {{.Number}} times", map[string]interface{}{"Name": name, "Number": 10})) 22 | fmt.Println(T("Hello {{.Name}} world! {{.Float}} times", map[string]interface{}{"Name": name, "Float": 10.0})) 23 | 24 | fmt.Println(T("Hello {{.Name}} world!", map[string]interface{}{"Name": strings.ToUpper(T("Hello {{.Name}} world!", map[string]interface{}{"Name": strings.ToUpper(name)}))})) 25 | 26 | type something struct { 27 | } 28 | 29 | foo := something{} 30 | strz := []string{T("one"), T("two"), T("buckle my shoe")} 31 | fmt.Println(T("Welp, that's a great {{.MyStruct}} how about a {{.Whatever}}", map[string]interface{}{"MyStruct": &foo, "Whatever": strz[2]})) 32 | 33 | println(T("Hello {{.Name}} world!", map[string]interface{}{"Name": name})) 34 | println(T("Hello {{.Name}} world! {{.Name}}", map[string]interface{}{"Name": name})) 35 | } 36 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/f_option/input_files/a_really_bad_test.go: -------------------------------------------------------------------------------- 1 | package input_files_test 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestAllTheThings(t *testing.T) { 8 | if 1 == 0 { 9 | panic("hmmmmmmmmmmm") 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/f_option/input_files/issue13.go: -------------------------------------------------------------------------------- 1 | package input_files 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "path/filepath" 7 | ) 8 | 9 | func Issue13() string { 10 | someString := "hello" 11 | fmt.Println(someString, "world") 12 | fmt.Println(someString, "hello", "world") 13 | 14 | fmt.Println(someString, "Hello world %s", someString) 15 | fmt.Println(someString, "Hello world %s", fmt.Printf("my_world")) 16 | fmt.Println(someString, "Hello world %s", "my_world") 17 | 18 | return fmt.Sprint(10, "world") 19 | } 20 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/f_option/input_files/nested_dir/test.go: -------------------------------------------------------------------------------- 1 | package nested_dir 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "path/filepath" 7 | ) 8 | 9 | type t struct { 10 | myString string 11 | } 12 | 13 | func Something() string { 14 | someString := "hello" 15 | var anotherString string = "world" 16 | println(someString, anotherString) 17 | 18 | yetAnotherString := []string{"tricky tests"} 19 | var moreStrings []string 20 | moreStrings = []string{"are", "tricky"} 21 | println(yetAnotherString, moreStrings) 22 | 23 | mappyMap := map[string]string{"hello": "world"} 24 | println(mappyMap) 25 | 26 | myT := t{myString: "my string"} 27 | println(myT) 28 | 29 | trickyT := t{"this is a tricky case"} 30 | println(trickyT) 31 | 32 | fmt.Printf("HAI") 33 | if os.Getenv("SOMETHING") { 34 | fmt.Printf(filepath.Clean(os.Getenv("something"))) 35 | } 36 | 37 | return "enqueuedequeueenqueuebananapants" 38 | } 39 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/f_option/input_files/test.go: -------------------------------------------------------------------------------- 1 | package input_files 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "path/filepath" 7 | ) 8 | 9 | type t struct { 10 | myString string 11 | } 12 | 13 | func myPrint() { 14 | println("isn't that grand") 15 | } 16 | 17 | func Something() string { 18 | myPrint() // a trivial case 19 | 20 | someString := "hello" 21 | var anotherString string = "world" 22 | println(someString, anotherString) 23 | 24 | yetAnotherString := []string{"tricky tests"} 25 | var moreStrings []string 26 | moreStrings = []string{"are", "tricky"} 27 | println(yetAnotherString, moreStrings) 28 | 29 | mappyMap := map[string]string{"hello": "world"} 30 | println(mappyMap) 31 | println(mappyMap["hello"]) 32 | 33 | myT := t{myString: "my string"} 34 | println(myT.myString) 35 | 36 | trickyT := t{"this is a tricky case"} 37 | println(trickyT.myString) 38 | 39 | concatenatedStrings := "foo" + " " + "bar" 40 | println(concatenatedStrings) 41 | 42 | fmt.Printf("HAI") 43 | if os.Getenv("SOMETHING") != "" { 44 | fmt.Printf(filepath.Clean(os.Getenv("SOMETHING"))) 45 | } 46 | 47 | fmt.Println("hello" + "world") 48 | 49 | return "enqueuedequeueenqueuebananapants" 50 | } 51 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/f_option/input_files/test_interpolated_strings.go: -------------------------------------------------------------------------------- 1 | package input_files 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | func Interpolated() string { 9 | name := "cruel" 10 | myName := "evil" 11 | fmt.Printf("Hello %s world!", name) 12 | fmt.Printf("Hello %s world!, bye from %s", name, myName) 13 | 14 | fmt.Printf("Hello %d(%s) world!, bye from %s", 10, name, "Evil") 15 | 16 | fmt.Printf("Hello %s world!", name) 17 | fmt.Printf("Hello %s world! %s", name, name) 18 | } 19 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/f_option/input_files/test_templated_strings.go: -------------------------------------------------------------------------------- 1 | package input_files 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | func Templated() string { 9 | name := "cruel" 10 | myName := "evil" 11 | fmt.Println("Hello {{.Name}} world!", name) 12 | fmt.Println("Hello {{.Name}} world!, bye from {{.MyName}}", name, myName) 13 | fmt.Println("Hello {{.Name}} world!", "Evil") 14 | 15 | //These should not have a map[string]interface{} 16 | fmt.Println("Hello {{Not complex}} world! I am", name) 17 | fmt.Println("Hello {{}}", myName) 18 | 19 | fmt.Println("Hello {{.Name}} world!", strings.ToUpper(name)) 20 | fmt.Println("Hello {{.Name}} world!", strings.ToUpper("Hi")) 21 | fmt.Println("Hello {{.Name}} world! {{.Number}} times", name, 10) 22 | fmt.Println("Hello {{.Name}} world! {{.Float}} times", name, 10.0) 23 | 24 | fmt.Println("Hello {{.Name}} world!", strings.ToUpper("Hello {{.Name}} world!", strings.ToUpper(name))) 25 | 26 | type something struct { 27 | } 28 | 29 | foo := something{} 30 | strz := []string{"one", "two", "buckle my shoe"} 31 | fmt.Println("Welp, that's a great {{.MyStruct}} how about a {{.Whatever}}", &foo, strz[2]) 32 | 33 | println("Hello {{.Name}} world!", name) 34 | println("Hello {{.Name}} world! {{.Name}}", name, name) 35 | } 36 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/i18n_strings_filename_option/expected_output/test.go: -------------------------------------------------------------------------------- 1 | package input_files 2 | 3 | func Something() { 4 | str := T("hello") 5 | println(str, "world") 6 | println(1 + 1) 7 | println(T("hello")) 8 | } 9 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/i18n_strings_filename_option/expected_output/test_interpolated_strings.go: -------------------------------------------------------------------------------- 1 | package input_files 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | func Interpolated() string { 9 | name := "cruel" 10 | myName := "evil" 11 | fmt.Printf(T("Hello {{.Arg0}} world!", map[string]interface{}{"Arg0": name})) 12 | fmt.Printf(T("Bye {{.Arg0}} world!\n", map[string]interface{}{"Arg0": name})) 13 | fmt.Printf("Hello %s world!, bye from %s", name, myName) 14 | fmt.Printf(T("Hello again:\t {{.Arg0}} world!\n", map[string]interface{}{"Arg0": name})) 15 | 16 | fmt.Printf(T("Hello {{.Arg0}}({{.Arg1}}) world!, bye from {{.Arg2}}", map[string]interface{}{"Arg0": 10, "Arg1": name, "Arg2": T("Evil")})) 17 | } 18 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/i18n_strings_filename_option/expected_output/test_interpolated_strings.go.en.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Hello {{.Arg0}}({{.Arg1}}) world!, bye from {{.Arg2}}", 4 | "translation": "Hello {{.Arg0}}({{.Arg1}}) world!, bye from {{.Arg2}}" 5 | }, 6 | { 7 | "id": "Evil", 8 | "translation": "Evil" 9 | }, 10 | { 11 | "id": "Hello {{.Arg0}} world!", 12 | "translation": "Hello {{.Arg0}} world!" 13 | }, 14 | { 15 | "id": "Bye {{.Arg0}} world!\n", 16 | "translation": "Bye {{.Arg0}} world!\n" 17 | }, 18 | { 19 | "id": "Hello again:\t {{.Arg0}} world!\n", 20 | "translation": "Hello again:\t {{.Arg0}} world!\n" 21 | } 22 | ] 23 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/i18n_strings_filename_option/expected_output/test_templated_strings.go: -------------------------------------------------------------------------------- 1 | package input_files 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | func Templated() string { 9 | name := T("cruel") 10 | myName := "evil" 11 | fmt.Println(T("Hello {{.Name}} world!", map[string]interface{}{"Name": name})) 12 | fmt.Println("Hello {{.Name}} world!, bye from {{.MyName}}", name, myName) 13 | 14 | fmt.Println(T("Hello {{Not complex}} world! I am"), name) 15 | fmt.Println("Hello {{}}", myName) 16 | 17 | fmt.Println(T("Hello {{.Name}} world!", map[string]interface{}{"Name": strings.ToUpper(name)})) 18 | fmt.Println(T("Hello {{.Name}} world!", map[string]interface{}{"Name": strings.ToUpper("Hi")})) 19 | fmt.Println(T("Hello {{.Name}} world! {{.Number}} times", map[string]interface{}{"Name": name, "Number": 10})) 20 | 21 | fmt.Println(T("Hello {{.Name}} world!", map[string]interface{}{"Name": strings.ToUpper(T("Hello {{.Name}} world!", map[string]interface{}{"Name": strings.ToUpper(name)}))})) 22 | fmt.Println(T("Hello {{.Name}} world!", map[string]interface{}{"Name": strings.ToUpper("Hello {{.Name}} world!, bye from {{.MyName}}", strings.ToUpper(name), myName)})) 23 | 24 | fmt.Println("Hello {{.Name}} world!, bye from {{.MyName}}", strings.ToUpper(name), strings.ToUpper(T("Hello {{.Name}} world!", map[string]interface{}{"Name": strings.ToUpper(name)}))) 25 | fmt.Println("Hello {{.Name}} world!, bye from {{.MyName}}", strings.ToUpper(name), strings.ToUpper("Hello {{.Name}} world!, bye from {{.MyName}}", strings.ToUpper(name), myName)) 26 | } 27 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/i18n_strings_filename_option/input_files/_test_interpolated_strings.go.en.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Hello %s world!", 4 | "translation": "Hello %s world!" 5 | }, 6 | { 7 | "id": "Bye %s world!\n", 8 | "translation": "Bye %s world!\n" 9 | }, 10 | { 11 | "id": "Hello again:\t %s world!\n", 12 | "translation": "Hello again:\t %s world!\n" 13 | }, 14 | { 15 | "id": "Hello %d(%s) world!, bye from %s", 16 | "translation": "Hello %d(%s) world!, bye from %s" 17 | }, 18 | { 19 | "id": "Evil", 20 | "translation": "Evil" 21 | } 22 | ] 23 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/i18n_strings_filename_option/input_files/strings.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "hello", 4 | "translation": "hello" 5 | } 6 | ] -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/i18n_strings_filename_option/input_files/test.go: -------------------------------------------------------------------------------- 1 | package input_files 2 | 3 | func Something() { 4 | str := "hello" 5 | println(str, "world") 6 | println(1 + 1) 7 | println("hello") 8 | } 9 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/i18n_strings_filename_option/input_files/test_interpolated_strings.go: -------------------------------------------------------------------------------- 1 | package input_files 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | func Interpolated() string { 9 | name := "cruel" 10 | myName := "evil" 11 | fmt.Printf("Hello %s world!", name) 12 | fmt.Printf("Bye %s world!\n", name) 13 | fmt.Printf("Hello %s world!, bye from %s", name, myName) 14 | fmt.Printf("Hello again:\t %s world!\n", name) 15 | 16 | fmt.Printf("Hello %d(%s) world!, bye from %s", 10, name, "Evil") 17 | } 18 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/i18n_strings_filename_option/input_files/test_interpolated_strings.go.en.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Hello %s world!", 4 | "translation": "Hello %s world!" 5 | }, 6 | { 7 | "id": "Bye %s world!\n", 8 | "translation": "Bye %s world!\n" 9 | }, 10 | { 11 | "id": "Hello again:\t %s world!\n", 12 | "translation": "Hello again:\t %s world!\n" 13 | }, 14 | { 15 | "id": "Hello %d(%s) world!, bye from %s", 16 | "translation": "Hello %d(%s) world!, bye from %s" 17 | }, 18 | { 19 | "id": "Evil", 20 | "translation": "Evil" 21 | } 22 | ] 23 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/i18n_strings_filename_option/input_files/test_templated_strings.go: -------------------------------------------------------------------------------- 1 | package input_files 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | func Templated() string { 9 | name := "cruel" 10 | myName := "evil" 11 | fmt.Println("Hello {{.Name}} world!", name) 12 | fmt.Println("Hello {{.Name}} world!, bye from {{.MyName}}", name, myName) 13 | 14 | fmt.Println("Hello {{Not complex}} world! I am", name) 15 | fmt.Println("Hello {{}}", myName) 16 | 17 | fmt.Println("Hello {{.Name}} world!", strings.ToUpper(name)) 18 | fmt.Println("Hello {{.Name}} world!", strings.ToUpper("Hi")) 19 | fmt.Println("Hello {{.Name}} world! {{.Number}} times", name, 10) 20 | 21 | fmt.Println("Hello {{.Name}} world!", strings.ToUpper("Hello {{.Name}} world!", strings.ToUpper(name))) 22 | fmt.Println("Hello {{.Name}} world!", strings.ToUpper("Hello {{.Name}} world!, bye from {{.MyName}}", strings.ToUpper(name), myName)) 23 | 24 | fmt.Println("Hello {{.Name}} world!, bye from {{.MyName}}", strings.ToUpper(name), strings.ToUpper("Hello {{.Name}} world!", strings.ToUpper(name))) 25 | fmt.Println("Hello {{.Name}} world!, bye from {{.MyName}}", strings.ToUpper(name), strings.ToUpper("Hello {{.Name}} world!, bye from {{.MyName}}", strings.ToUpper(name), myName)) 26 | } 27 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/i18n_strings_filename_option/input_files/test_templated_strings.go.en.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "cruel", 4 | "translation": "cruel" 5 | }, 6 | { 7 | "id": "Hello {{.Name}} world!", 8 | "translation": "Hello {{.Name}} world!" 9 | }, 10 | { 11 | "id": "Hello {{Not complex}} world! I am", 12 | "translation": "Hello {{Not complex}} world! I am" 13 | }, 14 | { 15 | "id": "Hello {{.Name}} world! {{.Number}} times", 16 | "translation": "Hello {{.Name}} world! {{.Number}} times" 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/init_code_snippet_filename/expected_output/i18n_init_default.go: -------------------------------------------------------------------------------- 1 | package input_files 2 | 3 | import ( 4 | "path/filepath" 5 | 6 | "github.com/maximilien/i18n4go/i18n4go/i18n" 7 | ) 8 | 9 | var T i18n.TranslateFunc 10 | 11 | func init() { 12 | T = i18n.Init(filepath.Join("test_fixtures", "rewrite_package", "init_code_snippet_filename", "input_files"), i18n.GetResourcesPath(), func(asset string) ([]byte, error) { 13 | return Asset(asset) 14 | }) 15 | } 16 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/init_code_snippet_filename/expected_output/i18n_init_from_template.go: -------------------------------------------------------------------------------- 1 | package input_files 2 | 3 | import ( 4 | "fmt" 5 | "path/filepath" 6 | 7 | "github.com/maximilien/i18n4go/i18n4go/i18n" 8 | ) 9 | 10 | var T i18n.TranslateFunc 11 | 12 | func init() { 13 | fmt.Println("DEBUG: this is a test i18n_init.go file") 14 | T = i18n.Init(filepath.Join("test_fixtures", "rewrite_package", "init_code_snippet_filename", "input_files"), i18n.GetResourcesPath()) 15 | } 16 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/init_code_snippet_filename/expected_output/issue14.go: -------------------------------------------------------------------------------- 1 | package input_files 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "path/filepath" 7 | ) 8 | 9 | func Issue14() string { 10 | someString := T("hello issue 14") 11 | fmt.Println(someString) 12 | } 13 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/init_code_snippet_filename/input_files/init_code_snippet.go.template: -------------------------------------------------------------------------------- 1 | package __PACKAGE__NAME__ 2 | 3 | import ( 4 | "fmt" 5 | "path/filepath" 6 | 7 | "github.com/maximilien/i18n4go/i18n4go/i18n" 8 | ) 9 | 10 | var T i18n.TranslateFunc 11 | 12 | func init() { 13 | fmt.Println("DEBUG: this is a test i18n_init.go file") 14 | T = i18n.Init(__FULL_IMPORT_PATH__, i18n.GetResourcesPath()) 15 | } 16 | -------------------------------------------------------------------------------- /test_fixtures/rewrite_package/init_code_snippet_filename/input_files/issue14.go: -------------------------------------------------------------------------------- 1 | package input_files 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "path/filepath" 7 | ) 8 | 9 | func Issue14() string { 10 | someString := "hello issue 14" 11 | fmt.Println(someString) 12 | } 13 | -------------------------------------------------------------------------------- /test_fixtures/show_missing_strings/d_option/input_files/extra_strings/app.go.en.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "This should be verified.", 4 | "translation": "This should be verified." 5 | }, 6 | { 7 | "id": "This should be also {{.Verified}}", 8 | "translation": "This should be also {{.Verified}}" 9 | }, 10 | { 11 | "id": "Can I haz extras?", 12 | "translation": "Can I haz extras?" 13 | }, 14 | { 15 | "id": "verified", 16 | "translation": "verified" 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /test_fixtures/show_missing_strings/d_option/input_files/extra_strings/code/app.go: -------------------------------------------------------------------------------- 1 | package app 2 | 3 | func main() { 4 | println("I am a string") 5 | println(T("This should be verified.")) 6 | println(T("This should be also {{.Verified}}", map[string]interface{}{ 7 | "Verified": T("verified"), 8 | })) 9 | } 10 | -------------------------------------------------------------------------------- /test_fixtures/show_missing_strings/d_option/input_files/missing_strings/app.go.en.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "This should be verified.", 4 | "translation": "This should be verified." 5 | }, 6 | { 7 | "id": "This should be also {{.Verified}}", 8 | "translation": "This should be also {{.Verified}}" 9 | }, 10 | { 11 | "id": "verified", 12 | "translation": "verified" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /test_fixtures/show_missing_strings/d_option/input_files/missing_strings/code/app.go: -------------------------------------------------------------------------------- 1 | package app 2 | 3 | func main() { 4 | println(T("I am a missing string")) 5 | println(T("This should be verified.")) 6 | println(T("This should be also {{.Verified}}", map[string]interface{}{ 7 | "Verified": T("verified"), 8 | })) 9 | } 10 | -------------------------------------------------------------------------------- /test_fixtures/show_missing_strings/d_option/input_files/no_missing_strings/app.go.en.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "This should be verified.", 4 | "translation": "This should be verified." 5 | }, 6 | { 7 | "id": "This should be also {{.Verified}}", 8 | "translation": "This should be also {{.Verified}}" 9 | }, 10 | { 11 | "id": "verified", 12 | "translation": "verified" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /test_fixtures/show_missing_strings/d_option/input_files/no_missing_strings/code/app.go: -------------------------------------------------------------------------------- 1 | package app 2 | 3 | import "strings" 4 | 5 | func main() { 6 | println("I am a string") 7 | println(T("This should be verified.")) 8 | println(T("This should be also {{.Verified}}", map[string]interface{}{ 9 | "Verified": T("verified"), 10 | })) 11 | println(T(strings.Join("a", "b"))) //ast.Expr is *ast.CallExpr, not *ast.BasicLit 12 | } 13 | -------------------------------------------------------------------------------- /test_fixtures/verify_strings/duplicate_keys/input_files/quota.go.en.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Show quota info", 4 | "translation": "Show quota info" 5 | }, 6 | { 7 | "id": "Show quota info", 8 | "translation": "Show quota info" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /test_fixtures/verify_strings/duplicate_keys/input_files/quota.go.fr.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Show quota info", 4 | "translation": "Show quota info" 5 | }, 6 | { 7 | "id": "Show quota info", 8 | "translation": "Show quota info" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /test_fixtures/verify_strings/f_option/input_files/quota.go.af.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Show quota info", 4 | "translation": "Wys kwota info" 5 | }, 6 | { 7 | "id": "Routes", 8 | "translation": "Roetes" 9 | }, 10 | { 11 | "id": "Services", 12 | "translation": "Dienste" 13 | }, 14 | { 15 | "id": "CF_NAME quota QUOTA", 16 | "translation": "CF_NAME aandeel fooi" 17 | }, 18 | { 19 | "id": "Getting quota {{.QuotaName}} info as {{.Username}}...", 20 | "translation": "Aan die kwota {{.QuotaName}} Info as {{.Username}} ..." 21 | }, 22 | { 23 | "id": "Memory Limit", 24 | "translation": "Memory perk" 25 | }, 26 | { 27 | "id": "Paid service plans", 28 | "translation": "Betaalde diens planne" 29 | } 30 | ] 31 | -------------------------------------------------------------------------------- /test_fixtures/verify_strings/f_option/input_files/quota.go.cs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Show quota info", 4 | "translation": "Info Zobrazit kvóta" 5 | }, 6 | { 7 | "id": "Routes", 8 | "translation": "Trasy" 9 | }, 10 | { 11 | "id": "Services", 12 | "translation": "Služby" 13 | }, 14 | { 15 | "id": "CF_NAME quota QUOTA", 16 | "translation": "CF_NAME podíl POPLATEK" 17 | }, 18 | { 19 | "id": "Getting quota {{.QuotaName}} info as {{.Username}}...", 20 | "translation": "Jak kvóty {{.QuotaName}} info jako {{.Username}} ..." 21 | }, 22 | { 23 | "id": "Memory", 24 | "translation": "Paměť" 25 | }, 26 | { 27 | "id": "Memory Limit", 28 | "translation": "Limit paměti" 29 | }, 30 | { 31 | "id": "Paid service plans", 32 | "translation": "Placené servisní plány" 33 | } 34 | ] 35 | -------------------------------------------------------------------------------- /test_fixtures/verify_strings/f_option/input_files/quota.go.de.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Show quota info", 4 | "translation": "Zeige Quote info" 5 | }, 6 | { 7 | "id": "Routes", 8 | "translation": "Routen" 9 | }, 10 | { 11 | "id": "Services", 12 | "translation": "Dienstleistungen" 13 | }, 14 | { 15 | "id": "CF_NAME quota QUOTA", 16 | "translation": "CF_NAME Aktien FEE" 17 | }, 18 | { 19 | "id": "Memory", 20 | "translation": "Speicher" 21 | }, 22 | { 23 | "id": "Paid service plans", 24 | "translation": "Paid Service-Pläne" 25 | } 26 | ] -------------------------------------------------------------------------------- /test_fixtures/verify_strings/f_option/input_files/quota.go.en.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Show quota info", 4 | "translation": "Show quota info" 5 | }, 6 | { 7 | "id": "Routes", 8 | "translation": "Routes" 9 | }, 10 | { 11 | "id": "Services", 12 | "translation": "Services" 13 | }, 14 | { 15 | "id": "CF_NAME quota QUOTA", 16 | "translation": "CF_NAME quota QUOTA" 17 | }, 18 | { 19 | "id": "Getting quota {{.QuotaName}} info as {{.Username}}...", 20 | "translation": "Getting quota {{.QuotaName}} info as {{.Username}}..." 21 | }, 22 | { 23 | "id": "Memory", 24 | "translation": "Memory" 25 | }, 26 | { 27 | "id": "Paid service plans", 28 | "translation": "Paid service plans" 29 | } 30 | ] -------------------------------------------------------------------------------- /test_fixtures/verify_strings/f_option/input_files/quota.go.es.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Show quota info", 4 | "translation": "Mostrar información de cuotas" 5 | }, 6 | { 7 | "id": "Routes", 8 | "translation": "Rutas" 9 | }, 10 | { 11 | "id": "Services", 12 | "translation": "Servicios" 13 | }, 14 | { 15 | "id": "CF_NAME quota QUOTA", 16 | "translation": "Cuota CF_NAME FEE" 17 | }, 18 | { 19 | "id": "Getting quota {{.QuotaName}} info as {{.Username}}...", 20 | "translation": "Conseguir cuota {{.QuotaName}} info como {{. Nombre de usuario}} ..." 21 | }, 22 | { 23 | "id": "Memory", 24 | "translation": "Memoria" 25 | }, 26 | { 27 | "id": "Paid service plans", 28 | "translation": "Los planes de servicios de pago" 29 | } 30 | ] 31 | -------------------------------------------------------------------------------- /test_fixtures/verify_strings/f_option/input_files/quota.go.fr.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Show quota info", 4 | "translation": "Afficher les infos de quota" 5 | }, 6 | { 7 | "id": "Routes", 8 | "translation": "Routes" 9 | }, 10 | { 11 | "id": "Services", 12 | "translation": "Services" 13 | }, 14 | { 15 | "id": "CF_NAME quota QUOTA", 16 | "translation": "CF_NAME quota QUOTA" 17 | }, 18 | { 19 | "id": "Getting quota {{.QuotaName}} info as {{.Username}}...", 20 | "translation": "Obtenir quota {{.QuotaName}} informations de l'utilisateur {{.Username}} ..." 21 | }, 22 | { 23 | "id": "Memory", 24 | "translation": "Mémoire" 25 | }, 26 | { 27 | "id": "Paid service plans", 28 | "translation": "Plans de services payés" 29 | } 30 | ] -------------------------------------------------------------------------------- /test_fixtures/verify_strings/f_option/input_files/quota.go.it.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Show quota info", 4 | "translation": "Info Mostra quota" 5 | }, 6 | { 7 | "id": "Routes", 8 | "translation": "Rotte" 9 | }, 10 | { 11 | "id": "Services", 12 | "translation": "Servizi" 13 | }, 14 | { 15 | "id": "CF_NAME quota QUOTA", 16 | "translation": "CF_NAME quota QUOTA" 17 | }, 18 | { 19 | "id": "Memory", 20 | "translation": "Memoria" 21 | }, 22 | { 23 | "id": "Paid service plans", 24 | "translation": "Piani di servizio a pagamento" 25 | } 26 | ] -------------------------------------------------------------------------------- /test_fixtures/verify_strings/f_option/input_files/quota.go.ja.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Show quota info", 4 | "translation": "表示クォータ情報" 5 | }, 6 | { 7 | "id": "Routes", 8 | "translation": "ルート" 9 | }, 10 | { 11 | "id": "Services", 12 | "translation": "サービス" 13 | }, 14 | { 15 | "id": "CF_NAME quota QUOTA", 16 | "translation": "CF_NAMEシェア料" 17 | }, 18 | { 19 | "id": "Getting quota {{.QuotaName}} info as {{.Username}}...", 20 | "translation": "{{.Username}}ユーザー名}}のように、クォータ{{.QuotaName}}の情報を取得中..." 21 | }, 22 | { 23 | "id": "Memory", 24 | "translation": "メモリ" 25 | }, 26 | { 27 | "id": "Memory Limit", 28 | "translation": "メモリの制限" 29 | }, 30 | { 31 | "id": "Paid service plans", 32 | "translation": "有料のサービスプラン" 33 | } 34 | ] -------------------------------------------------------------------------------- /test_fixtures/verify_strings/f_option/input_files/quota.go.vi.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /test_fixtures/verify_strings/f_option/input_files/quota.go.zh_CN.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "Show quota info", 4 | "translation": "显示配额信息" 5 | }, 6 | { 7 | "id": "Routes", 8 | "translation": "路线" 9 | }, 10 | { 11 | "id": "Services", 12 | "translation": "服务" 13 | }, 14 | { 15 | "id": "CF_NAME quota QUOTA", 16 | "translation": "CF_NAME份额费用QUOTA" 17 | }, 18 | { 19 | "id": "Getting quota {{.QuotaName}} info as {{.Username}}...", 20 | "translation": "获得配额{{.QuotaName}}信息为{{.Username}} ..." 21 | }, 22 | { 23 | "id": "Memory", 24 | "translation": "记忆" 25 | }, 26 | { 27 | "id": "Paid service plans", 28 | "translation": "有偿服务计划" 29 | } 30 | ] --------------------------------------------------------------------------------