Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

label and I18n #53

Open
aklein-dex opened this issue Jul 5, 2012 · 1 comment
Open

label and I18n #53

aklein-dex opened this issue Jul 5, 2012 · 1 comment

Comments

@aklein-dex
Copy link

Here is my code in my model :

    enum_attr :currency, %w(en ja), :init => I18n.locale do 
      label :en => I18n.t(:dollar)
      label :ja => I18n.t(:yen)
    end

My locale files :

    en:
      dollar : "$"
      yen : "¥"
    ja:
       dollar: "$"
       yen : "円"

This works as expected on my development environment, but on my staging (and production) environment, the labels are strange!
In my page I print out I18n.locale and I18n.default_locale, and both are "ja" as expected.
But the labels are:
<option value="en">translation missing: en.dollar</option>
<option selected="selected" value="ja">translation missing: en.yen</option>

Why it is looking for "en" despite that I18n.locale = "ja" ?
Even why it cannot find "en.dollar" despite that it exists in my locale file ?

@aklein-dex
Copy link
Author

let's say I'm doing this :

label :en => "#{I18n.locale}"

The result is :

<option selected="selected" value="en">en</option>

Why the label is "en" ? In my config/environments/staging.rb :

 config.i18n.default_locale = :ja
 config.i18n.locale = :ja

It looks like the labels are initialized before the I18n is set to "ja" !

It would be nice, if we could do something like:

e.select_options( :locale => true)

and

<%= f.enum_select :currency, :locale => true %>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant