-
Notifications
You must be signed in to change notification settings - Fork 17
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
Export currency names #51
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,12 @@ class TestCldrCurrencies < Test::Unit::TestCase | |
currencies = Cldr::Export::Data::Currencies.new('de')[:currencies] | ||
assert_empty codes - currencies.keys, "Unexpected missing currencies" | ||
assert_empty currencies.keys - codes, "Unexpected extra currencies" | ||
assert_equal({ :one => 'Euro', :other => 'Euro', :symbol => '€' }, currencies[:EUR]) | ||
assert_equal({ :name => 'Euro', :one => 'Euro', :other => 'Euro', :symbol => '€' }, currencies[:EUR]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should assert a locale/currency whose values differ such as en/CAD. test 'currencies :en' do
codes = [:ADP, :AED, :AFA, :AFN, :ALL, :AMD, :ANG, :AOA, :AOK, :AON, :AOR,
:ARA, :ARP, :ARS, :ATS, :AUD, :AWG, :AZM, :AZN, :BAD, :BAM, :BBD,
:BDT, :BEC, :BEF, :BEL, :BGL, :BGN, :BHD, :BIF, :BMD, :BND, :BOB,
:BOP, :BOV, :BRB, :BRC, :BRE, :BRL, :BRN, :BRR, :BRZ, :BSD, :BTN,
:BUK, :BWP, :BYB, :BYR, :BZD, :CAD, :CDF, :CHE, :CHF, :CHW, :CLF,
:CLP, :CNY, :COP, :CRC, :CSD, :CSK, :CUC, :CUP, :CVE, :CYP, :CZK,
:DDM, :DEM, :DJF, :DKK, :DOP, :DZD, :ECS, :ECV, :EEK, :EGP, :ERN,
:ESA, :ESB, :ESP, :ETB, :EUR, :FIM, :FJD, :FKP, :FRF, :GBP, :GEK,
:GEL, :GHC, :GHS, :GIP, :GMD, :GNF, :GNS, :GQE, :GRD, :GTQ, :GWE,
:GWP, :GYD, :HKD, :HNL, :HRD, :HRK, :HTG, :HUF, :IDR, :IEP, :ILP,
:ILS, :INR, :IQD, :IRR, :ISK, :ITL, :JMD, :JOD, :JPY, :KES, :KGS,
:KHR, :KMF, :KPW, :KRW, :KWD, :KYD, :KZT, :LAK, :LBP, :LKR, :LRD,
:LSL, :LTL, :LTT, :LUC, :LUF, :LUL, :LVL, :LVR, :LYD, :MAD, :MAF,
:MDL, :MGA, :MGF, :MKD, :MLF, :MMK, :MNT, :MOP, :MRO, :MTL, :MTP,
:MUR, :MVR, :MWK, :MXN, :MXP, :MXV, :MYR, :MZE, :MZM, :MZN, :NAD,
:NGN, :NIC, :NIO, :NLG, :NOK, :NPR, :NZD, :OMR, :PAB, :PEI, :PEN,
:PES, :PGK, :PHP, :PKR, :PLN, :PLZ, :PTE, :PYG, :QAR, :RHD, :ROL,
:RON, :RSD, :RUB, :RUR, :RWF, :SAR, :SBD, :SCR, :SDD, :SDG, :SDP,
:SEK, :SGD, :SHP, :SIT, :SKK, :SLL, :SOS, :SRD, :SRG, :SSP, :STD,
:SUR, :SVC, :SYP, :SZL, :THB, :TJR, :TJS, :TMM, :TMT, :TND, :TOP,
:TPE, :TRL, :TRY, :TTD, :TWD, :TZS, :UAH, :UAK, :UGS, :UGX, :USD,
:USN, :USS, :UYP, :UYU, :UZS, :VEB, :VEF, :VND, :VUV, :WST, :XAF,
:XAG, :XAU, :XBA, :XBB, :XBC, :XBD, :XCD, :XDR, :XEU, :XFO, :XFU,
:XOF, :XPD, :XPF, :XPT, :XRE, :XTS, :XXX, :YDD, :YER, :YUD, :YUM,
:YUN, :ZAL, :ZAR, :ZMK, :ZMW, :ZRN, :ZRZ, :ZWD, :ZWL, :ZWR, :ALK,
:ARL, :ARM, :BAN, :BGM, :BGO, :BOL, :CLE, :CNX, :COU, :ILR, :ISJ,
:KRH, :KRO, :MCF, :MDC, :MKN, :MVP, :UYI, :VNN, :XSU, :XUA, :YUR,
:BYN, :CNH, :MRU, :STN, :VES, :UYW]
currencies = Cldr::Export::Data::Currencies.new('en')[:currencies]
assert_empty codes - currencies.keys, "Unexpected missing currencies"
assert_empty currencies.keys - codes, "Unexpected extra currencies"
# Note, for some reason, the currency symbol is missing for en.
assert_equal({ :name => 'Canadian Dollar', :one => 'Canadian dollar', :other => 'Canadian dollars' }, currencies[:CAD])
end There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've generally treated the CLDR data as "correct" in the sense that there's not too much we as downstream consumers can do if it's wrong. Moreover, I'm fairly sure currencies get added and removed on a semi-frequent basis, so I'm not sure what value a test like this would bring us considering it would break whenever a currency like the South Sudanese pound is added. |
||
end | ||
|
||
test 'currencies uses the label to populate :one when count is unavailable' do | ||
currencies = Cldr::Export::Data::Currencies.new('ak')[:currencies] | ||
assert_equal({ :name => 'Yuan', :one => 'Yuan' }, currencies[:CNY]) | ||
end | ||
|
||
# Cldr::Export::Data.locales.each do |locale| | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@froyomuffin Why is
one
special cased here?This adds a
one
key for languages that don't have aone
pluralization rule (e.g.,zh
), slightly bloating the data files)This is missing all of the other pluralization keys that might be needed in the locale.
My guess without context is that this was done to give a "reasonable" default for the currency in cases where CLDR doesn't have pluralization translation information for the currency.
IMO, in some sense this is fabricating information that isn't in the upstream CLDR dataset.
Unless
ruby-cldr
's mission is to augment CLDR with its own, I feel that this logic belongs downstream ofruby-cldr
in the consumer's code.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see that you were just maintaining this existing behaviour (which is present all the way back to at least:
ruby-cldr/lib/cldr/data/currencies.rb
Line 17 in 6664464
2009-12-30 (!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for late reply. I honestly do not remember >.<