Skip to content

Commit

Permalink
Merge pull request #71 from movermeyer/mo.plurals_rb
Browse files Browse the repository at this point in the history
Only export `plurals.rb` for those that have plurals data
  • Loading branch information
Korri authored Oct 7, 2021
2 parents 0284112 + 2f47ad1 commit 4c62b6f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/cldr/export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def locale_based_data(component, locale, options = {})

def plural_data(component, locale, options = {})
data = locale_based_data(component, locale, options)
"{ :'#{locale}' => { :i18n => { :plural => { :keys => #{data[:keys].inspect}, :rule => #{data[:rule]} } } } }"
data.empty? ? "" : "{ :'#{locale}' => { :i18n => { :plural => { :keys => #{data[:keys].inspect}, :rule => #{data[:rule]} } } } }"
end

def shared_data(component, options = {})
Expand Down Expand Up @@ -145,7 +145,7 @@ def locales(locale, component, options)
end
end

ancestry
ancestry
else
[locale]
end
Expand Down
8 changes: 8 additions & 0 deletions test/export_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ def tmp_dir
assert_equal 'NaN', data[:numbers][:symbols][:nan]
end

test 'passing the merge option generates and merges Plurals data from fallback locales' do
data = Cldr::Export.data('Plurals', 'af-NA')
assert_equal "", data

data = Cldr::Export.data('Plurals', 'af-NA', :merge => true)
assert_match(/{ :'af-NA' => { :i18n => { :plural/, data)
end

test 'the merge option respects parentLocales' do
data = Cldr::Export.data('calendars', 'en-GB', :merge => true)
assert_equal 'dd/MM/y', data[:calendars][:gregorian][:additional_formats]['yMd']
Expand Down

0 comments on commit 4c62b6f

Please sign in to comment.