Reputation: 663
I'm getting some string into my database from an external API and I want to translate them before showing users. I don't want to translate each object by globalize3 because content that I want to translate has some format.
For example I need to change all information values with date:
"Game postponed from 22.08.2013" -> date changes but string is same.
I tried using string as key and it works if I dont have variable:
config/locale/tr.yml file
tr:
Hello World: "Merhaba Dunya"
rails console
I18n.t("Hello World")
=> "Merhaba Dunya"
How can i use my string with variable as key and get translated one?
I want to define this:
tr:
"Game postponed from %{date}" => "Mac %{date} tarihinden ertelendi"
and I want to use it by:
I18n.t("Game postponed from 22.08.2013")
=> "Mac 22.08.2013 tarihinden ertelendi"
Using I18n may not be best solution to my case but I don't know how can I solve this.
Upvotes: 2
Views: 2855
Reputation: 9185
Here is a working version with an example:
> I18n.transliterate("arrêter".downcase.strip)
=> "arreter"
Upvotes: 0
Reputation: 4367
In your config/locale/tr.yml
'Game postponed from': 'Game postponed from %{date}'
Console:
I18n.t 'Game postponed from', :date => some_date
Upvotes: 1