GithubHelp home page GithubHelp logo

one_sky-ruby's Introduction

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.

one_sky-ruby's People

Contributors

matthewrudy avatar beljun avatar 3dd13 avatar loking avatar

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.