Translate CLI
Installation
Install as part of your application
Add this line to your application's Gemfile
:
gem 'translate_client'
And then execute:
bundle
Installing the translate
command standalone
Install it yourself as:
gem install translate_client
Usage
Run translate help
to view available commands. Run translate help [COMMAND]
for help with that specific command.
translate auth login
Opens the Translate app in a web browser where you can allow access to the CLI.
translate auth whoami
Prints the email address with which you're logged in.
$ translate auth whoami
> You're logged in as [email protected].
translate auth logout
Logs you out again.
translate pull [--project=PROJECT] [--locale=LOCALE] [--format=FORMAT] [--out=OUT]
Pull translations from the webapp down to your computer.
translate pull --project "12345678-1234-abcd-5678-ef1234567890" --locale en --in config/locales/en.yml --format rails
Most options can be inferred (see below), so depending on your configuration, you can also do:
translate pull
translate push [--project=PROJECT] [--locale=LOCALE] [--format=FORMAT] [--in=IN]
Push translations from your computer back to the webapp.
translate push --project "12345678-1234-abcd-5678-ef1234567890" --locale en --in config/locales/en.yml --format rails
Most options can be inferred (see below), so depending on your configuration, you can also do:
translate push
Automatically inferring options
--project/-p
: Unless provided, it will try to read thetranslate.project
key from apackage.json
in the working directory:json { "name": "your-cool-project", "translate": { "project": "12345678-1234-abcd-5678-ef1234567890" } }
--format/-f
: Unless provided, it will try to automatically detect your project type. This currently only recognizes Ruby on Rails projects by checking whether you have aGemfile
matching/gem.+\brails\b/
in the working directory--locale/-l
: If you provide a locale, it will pull/push only the provided locale. If you don't provide it, it will either pull all locales on the server, or it will push all the locales in your project. (It can only push all your locales if it can recognize your locale directory. This currently only works for Ruby on Rails projects, where it will recognizeconfig/locales/*.yml
)--in/-i
or--out/-o
: If you provide a--locale
, you can also provide the a file path. If it's a relative path, it will be resolved relative to the working directory.
Development
After checking out the repo, run bin/setup
to install dependencies. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and the created tag, and push the .gem
file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/nerdgeschoss/translate_client. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
License
The gem is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the Translate CLI project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.