Skip to content

Latest commit

 

History

History
124 lines (64 loc) · 3.65 KB

README.rdoc

File metadata and controls

124 lines (64 loc) · 3.65 KB

We have the most updated gem here: github.com/onesky/onesky-ruby

OneSky: The Community-Powered Translation Service

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 is the basic interface to the RESTful API. It is used as the main building block for higher-level utilities and libraries such as the i18n-one_sky gem.

Installing

Get from RubyGems.org by:

gem install one_sky

Usage

Just the basic usage scenarios are shown here. See OneSky::Project for more available methods.

Initialization

Provide the API key and secret which you can get from the web UI. Also provide the name of the project you created.

require 'one_sky'

client = OneSky::Client.new("my_api_key", "my_api_secret")

Project

Load a specific project by name.

project = client.project("my-project-name")

Get the details of the project.

project.details

See what platforms are available.

project.platforms

Platform

Load a specific platform by id.

platform = project.platform(123)

Get the details of the platform.

platform.details

See what locales are assigned.

platform.locales

Translation

Get the translation proxy for a platform

translation = platform.translation

Submit a phrase for translation

Submit a single string:

translation.input_string("Hello World!")

Submit a string with a specified key, context, and page:

translation.input_string(:string => "Hello World!", :string_key => "hello_world", :context => "my_context", :page => "my_page")

Submit many strings at once:

translation.input_strings(["Hello World!", "Goodbye Moon"])

Provide a translation

Submit a translation for a given key, in a given locale.

translation.translate("hello_world", "zh_CN", "世界你好")

Get translated phrases

So you’ve submitted your phrases and your translators/users or the general OneSky community have kindly provided translations for them. It’s time now to download those.

translations = translation.output

=> {"Default"=>{"en-us"=>{"Hello World!"=>"Hello World!"}, "zh-cn"=>{"Hello World!"=>"\u4E16\u754C\u60A8\u597D\uFF01"}, "es-es"=>{"Hello World!"=>"Hola Mundo!"}}}

Let’s pretty print that a bit:

translations["Default"].map { |k,v| puts "#{k}: #{v['Hello World!']}" }

en-us: Hello World!
zh-cn: 世界您好!
es-es: Hola Mundo!

Provide a single sign-on (SSO) link for your translators

OneSky is all about community-powered translations. You can mark your project as public and any OneSky member translator can help in translating your phrases. Or if you mark it as private, only those you give access to can do so. For instance, you’d like your own website’s user base to help you out. You can take a user’s unique ID and bind it to OneSky:

client.utility.get_sso_link("myapp/users/123456", "fred")
=> "http://rubyredtomatoes.oneskyapp.com/?time=1294020222&id=myapp/users/123456&data=3d56315499647c0419867283767aa270"

That user can then use the above link to automatically sign in to OneSky and start translating for you.

Using with Rails

See the i18n-one_sky gem for Rails and I18n integration.

History

See CHANGELOG

Credits

See CREDITS

License

Copyright 2010-2011 OneSky, Inc.

Licensed under the MIT License.