iOS Polyglot CLI
Polyglot client for iOS development
Table of contents
Getting started
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 frompolyglot.yml
file will be used.--token
Auth token. If not provided, an environment variable value will be used (eitherPOLYGLOT_TOKEN
or one frompolyglot.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 frompolyglot.yml
file will be used.--token
Auth token. If not provided, an environment variable value will be used (eitherPOLYGLOT_TOKEN
or one frompolyglot.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 frompolyglot.yml
file will be used.--token
Auth token. If not provided, an environment variable value will be used (eitherPOLYGLOT_TOKEN
or one frompolyglot.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/
Documentation Language Configuration
To enable polyglot
to document translations in a specific language, add a new flag called documentationLanguage
to your polyglot.yaml
file under the project requiring documentation. The documentationLanguage
value should follow a locale format (e.g., en_GB
for en
).
When running polyglot
, it will attempt to find an exact match for the specified locale. If no match is found, polyglot
will abort the pull operation and output a list of all supported language variations to the console for reference.
If the documentationLanguage
flag is not set in the polyglot.yaml
file, polyglot
will default to using the defaultLanguage
. If the defaultLanguage
is also unavailable, polyglot
will default to the first language listed among the available languages for documentation.
Example:
# polyglot.yaml
...
:projects:
- :id: '[projectId]'
:path: "[translationPath]"
:sourceFilesPath: "[sourceFilePath]"
:documentationLanguage: "en_GB"
...
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
We believe that the community can help us improve and build better a product. Please refer to our contributing guide to learn about the types of contributions we accept and the process for submitting them.
To ensure that our community remains respectful and professional, we defined a code of conduct that we expect all contributors to follow.
We appreciate your interest and look forward to your contributions.
License
Copyright 2024 Infinum
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Credits
Maintained and sponsored by Infinum.