Kunstmaan I18n-Strings
Features
- Lookup all translation keys inside your Xcode project.
- Optimize build phase if there are missing translations.
- Sync translations from a shared datastore
Example project integrating this in the Xcode build process can be found here i18n-swift-example
Installation
npm
To install the kuma-i18n-strings cli command globally, you can run the following command:
$ npm install -g kuma-i18n-strings
Syncing from Google Spreadsheets
Setting up a Google Service Account for syncing with Google Spreadsheets
This is a 2-legged oauth method and designed to be "an account that belongs to your application instead of to an individual end user". Use this for an app that needs to access a set of documents that you have full access to. (read more)
Setup Instructions
- Go to the Google Developers Console
- Select your project or create a new one (and then select it)
- Enable the Drive API for your project
- In the sidebar on the left, expand APIs & auth > APIs
- Search for "drive"
- Click on "Drive API"
- click the blue "Enable API" button
- Create a service account for your project
- In the sidebar on the left, expand APIs & auth > Credentials
- Click blue "Add credentials" button
- Select the "Service account" option
- Select the "JSON" key type option
- Click blue "Create" button
- your JSON key file is generated and downloaded to your machine (it is the only copy!)
- note your service account's email address (also available in the JSON key file)
- Share the doc (or docs) with your service account using the email noted above
- Create a .kuma-i18n-strings configuration file that looks as follows:
For more information about setting up a Service Account look at the google-spreadsheet npm package
Multiple values are possible for the column names where the values can be found. This way you can use the translation file for multiple platforms. The array should contain the column names sorted by importance. If there is no value found in the first column it will fall back to the next and so on ...
In the column names for the values you can specify the language by adding $$LANG$$
this will be replaced by the actual language. For example: ios fallback $$LANG$$
will become ios fallback en
.
Syncing from an endpoint that returns strings files
Currently only endpoints returning strings files are supported.
Usage
To collect all the strings from the storyboard, swift files:
$ kuma-i18n-strings collect
To sync the translations with an online datastore (for now only google spreadsheets):
$ kuma-i18n-strings sync
Options
-s, --source Specify the path where the Xcode files are located-c, --config Specify the path to the kuma-i18n configuration file relative to the source path, default .kuma-i18n-strings-u, --update-files Specify
When you are using the above commands without -u
or --update-files
it will exit with an exit code of -1 when there are new translations in the online datastore or in the xcode project. This way you can integrate it within your build phases so that building fails when the translations aren't up-to-date.
Roadmap
- Add Android support, especially for syncing