I found it necessary to specify the currency format options for each locale, which I put in separate .yml files, but you can put all of them in one .yml file for testing.
Open the rails console and include the NumberHelper class
>> include ActionView::Helpers::NumberHelper
=> Object
>> number_to_currency(1234567890.506)
=> "$1,234,567,890.51"
>> number_to_currency(1234567890.506, :locale => :en)
=> "$1,234,567,890.51"
>> number_to_currency(1234567890.506, :locale => :en_gb)
=> "1,234,567,890.51 £"
>> number_to_currency(1234567890.506, :locale => :fr)
=> "1 234 567 890.51 €"
>> number_to_currency(1234567890.506, :locale => :br)
=> "R$ 1.234.567.890,51"
Locale yml File(s)
en:
hello: "Hello world"
hello-you: "Hello %{name}!"
inbox:
counting:
one: You have 1 new message
other: You have %{count} new messages
zero: You have no messages
greetings:
hello: "Hello"
hey: "Hey"
number:
currency:
format:
significant: !'false'
fr:
hello-you: "bonjour %{name}!"
number:
currency:
format:
format: "%n %u"
unit: "€"
delimiter: " "
en_gb:
number:
currency:
format:
format: "%n %u"
unit: "£"
br:
number:
currency:
format:
format: "%u %n"
unit: "R$ "
delimiter: "."
separator: ","
String Interpolation
You can build your I18N strings dynamically, assuming your .yml locale file is setup properly.
>> I18n.t("hello-you", {name: "John Doe"})
=> "Hello John Doe!"
>> I18n.t("inbox.counting", {count: 10})
=> "You have 10 new messages"
>> I18n.t(["greetings", "hello"])
=> [{:hello=>"Hello", :hey=>"Hey"}, "Hello world"]
>> I18n.t("hello-you", {locale: :fr, name: "John Doe"})
=> "bonjour John Doe!"
References
http://webdesign.about.com/od/localization/l/blhtmlcodes-cur.htmhttps://github.com/fnando/i18n-js
https://github.com/jquery/globalize
Nice Articles!
ReplyDeleteGreat moments of this articles!
Im surprised! Keep posting dude!
Read More:
* Download Film Minions 3 (Subtitle Indonesia) 2015
* Download Yakuza Apocalypse Subtitle Indo (2015)
* Download Film Terminator Genisys 2015 (Subtitle Indonesia)
* Download Film Insidious: Chapter 3 2015 (Subtitle Indonesia)
* Download Inside Out 2015 (Subtitle Indonesia) HD-RAY
* Download Jurassic World 2015 (Subtitle Indonesia)
* Film Korea Romantis Populer 2015
Ecommerce is a great way to promote customised products. Visit if you're looking for the best eCommerce App development company in the US.
ReplyDeleteHelllo mate great blog post
ReplyDelete