0.01
No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
Wrapper for translations in RubyMotion
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

 Project Readme

MotionI18n

Rails-style translations for RubyMotion apps.

This gem allows you to specify your RubyMotion translations as .yml files. The translations are automatically converted to Cocoa's native format for translations.

Installation

gem install motion-i18n

and in your Rakefile:

require 'motion-i18n'

or using bundler:

gem "motion-i18n"

Usage

Put your translations in YAML files in config/locales/. For each locale there should be a file named as the locale with the extension .yml, e.g. en.yml, de.yml etc.

Translations

For a guide on how the translation files should look like, see http://guides.rubyonrails.org/i18n.html#adding-translations

To translate a string, use I18n.translate or the shortcut I18n.t like this:

I18n.t("main_screen.title")

To substitute variables in the string, specify the substitutions in second a hash argument

I18n.t("maps.directions", :from => origin, :to => destination)

Locale

You can get the current locale by calling

I18n.locale

Setting the locale is done by changing the language settings on the mobile device or simulator. Setting the locale via code or in the Rakefile will have no effect or generate an error.

Workflow

This gem works perfectly together with the i18n_tools gem:

gem install i18n_tools

or in Gemfile;

gem "i18n_tools", :require => "i18n_tools/tasks"

The gem will give you the tasks rake translations:missing which shows untranslated strings as well as rake translations:unused which shows strings which are translated but not used in the code. For more information, see i18n_tools.

Warning

For each locale loc, this gem overwrites the file resources/loc.lproj/Localizable.strings before building. Make sure you don't edit this file. Also, you should add these files to .gitignore:

Localizable.strings

Forking

Feel free to fork and submit pull requests!