0

I am facing a weird problem. In my rails 3 app I am supporting internationalization with english and french. Here in my template I wrote something like this

<%= t "Hi %{person}!", :person => "Simpson" %>

When I set locale as french everything works fine, since it has got translation for this but when I set locale as english then it gives output as

Hi %{person}!

in my browser. When I add translation to en.yml, it works fine. I don't understand why there is need to add translation in en.yml for this. Moreover I don't want this to happen, is there any work around for this?

Thanks

Paritosh Singh
  • 6,288
  • 5
  • 37
  • 56

1 Answers1

1

The first argument givent to the t method should be a key, so your view should have something like this :

<%= t :greetings, :person => "Simpson" %>

Your config/locales/en.yml would look like this :

en:
  greetings: Hi %{person}

and your config/locales/fr.yml something like this :

fr:
  greetings: Bonjour %{person}
tigrish
  • 2,488
  • 18
  • 21
  • I don't want any translation in en.yml, what should be done in that case. In your solution however I am adding translation. – Paritosh Singh Oct 18 '12 at 11:21
  • Well either the same response as http://stackoverflow.com/questions/12914019/rails-remove-missing-translation-errors/12930993#comment17524467_12930993 applies or you can just not I18n, like this : <%= "Hi #{person}" %> – tigrish Oct 18 '12 at 14:48