github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

joshmh / globalize2

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 329
    • 43
  • Source
  • Commits
  • Network (43)
  • Issues (17)
  • Downloads (3)
  • Wiki (10)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (3)
    • v0.1.1
    • v0.1.0
    • 0.1.0_PR1
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

The second incarnation of Globalize for Rails — Read more

  cancel

http://www.globalize-rails.org/

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

added &block as 3rd method argument to make sure it doesn't raise another 
argument error if a block is supplied 
hukl (author)
Mon Jan 11 03:26:07 -0800 2010
commit  ffd2739d9cc85cffc607597f33b05fe12e9df23c
tree    426452c36e970a433ed28685c12364eb9708bac5
parent  7672e7e001f3d3bc0c558b53392f37dd148ef974
globalize2 /
name age
history
message
file .gitignore Sat Dec 26 07:24:51 -0800 2009 add .DS_Store to gitignore [svenfuchs]
file LICENSE Tue May 26 01:41:12 -0700 2009 added MIT license [joshmh]
file README.textile Sat Dec 26 07:39:07 -0800 2009 reference Tomasz Stachewicz' migration script (... [svenfuchs]
file Rakefile Sun Nov 08 05:24:11 -0800 2009 prepare gemcutter release [svenfuchs]
file VERSION Sat Dec 26 07:25:25 -0800 2009 bump to 0.2.0 [svenfuchs]
directory generators/ Sat Dec 26 07:24:51 -0800 2009 Big refactoring towards version 0.2.0. Strippin... [svenfuchs]
file globalize2.gemspec Sat Dec 26 07:25:25 -0800 2009 bump to 0.2.0 [svenfuchs]
file init.rb Sat Dec 26 07:25:25 -0800 2009 remove bogus include from init.rb [svenfuchs]
directory lib/ Mon Jan 11 03:28:56 -0800 2010 added &block as 3rd method argument to make sur... [hukl]
directory test/ Mon Jan 11 03:28:44 -0800 2010 fixes http://github.com/joshmh/globalize2/issue... [hukl]
README.textile

Globalize2

Globalize2 is the successor of Globalize for Rails.

It is compatible with and builds on the new I18n api in Ruby on Rails. and adds model translations to ActiveRecord.

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.

Requirements

ActiveRecord
I18n

(or Rails > 2.2)

Installation

To install Globalize2 with its default setup just use:


script/plugin install git://github.com/joshmh/globalize2.git

Model translations

Model translations allow you to translate your models’ attribute values. E.g.


class Post < ActiveRecord::Base
  translates :title, :text
end

Allows you to values for the attributes :title and :text per locale:


I18n.locale = :en
post.title # => Globalize2 rocks!

I18n.locale = :he
post.title # => גלובאלייז2 שולט!

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:


class CreatePosts < ActiveRecord::Migration
  def self.up
    create_table :posts do |t|
      t.timestamps
    end
    Post.create_translation_table! :title => :string, :text => :text
  end
  def self.down
    drop_table :posts
    Post.drop_translation_table!
  end
end

Note that the ActiveRecord model Post must already exist and have a translates directive listing the translated fields.

Migration from Globalize

See this script by Tomasz Stachewicz: http://gist.github.com/120867

Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server