iOS Localizer
A Ruby gem that makes it easy to localize iOS applications.
This gem uses Google Translate's REST API to translate all the Localizable.strings files generated by XCode to the file's respective language.
Created by Daniel Olshansky (@olshansky) and Amandeep Grewal (@amandeep).
Prerequisites
1. API Access
Google's translating services cost $20 per 1M characters so you must get a valid key prior to using this gem.
Go to the Google APIs Console. Under Services, enable Translate API and complete the required forms to enable payments.
2. Localizing your strings
I would also personally recommend that all the strings displayed to the user should be removed from any .nib files and added via code to make your project more systematic and easier to manage.
Any string displayed to the User must be formatted in the following way:
NSLocalizedString(@"String to be displayed", @"Comment about the string");
3. Localizable.strings files
Create a new Strings file:
- Go to File > New > File
- On the left hand side go to Resource (iOS or OS X depending on the application) and choose Strings File. Call the file Localizable.strings.
Select the new Localizable.strings file and make it localizable by clicking the Make localized button.
4. Adding new languages
Adding an additional language is very simple with XCode. This image shows you where you can choose to add or remove languages that application should be localized for depending on who your target demographic.
Installation
gem install ios_localizer
Usage
- Navigate into your project's directory in terminal:
i.e. cd ~/Documents/workspace/ExampleProjectName/
- The most common use case of the gem would then be:
i.e. ios_localizer -k YoureKeyHere1234567890
- If the source language is not english, you can specify it as follows:
i.e. ios_localizer -k YoureKeyHere1234567890 -s nl
where nl
is the ISO 639 representation of the source language
- If you have already run the script but added a new localization language afterwards, you can avoid retranslating (and wasting your credit) as follows:
i.e. ios_localizer -k YoureKeyHere1234567890 -n la -n lb -n lc
where la
, lb
and lc
are the ISO 639 representations of the languages you
would like to avoid translating to (given that you have added them in
XCode under Localizations).
Contributing
Any and all pull requests are welcome!
Copyright and license
Copyright 2012 Daniel Olshansky & Amandeep Grewal
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with the License. You may obtain a copy of the License in the LICENSE file, or 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.