Skip to content

tkadauke/motion-i18n

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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!

About

Wrapper for translations in RubyMotion

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages