Skip to content

A set of I18n extensions that use the OneSky service.

License

Notifications You must be signed in to change notification settings

uken/i18n-one_sky-ruby

 
 

Repository files navigation

I18n OneSky

OneSky is a new service that lets developers reach a global audience by easily enabling them to translate their websites and applications to different languages through the help of the community.

This gem integrates OneSky and I18n. At its most basic, it allows you to take the phrases defined under I18n’s default locale and upload them to OneSky for translation by the community. Afterwards, you can download available translations and save them as Simple backend YAML files.

added Database backend storage support since version 0.0.3

Using inside a Rails project

In your Rails root, edit your Gemfile to include this gem:

# Gemfile
gem 'rails', '3.0.3'
...
gem 'i18n-one_sky'

Then tell Bundler to install:

bundle install

If you haven’t done so yet, log in to your account at OneSky and create a new project for this Rails app. Also, find the API key and secret which you will supply here:

rails generate one_sky:init my_api_key my_api_secret my_project my_platform_id

This will create the configuration file config/one_sky.yml.

So assuming that you already have your phrases defined for your default locale and all your views contain the ubiquitous t() methods, it’s time now to submit these phrases to OneSky:

rake one_sky:upload

Then ask your translators to provide the translations using the OneSky website. When they’re done and a few new languages are available, download them by:

rake one_sky:download

This will save the translations inside config/locales/*_one_sky.yml files. You now have more languages supported and it’s just a matter of pushing again to production. You can call upload and download over and over as you incrementally internationalize your site.

Using outside Rails

Although I18n is commonly known as the default internationalization module for Rails, it actually is designed to be used outside Rails, too. And so is i18n-one_sky.

Install it like any regular gem:

gem install i18n-one_sky

And see I18n::OneSky::SimpleClient for the methods available in Ruby.

Using Database as translation storage, YAML as fallback (since version 0.0.3, Rails only)

The following command generates rails initializers and run db migration:

rails generate one_sky:init_active_record_backend

use the upload_phrases rake command to upload your default locale to one sky server:

rake one_sky:active_record:upload

Then, instead of running one_sky:download, run the following command to download and store the translations into translations database table:

rake one_sky:active_record:download

Using i18n-one_sky gem in Heroku

Because Heroku is read-only file system, you have to use database storage as storage backend. Either configure the “ONESKY_API_KEY”, “ONESKY_API_SECRET”, “ONESKY_PROJECT”, “ONESKY_PLATFORM_ID” environment variables manually or use the OneSky Heroku addon.

Read “Using Database as translation storage” sections for details to upload and download phrases.

History

See CHANGELOG

Credits

See CREDITS

License

Copyright 2010-2011 OneSky, Inc.

Licensed under the MIT License.

About

A set of I18n extensions that use the OneSky service.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%