jodosha / globalize forked from heythisisnate/globalize

Globalize is a Ruby on Rails plugin designed to support multilingual applications (official repository).

This URL has Read+Write access

globalize / README
a727ed7f » yannlugrin 2006-10-13 import from old svn hosting... 1 =Welcome to Globalize
2
c5f9de6c » saimonmoore 2007-01-17 --Integrating db_localizes ... 3 *Globalize* is a Ruby on Rails plugin designed to support globalized applications.
4 It supports translation into multiple languages (for both db content and controller
5 and view code) and localization of time, data, and numbers.
6 It's under the MIT License, same as Ruby on Rails.
a727ed7f » yannlugrin 2006-10-13 import from old svn hosting... 7
fa331b24 » saimonmoore 2007-01-22 --Adding more documentation... 8 == How to use it
a727ed7f » yannlugrin 2006-10-13 import from old svn hosting... 9
fa331b24 » saimonmoore 2007-01-22 --Adding more documentation... 10 Decide where you'd like globalize to store your translations.
c5f9de6c » saimonmoore 2007-01-17 --Integrating db_localizes ... 11
fa331b24 » saimonmoore 2007-01-22 --Adding more documentation... 12 By default globalize stores translations externally in a dedicated table but now
13 you also have the option to store translations within the model's own table.
c5f9de6c » saimonmoore 2007-01-17 --Integrating db_localizes ... 14
fa331b24 » saimonmoore 2007-01-22 --Adding more documentation... 15 To set this method as the default for add:
c5f9de6c » saimonmoore 2007-01-17 --Integrating db_localizes ... 16
fa331b24 » saimonmoore 2007-01-22 --Adding more documentation... 17 Globalize::DbTranslate.keep_translations_in_model = true
c5f9de6c » saimonmoore 2007-01-17 --Integrating db_localizes ... 18
fa331b24 » saimonmoore 2007-01-22 --Adding more documentation... 19 to your environment.rb.
c5f9de6c » saimonmoore 2007-01-17 --Integrating db_localizes ... 20
fa331b24 » saimonmoore 2007-01-22 --Adding more documentation... 21 === In your models
a727ed7f » yannlugrin 2006-10-13 import from old svn hosting... 22
c5f9de6c » saimonmoore 2007-01-17 --Integrating db_localizes ... 23 #All translations stored in a separate table
a727ed7f » yannlugrin 2006-10-13 import from old svn hosting... 24 class Product < ActiveRecord::Base
25 translates :name, :description, :specs
26 end
27
c5f9de6c » saimonmoore 2007-01-17 --Integrating db_localizes ... 28 or you can override the global setting per model by:
29
30 #All translations stored 'products' table
31 class Product < ActiveRecord::Base
32
33 self.keep_translations_in_model = true
34
fa331b24 » saimonmoore 2007-01-22 --Adding more documentation... 35 translates
36 :name, :description, :specs
c5f9de6c » saimonmoore 2007-01-17 --Integrating db_localizes ... 37 end
38
a727ed7f » yannlugrin 2006-10-13 import from old svn hosting... 39 Then:
40
fa331b24 » saimonmoore 2007-01-22 --Adding more documentation... 41 Using <i>keep_translations_in_model = false</i>:
c5f9de6c » saimonmoore 2007-01-17 --Integrating db_localizes ... 42
a727ed7f » yannlugrin 2006-10-13 import from old svn hosting... 43 Locale.set("en-US")
c5f9de6c » saimonmoore 2007-01-17 --Integrating db_localizes ... 44 prod = Product.find(1)
a727ed7f » yannlugrin 2006-10-13 import from old svn hosting... 45
46 <tt>prod.name -> "Meatballs"</tt>
47
48 Locale.set("es-ES")
c5f9de6c » saimonmoore 2007-01-17 --Integrating db_localizes ... 49 prod = Product.find(1) #Note: A reload of the model instance is required after a locale change.
a727ed7f » yannlugrin 2006-10-13 import from old svn hosting... 50
51 <tt>prod.name -> "Albondigas"</tt>
52
c5f9de6c » saimonmoore 2007-01-17 --Integrating db_localizes ... 53
fa331b24 » saimonmoore 2007-01-22 --Adding more documentation... 54 Using <i>keep_translations_in_model = true</i>:
c5f9de6c » saimonmoore 2007-01-17 --Integrating db_localizes ... 55
56 Locale.set("en-US")
57 prod = Product.find(1)
58
59 <tt>prod.name -> "Meatballs"</tt>
60
61 Locale.set("es-ES")
62
63 <tt>prod.name -> "Albondigas"</tt> #Note: No reload of model is required
64
a727ed7f » yannlugrin 2006-10-13 import from old svn hosting... 65 === In your views (or anywhere else)
66
67 Locale.set("he-IL")
c5f9de6c » saimonmoore 2007-01-17 --Integrating db_localizes ... 68 <%= "Thanks for ordering!".t %> -> "תודה על ההזמנה!"
a727ed7f » yannlugrin 2006-10-13 import from old svn hosting... 69 <%= "You've got %d items in your cart" / 5 %> -> "יש 5 מוצרים בסל שלך"
70
71 Locale.set("es-ES")
72 <%= Time.now.loc("%d %B %Y") %> -> "17 Octubre 2005"
73 <%= 12345.45.loc %> -> "12.345,45"
74
c5f9de6c » saimonmoore 2007-01-17 --Integrating db_localizes ... 75 See the wiki (http://www.globalize-rails.org/) for more documentation.
a727ed7f » yannlugrin 2006-10-13 import from old svn hosting... 76
fa331b24 » saimonmoore 2007-01-22 --Adding more documentation... 77 == How to install
a727ed7f » yannlugrin 2006-10-13 import from old svn hosting... 78
79 From your rails app root directory:
80
4cc24938 » saimonmoore 2007-03-12 --Backporting for-1.2 features 81 1. <tt>script/plugin install http://svn.globalize-rails.org/svn/globalize/trunk</tt>
82 2. <tt>rake globalize:setup</tt> (might take a while, about a minute or so)
a727ed7f » yannlugrin 2006-10-13 import from old svn hosting... 83
84 ...and you're globalized, dude!
85
86 Optionally, try:
87
88 * <tt>rake test_plugins</tt>
c5f9de6c » saimonmoore 2007-01-17 --Integrating db_localizes ... 89 * <tt>rake plugindoc</tt>