iOS Polyglot CLI

Polyglot client for iOS development

Installation

If you use old polyglot-cli or native polyglot please uninstall them first:

sudo gem uninstall polyglot-cli
brew uninstall --force infinum/formulae/polyglot

Then to install polyglot simply run:

gem install ios_polyglot_cli

If you have any issues with the above command, please consult this thread.

You can check if everything is OK running:

polyglot --help

You should see the output with all commands and their description.

Usage

Login

Login command is removed!

To generate an Auth Token please visit https://infinum.polyglothq.com, generate a new token under Settings -> Security and store it in your environment variables under POLYGLOT_TOKEN environment variable (or whatever variable your project is using).

Setup

To setup polyglot in your Xcode project use:

polyglot init

It will prompt you with a project list to select the one you are setting up. You can provide source language (Swift/ObjC), translations path and resources path. It will create polyglot.yml file which you can edit later and add additional Polyglot projects.

Optional parameters:

  • --query will prompt you with a list of all projects that match the specified query.
  • --url URL of the Polyglot API, if not provided, either https://infinum.polyglothq.com/api/v2/ or one from polyglot.yml file will be used.
  • --token Auth token. If not provided, an environment variable value will be used (either POLYGLOT_TOKEN or one from polyglot.yml).

Projects

If you want to see all polyglot projects and their IDs enter:

polyglot projects

Optional parameters:

  • --query will prompt you with a list of all projects that match the specified query.
  • --url URL of the Polyglot API, if not provided, either https://infinum.polyglothq.com/api/v2/ or one from polyglot.yml file will be used.
  • --token Auth token. If not provided, an environment variable value will be used (either POLYGLOT_TOKEN or one from polyglot.yml).

Pull

Finally, to fetch translations use:

$ polyglot pull

Optional parameters:

  • --url URL of the Polyglot API, if not provided, either https://infinum.polyglothq.com/api/v2/ or one from polyglot.yml file will be used.
  • --token Auth token. If not provided, an environment variable value will be used (either POLYGLOT_TOKEN or one from polyglot.yml).

Config syntax

# polyglot.yml file
language: swift
url: https://myproject.polyglothq.com/api/v2/ # Optional, https://infinum.polyglothq.com/api/v2/ by default
token_env_variable: CUSTOM_POLYGLOT_TOKEN_VARIABLE # Optional, POLYGLOT_TOKEN by default
skip_writing_language_struct: false # Optional, false by default
useOldNaming: false # Optional, false by default
projects:
  -
    id: 1234
    path: ./ProjectOne/Resources/Translations/
    sourceFilesPath: ./ProjectOne/Sources/Translations/
  -
    id: 6789
    path: ./ProjectTwo/Resources/Translations/
    sourceFilesPath: ./ProjectTwo/Sources/Translations/

Legacy projects

New style translations will create file names en_US.strings for example, and some old projects still use old naming in the style of en.strings. To get around this issue, you either need to migrate your project to use the new naming (be mindful of the existing app's settings), or add this line under your path value:

useOldNaming: true

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 tags, and push the .gem file to rubygems.org.

To release a new version to rubygems, you will need to be added as an owner of polyglot project on rubygems. Owners that can add other users are listed on project's rubygems page.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/infinum/ios_polyglot_cli.

License

The gem is available as open source under the terms of the MIT License.