百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
G

globalize2

> 编程语言
开源

Globalize for Rails 的第二个版本

362 stars0 点赞3 次浏览
访问官网GitHub

工具介绍

Globalize for Rails 的第二个版本

h1. Globalize2

Globalize2 is the successor of Globalize for Rails.

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.

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.

h2. Requirements

ActiveRecord I18n

(or Rails > 2.2)

h2. Installation

To install Globalize2 with its default setup just use:

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

h2. Model translations

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

class Post 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 :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.

h2. Migration from Globalize

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

h2. Changes since Globalize2 v0.1.0

  • The association globalize_translations has been renamed to translations.

h2. Alternative Solutions

  • "Veger's fork":http://github.com/veger/globalize2 - uses default AR schema for the default locale, delegates to the translations table for other locales only
  • "TranslatableColumns":http://github.com/iain/translatable_columns - have multiple languages of the same attribute in a model (Iain Hecker)
  • "localized_record":http://github.com/glennpow/localized_record - allows records to have localized attributes without any modifications to the database (Glenn Powell)
  • "model_translations":http://github.com/janne/model_translations - Minimal implementation of Globalize2 style model translations (Jan Andersson)

h2. Related solutions

  • "globalize2_versioning":http://github.com/joshmh/globalize2_versioning - acts_as_versioned style versioning for Globalize2 (Joshua Harvey)

  • "i18n_multi_locales_validations":http://github.com/ZenCocoon/i18n_multi_locales_validations - multi-locales attributes validations to validates attributes from Globalize2 translations models (Sébastien Grosjean)

  • "Globalize2 Demo App":http://github.com/svenfuchs/globalize2-demo - demo application for Globalize2 (Sven Fuchs)

  • "migrate_from_globalize1":http://gist.github.com/120867 - migrate model translations from Globalize1 to Globalize2 (Tomasz Stachewicz)

  • "easy_globalize2_accessors":http://github.com/astropanic/easy_globalize2_accessors - easily access (read and write) globalize2-translated fields (astropanic, Tomasz Stachewicz)

  • "globalize2-easy-translate":http://github.com/bsamman/globalize2-easy-translate - adds methods to easily access or set translated attributes to your model (bsamman)

  • "batch_translations":http://github.com/alvarezrilla/batch_translations - allow saving multiple Globalize2 translations in the same request (Jose Alvarez Rilla)

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Ruby

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言