heartcombo / simple_form

Forms made easy for Rails! It's tied to a simple DSL, with no opinion on markup.
http://blog.plataformatec.com.br/tag/simple_form
MIT License
8.21k stars 1.32k forks source link

Variables in l18n translation file? #561

Closed flynfish closed 12 years ago

flynfish commented 12 years ago

I was wondering if there is a way to pass a variable to a label? I have tried %{model} in the label string but that just prints out the string.

labels:
  my_model_name:
    field_name: "This doesn't work for %{model}"

Here is a SO question asking the same thing.

Thanks!

carlosantoniodasilva commented 12 years ago

Nope, unfortunately it's not possible, you'll have to call I18n by yourself:

f.input :foo, :label => t("labels.my_model_name.field_name", :model => "what you want here")

Or something like that (it'd be good to extract this to some other helper if you'll use in a lot of places).

As a side note, please try to use the mailing list for questions. Thanks!

flynfish commented 12 years ago

Ah my bad, I didn't see the mailing list. I will use that next time, thanks for the input!

carlosantoniodasilva commented 12 years ago

No problem :).. we just try to keep the issues tracker for issues / pull requests. Cheers!