diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-06-27 22:52:50 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-06-27 22:52:50 +0200 |
| commit | 9a19a0494ef51cdac9a78e24d517ca48ba44c453 (patch) | |
| tree | 8eaae12d8047a40e29d3ea7ff3116b5c869e04bd /vendor/plugins/globalize2/README.textile | |
| parent | 85a01e35274b8d4d4165a7b26bd7986e211246bb (diff) | |
| parent | 1853082fcd8c067390c246f9daa01a9b47387497 (diff) | |
Migration from Rails 2.3.5 to Rails 8.1 successful.
Merging dev branch.
Diffstat (limited to 'vendor/plugins/globalize2/README.textile')
| -rw-r--r-- | vendor/plugins/globalize2/README.textile | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/vendor/plugins/globalize2/README.textile b/vendor/plugins/globalize2/README.textile deleted file mode 100644 index 7155a7c..0000000 --- a/vendor/plugins/globalize2/README.textile +++ /dev/null | |||
| @@ -1,65 +0,0 @@ | |||
| 1 | h1. Globalize2 | ||
| 2 | |||
| 3 | Globalize2 is the successor of Globalize for Rails. | ||
| 4 | |||
| 5 | It is compatible with and builds on the new "I18n api in Ruby on Rails":http://guides.rubyonrails.org/i18n.html. and adds model translations to ActiveRecord. | ||
| 6 | |||
| 7 | Globalize2 is much more lightweight and compatible than its predecessor was. Model translations in Globalize2 use default ActiveRecord features and do not limit any ActiveRecord functionality any more. | ||
| 8 | |||
| 9 | h2. Requirements | ||
| 10 | |||
| 11 | ActiveRecord | ||
| 12 | I18n | ||
| 13 | |||
| 14 | (or Rails > 2.2) | ||
| 15 | |||
| 16 | h2. Installation | ||
| 17 | |||
| 18 | To install Globalize2 with its default setup just use: | ||
| 19 | |||
| 20 | <pre><code> | ||
| 21 | script/plugin install git://github.com/joshmh/globalize2.git | ||
| 22 | </code></pre> | ||
| 23 | |||
| 24 | h2. Model translations | ||
| 25 | |||
| 26 | Model translations allow you to translate your models' attribute values. E.g. | ||
| 27 | |||
| 28 | <pre><code> | ||
| 29 | class Post < ActiveRecord::Base | ||
| 30 | translates :title, :text | ||
| 31 | end | ||
| 32 | </code></pre> | ||
| 33 | |||
| 34 | Allows you to values for the attributes :title and :text per locale: | ||
| 35 | |||
| 36 | <pre><code> | ||
| 37 | I18n.locale = :en | ||
| 38 | post.title # => Globalize2 rocks! | ||
| 39 | |||
| 40 | I18n.locale = :he | ||
| 41 | post.title # => גלובאלייז2 שולט! | ||
| 42 | </code></pre> | ||
| 43 | |||
| 44 | In order to make this work, you'll need to add the appropriate translation tables. Globalize2 comes with a handy helper method to help you do this. It's called @create_translation_table!@. Here's an example: | ||
| 45 | |||
| 46 | <pre><code> | ||
| 47 | class CreatePosts < ActiveRecord::Migration | ||
| 48 | def self.up | ||
| 49 | create_table :posts do |t| | ||
| 50 | t.timestamps | ||
| 51 | end | ||
| 52 | Post.create_translation_table! :title => :string, :text => :text | ||
| 53 | end | ||
| 54 | def self.down | ||
| 55 | drop_table :posts | ||
| 56 | Post.drop_translation_table! | ||
| 57 | end | ||
| 58 | end | ||
| 59 | </code></pre> | ||
| 60 | |||
| 61 | Note that the ActiveRecord model @Post@ must already exist and have a @translates@ directive listing the translated fields. | ||
| 62 | |||
| 63 | h2. Migration from Globalize | ||
| 64 | |||
| 65 | See this script by Tomasz Stachewicz: http://gist.github.com/120867 | ||
