# Globalize2 - virtual attributes to access field in a specific language directly

**URL:** <https://www.ruby-forum.com/t/globalize2-virtual-attributes-to-access-field-in-a-specific-language-directly/181583>\
**Category:** Rails I18n\
**Created:** [January 14, 2010, 5:09am UTC](https://www.ruby-forum.com/t/globalize2-virtual-attributes-to-access-field-in-a-specific-language-directly/181583 "2010-01-14T05:09:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hydrozen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/977dab/32.png) [@hydrozen](https://www.ruby-forum.com/u/hydrozen)\
**Post date:** [January 14, 2010, 5:09am UTC](https://www.ruby-forum.com/t/globalize2-virtual-attributes-to-access-field-in-a-specific-language-directly/181583/1 "2010-01-14T05:09:41Z")

</div>

Hi,

I just did a small extension to the translates method of globalize2 so  
that it defines a couple additional attributes to my model. For  
example, since my application supports french and english, when I do  
translates :title in my model, it generates the title method but also  
title\_en and title\_fr to access to access each language without  
manually switching I18n.locale back and forth.

I am just wondering if you guys think it can be a good idea. It seems  
to simplify the development of my forms IMHO. I could package it and  
release it into the wild…

---

<div class="post-metadata">

**Author:** ![hydrozen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/977dab/32.png) [@hydrozen](https://www.ruby-forum.com/u/hydrozen)\
**Post date:** [January 14, 2010, 9:38am UTC](https://www.ruby-forum.com/t/globalize2-virtual-attributes-to-access-field-in-a-specific-language-directly/181583/2 "2010-01-14T09:38:21Z")

</div>

On Thu, Jan 14, 2010 at 05:08, hydrozen [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> to simplify the development of my forms IMHO. I could package it and  
> release it into the wild…

Sounds very handy. Best way to release would probably be to fork  
globalize2 on GitHub: [GitHub - joshmh/globalize2: The second incarnation of Globalize for Rails](http://github.com/joshmh/globalize2/)

---

<div class="post-metadata">

**Author:** ![hydrozen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/977dab/32.png) [@hydrozen](https://www.ruby-forum.com/u/hydrozen)\
**Post date:** [January 17, 2010, 4:05pm UTC](https://www.ruby-forum.com/t/globalize2-virtual-attributes-to-access-field-in-a-specific-language-directly/181583/3 "2010-01-17T16:05:24Z")

</div>

On Jan 14, 2010, at 5:08 AM, hydrozen wrote:

> I just did a small extension to the translates method of globalize2 so  
> that it defines a couple additional attributes to my model. For  
> example, since my application supports french and english, when I do  
> translates :title in my model, it generates the title method but also  
> title\_en and title\_fr to access to access each language without  
> manually switching I18n.locale back and forth.
> 
> I am just wondering if you guys think it can be a good idea. It seems  
> to simplify the development of my forms IMHO. I could package it and  
> release it into the wild…

Sounds like something that already has been implemented twice:

[http://github.com/astropanic/easy\_globalize2\_accessors](http://github.com/astropanic/easy_globalize2_accessors)  
[http://github.com/bsamman/globalize2-easy-translate](http://github.com/bsamman/globalize2-easy-translate)

Are you one of the authors?
