Sha256: 186ed2cb82b3e46fd3de12948535fcb4bfeea39fd8140957a64a56c550d9f3f3
Contents?: true
Size: 633 Bytes
Versions: 9
Compression:
Stored size: 633 Bytes
Contents
<%- require 'net/http' require 'uri' require 'json' class GoogleTranslate def self.t(text) uri = URI.parse('http://ajax.googleapis.com/ajax/services/language/translate') JSON.parse(Net::HTTP.post_form(uri, {"q" => text, "langpair" => "en|zh-TW", "v" => '1.0'}).body)['responseData']['translatedText'] rescue text.humanize end end -%> "zh-TW": activerecord: models: <%= singular_name %>: <%= GoogleTranslate.t singular_name.humanize %> attributes: <%= singular_name %>: <% attributes.each do |attribute| -%> <%= attribute.name %>: <%= GoogleTranslate.t attribute.name.humanize %> <% end -%>
Version data entries
9 entries across 9 versions & 2 rubygems