Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Rails plugin that provides support for adding translation to dynamic content
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
generators/has_translations
lib
rails
tasks
test
MIT-LICENSE
README
README~
Rakefile
init.rb
install.rb
uninstall.rb

README

HasTranslations
===============
The has_translations plugin can be used to add translations to your model . Rails provides internationalization support for static content , has_translations complements that and provides internationalization support for dynamic contents .

To Install :
1. Place the plugin in vendor/plugins directory of your rails app.
2. Go to the home folder of your app and run "script/generate has_translations"
3. Run "rake db:migrate" . That's it ! you are ready now .

Example
=======
Suppose you have a Model "Post" with fields "title" and "description" . And you want to add translations for the "title" and "description" fields


Class Post
has_translations :title , :description  [ Add this line in your model ]


To consume  :

Post p = Post.new
p.title_add_translation(:fr,"something in french")
p.title_add_translation(:ru,"something in russian")

To retrieve the translarion use
p.title_get_translation(:fr)

To retrieve all translations use :
p.title_get_all_translations()  
This function will return a hash with key as language and value as the translation value. So for te above case it will return :
["fr" => "something in french" , "ru" => "something in russian" ]
Something went wrong with that request. Please try again.