Giter VIP home page Giter VIP logo

motion-i18n's Introduction

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.