-
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
Conversation
@camertron I pushed the branch directly to this repo by mistake. Would you prefer I create a fork and restart there? |
dfaa818
to
fc902b6
Compare
fc902b6
to
3e8c8d7
Compare
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.
First time looking at this repo but changes look reasonable. One test comment.
@@ -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 comment
The 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 comment
The 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.
@froyomuffin nah that's fine :) Prob won't be able to look at this PR until next week tho, is that cool? |
@camertron Yuppers :) |
👋 Any chance we can get this merged soon? |
Published this in v0.3.0 of the gem (along with a few other things). |
count = node.attribute('count').value.to_sym | ||
result[count] = node.content | ||
else | ||
result[:one] = node.content if result[:one].nil? |
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.
I18n.with_locale(:af) do I18n.t("currencies.LVL", count: 0) end
I18n::InvalidPluralizationData: translation data {:one=>"Lettiese lats", :name=>"Lettiese lats", :symbol=>"LVL"} can not be used with :count => 0. key 'other' is missing.
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 of ruby-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
count = node.attribute('count') ? node.attribute('count').value.to_sym : :one |
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 >.<
Presently, we're not exporting the currency labels from CLDR data
Essentially, we have two use cases for this data:
The capitalization is different in both cases.
The currently export implementation simply exports data as
:one
and then overrides it with the actual:one
. This PR just exports the data under:name
.I also added a test to check the case where we only have a 'displayName' node that we use that node's data to populate
:one
.