I18N Scope #80

Open
skarface opened this Issue Mar 3, 2012 · 7 comments

Comments

Projects
None yet
5 participants
@skarface

skarface commented Mar 3, 2012

It's really nice if can have i18N support, for now i try translate attributes in i18n file but it does not work.

@cgriego

This comment has been minimized.

Show comment Hide comment
@cgriego

cgriego Mar 6, 2012

Owner

@skarface What are you using for keys? ActiveAttr doesn't do anything for i18n but it does pull in ActiveModel modules that should provide full support.

Owner

cgriego commented Mar 6, 2012

@skarface What are you using for keys? ActiveAttr doesn't do anything for i18n but it does pull in ActiveModel modules that should provide full support.

@skarface

This comment has been minimized.

Show comment Hide comment
@skarface

skarface Mar 6, 2012

I use normal way, in my translate file i put:
activerecord:
attributes:
user:
name: "Nome"

I try do same with ActiveAttr but translation won't work.

skarface commented Mar 6, 2012

I use normal way, in my translate file i put:
activerecord:
attributes:
user:
name: "Nome"

I try do same with ActiveAttr but translation won't work.

@cgriego

This comment has been minimized.

Show comment Hide comment
@cgriego

cgriego Mar 6, 2012

Owner

Since ActiveAttr isn't doing anything for i18n, and only leaning on ActiveModel, you'll have to use "activemodel" as the key portion instead of "activerecord" or "activeattr".

I'll leave this issue open to consider whether we should declare our own i18n scope. It might be necessary when we create our own validators.

Owner

cgriego commented Mar 6, 2012

Since ActiveAttr isn't doing anything for i18n, and only leaning on ActiveModel, you'll have to use "activemodel" as the key portion instead of "activerecord" or "activeattr".

I'll leave this issue open to consider whether we should declare our own i18n scope. It might be necessary when we create our own validators.

@skarface

This comment has been minimized.

Show comment Hide comment
@skarface

skarface Apr 17, 2012

Work right with ActiveModel, many thanks.

Work right with ActiveModel, many thanks.

@phstc

This comment has been minimized.

Show comment Hide comment
@phstc

phstc May 23, 2012

Work right with ActiveModel, many thanks. (2)

@cgriego Would be great if you can add it in the README.

phstc commented May 23, 2012

Work right with ActiveModel, many thanks. (2)

@cgriego Would be great if you can add it in the README.

@phantomwhale

This comment has been minimized.

Show comment Hide comment
@phantomwhale

phantomwhale Aug 10, 2012

Just encountered this - I see that ActiveRecord overrides the #i18n_scope method to :activerecord, but ActiveModel by default declares it as :activemodel

For now, we're going with a Monkey Patch to BasicModel of:

  def self.i18n_scope
    "activerecord"
  end

Not sure if there is a more elegant way of integrating this into the gem - I can imagine the 80%+ of users would be using this within a Rails stack, and therefore needing this patch. Might be a little beyond my modest skills now, but I'll keep a few brain cells working on it.

Just encountered this - I see that ActiveRecord overrides the #i18n_scope method to :activerecord, but ActiveModel by default declares it as :activemodel

For now, we're going with a Monkey Patch to BasicModel of:

  def self.i18n_scope
    "activerecord"
  end

Not sure if there is a more elegant way of integrating this into the gem - I can imagine the 80%+ of users would be using this within a Rails stack, and therefore needing this patch. Might be a little beyond my modest skills now, but I'll keep a few brain cells working on it.

@borama

This comment has been minimized.

Show comment Hide comment
@borama

borama Dec 7, 2012

Another workaround: if you don't want to monkey patch, you can simply use an alias in the translation file:

cs:
  activerecord: &model_i18n
    attributes:
      user:
        name: 'Jméno'

  activemodel: *model_i18n    

Works OK, though I guess this might double the i18n keys in memory...

borama commented Dec 7, 2012

Another workaround: if you don't want to monkey patch, you can simply use an alias in the translation file:

cs:
  activerecord: &model_i18n
    attributes:
      user:
        name: 'Jméno'

  activemodel: *model_i18n    

Works OK, though I guess this might double the i18n keys in memory...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment