ruby-cldr 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ac65fa730274ef7d70f6dde1a20a4a6ed4a36f1407d65e12ba220539d6a0424
4
- data.tar.gz: 900156546c3603e66501d527714a8b9ac3c66287ebde5672f699da68d5cbbfc8
3
+ metadata.gz: d2730108a5324c951320fd218ac7c4be0bbfb0f98fd0640c40ac45cd3c9c1bc8
4
+ data.tar.gz: f3f218f3e52903be3bc9f7e46d1a9406e995a03fbc56c413dadf47b668799215
5
5
  SHA512:
6
- metadata.gz: '0589799c818cf86570883c73bcb095889496bc158026d51557829ba3c9eda8f13c1879823689c1263eee20931b77bd0a01de4e6680cfb5064ccb807a36fb0e69'
7
- data.tar.gz: 642f18b73738a815314e6c0ee39ceac70c0f5d26c89027f4936f9089b577943481a8422980674bf725dd6243cce449af96d13ba5567f499564b9f42420ab40f2
6
+ metadata.gz: c9928d8c1f33e5c8e651492cf8b801e6fd642e6a4c1913268f8ac976dbe4185e23d4e1e7662c0a3e81ab7eabbbc603bd1cf9db727d6e278fe18e5119faeb58e5
7
+ data.tar.gz: c2a868e0af577e0fe61550daa773f8a13ee2cb92f71307ac761eb7b1b2ba0eea626423d811897c5de00cd16b19532693544bf4f35e797971ca8b156a8cd8ba60
data/CHANGELOG.md ADDED
@@ -0,0 +1,44 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
5
+
6
+ ## How do I make a good changelog?
7
+ ### Guiding Principles
8
+ - Changelogs are for humans, not machines.
9
+ - There should be an entry for every single version.
10
+ - The same types of changes should be grouped.
11
+ - Versions and sections should be linkable.
12
+ - The latest version comes first.
13
+ - The release date of each version is displayed.
14
+ - Mention whether you follow Semantic Versioning.
15
+
16
+ ### Types of changes
17
+ - Added for new features.
18
+ - Changed for changes in existing functionality.
19
+ - Deprecated for soon-to-be removed features.
20
+ - Removed for now removed features.
21
+ - Fixed for any bug fixes.
22
+ - Security in case of vulnerabilities.
23
+
24
+ ## [Unreleased]
25
+
26
+ - Added a changelog, [#49](https://github.com/ruby-i18n/ruby-cldr/pull/49)
27
+ - Added Travis CI for testing, [#48](https://github.com/ruby-i18n/ruby-cldr/pull/48)
28
+ - Added root fallback to en language, [#47](https://github.com/ruby-i18n/ruby-cldr/pull/47)
29
+ - Added subdivisions to the list of exportable components, [#46](https://github.com/ruby-i18n/ruby-cldr/pull/46)
30
+
31
+ ---
32
+
33
+ ## [0.2.0] - 2019-03-26
34
+
35
+ - Updated to CLDR 34 [#43](https://github.com/ruby-i18n/ruby-cldr/pull/43)
36
+ - Lots of [other changes](https://github.com/ruby-i18n/ruby-cldr/compare/v0.1.1...v0.2.0)
37
+
38
+ ## [0.3.0] - 2019-06-16
39
+
40
+ - Export currency names [#51](https://github.com/ruby-i18n/ruby-cldr/pull/51)
41
+ - Bring back root fallback for english [#47](https://github.com/ruby-i18n/ruby-cldr/pull/47)
42
+ - Export subdivisions [#46](https://github.com/ruby-i18n/ruby-cldr/pull/46)
43
+
44
+ [Unreleased]: https://github.com/ruby-i18n/ruby-cldr/compare/v0.3.0...HEAD
data/Gemfile.lock CHANGED
@@ -68,6 +68,7 @@ GEM
68
68
 
69
69
  PLATFORMS
70
70
  ruby
71
+ x86_64-darwin-17
71
72
 
72
73
  DEPENDENCIES
73
74
  i18n
@@ -80,4 +81,4 @@ DEPENDENCIES
80
81
  thor
81
82
 
82
83
  BUNDLED WITH
83
- 2.0.1
84
+ 2.0.2
data/README.textile CHANGED
@@ -1,5 +1,7 @@
1
1
  h1. Ruby library for exporting and using data from CLDR
2
2
 
3
+ !https://travis-ci.com/ruby-i18n/ruby-cldr.svg?branch=master!:https://travis-ci.com/ruby-i18n/ruby-cldr
4
+
3
5
  CLDR ("Common Locale Data Repository":http://cldr.unicode.org) contains tons of high-quality locale data such as formatting rules for dates, times, numbers, currencies as well as language, country, calendar-specific names etc.
4
6
 
5
7
  For localizing applications in Ruby we'll obviously be able to use this incredibly comprehensive and well-maintained resource.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.3.0
data/lib/cldr/export.rb CHANGED
@@ -144,12 +144,12 @@ module Cldr
144
144
  end
145
145
  end
146
146
 
147
- ancestry << :root if component_should_merge_root?(component)
148
147
  ancestry
149
148
  else
150
149
  [locale]
151
150
  end
152
151
 
152
+ locales << :root if should_merge_root?(locale, component, options)
153
153
  locales
154
154
  end
155
155
 
@@ -170,8 +170,10 @@ module Cldr
170
170
  SHARED_COMPONENTS.include?(component)
171
171
  end
172
172
 
173
- def component_should_merge_root?(component)
174
- !%w(Rbnf Fields).include?(component)
173
+ def should_merge_root?(locale, component, options)
174
+ return false if %w(Rbnf Fields).include?(component)
175
+ return true if options[:merge]
176
+ locale == :en
175
177
  end
176
178
  end
177
179
  end
@@ -25,6 +25,7 @@ module Cldr
25
25
  autoload :RbnfRoot, 'cldr/export/data/rbnf_root'
26
26
  autoload :RegionCurrencies, 'cldr/export/data/region_currencies'
27
27
  autoload :SegmentsRoot, 'cldr/export/data/segments_root'
28
+ autoload :Subdivisions, 'cldr/export/data/subdivisions'
28
29
  autoload :Territories, 'cldr/export/data/territories'
29
30
  autoload :TerritoriesContainment, 'cldr/export/data/territories_containment'
30
31
  autoload :Timezones, 'cldr/export/data/timezones'
@@ -47,7 +48,7 @@ module Cldr
47
48
  end
48
49
 
49
50
  def components
50
- self.constants.sort - [:Base, :Export]
51
+ self.constants.sort - [:Base, :Export, :ParentLocales]
51
52
  end
52
53
  end
53
54
  end
@@ -17,8 +17,16 @@ module Cldr
17
17
 
18
18
  def currency(node)
19
19
  data = select(node, 'displayName').inject({}) do |result, node|
20
- count = node.attribute('count') ? node.attribute('count').value.to_sym : :one
21
- result[count] = node.content unless draft?(node)
20
+ unless draft?(node)
21
+ if node.attribute('count')
22
+ count = node.attribute('count').value.to_sym
23
+ result[count] = node.content
24
+ else
25
+ result[:one] = node.content if result[:one].nil?
26
+ result[:name] = node.content
27
+ end
28
+ end
29
+
22
30
  result
23
31
  end
24
32
 
@@ -30,4 +38,4 @@ module Cldr
30
38
  end
31
39
  end
32
40
  end
33
- end
41
+ end
@@ -4,7 +4,7 @@ module Cldr
4
4
  module Export
5
5
  module Data
6
6
  class ParentLocales < Hash
7
- def initialize(_)
7
+ def initialize(_ = nil)
8
8
  path = File.join(Cldr::Export::Data.dir, 'supplemental', 'supplementalData.xml')
9
9
  doc = File.open(path) { |file| Nokogiri::XML(file) }
10
10
 
@@ -0,0 +1,35 @@
1
+ module Cldr
2
+ module Export
3
+ module Data
4
+ class Subdivisions < Base
5
+
6
+ def initialize(locale)
7
+ super
8
+ update(:subdivisions => subdivisions)
9
+ end
10
+
11
+ private
12
+
13
+ def subdivisions
14
+ @subdivisions ||= select('localeDisplayNames/subdivisions/subdivision').inject({}) do |result, node|
15
+ result[node.attribute('type').value.to_sym] = node.content unless draft?(node) or alt?(node)
16
+ result
17
+ end
18
+ end
19
+
20
+ def doc
21
+ begin
22
+ super
23
+ rescue Errno::ENOENT
24
+ @doc = Nokogiri::XML('')
25
+ end
26
+ end
27
+
28
+ def path
29
+ @path ||= "#{Cldr::Export::Data.dir}/subdivisions/#{locale.to_s.gsub('-', '_')}.xml"
30
+ end
31
+
32
+ end
33
+ end
34
+ end
35
+ end
@@ -20,11 +20,27 @@ class TestCldrDataCalendars < Test::Unit::TestCase
20
20
  :abbreviated => { 1 => 'Jan', 2 => 'Feb', 3 => 'Mär', 4 => 'Apr', 5 => 'Mai', 6 => 'Jun', 7 => 'Jul', 8 => 'Aug', 9 => 'Sep', 10 => 'Okt', 11 => 'Nov', 12 => 'Dez' },
21
21
  :narrow => { 1 => 'J', 2 => 'F', 3 => 'M', 4 => 'A', 5 => 'M', 6 => 'J', 7 => 'J', 8 => 'A', 9 => 'S', 10 => 'O', 11 => 'N', 12 => 'D' },
22
22
  :wide => { 1 => 'Januar', 2 => 'Februar', 3 => 'März', 4 => 'April', 5 => 'Mai', 6 => 'Juni', 7 => 'Juli', 8 => 'August', 9 => 'September', 10 => 'Oktober', 11 => 'November', 12 => 'Dezember' },
23
- }
23
+ },
24
24
  }
25
25
  assert_equal months, gregorian[:months]
26
26
  end
27
27
 
28
+ test 'calendars months :en' do
29
+ months = {
30
+ :format => {
31
+ :abbreviated => { 1 => "Jan", 2 => "Feb", 3 => "Mar", 4 => "Apr", 5 => "May", 6 => "Jun", 7 => "Jul", 8 => "Aug", 9 => "Sep", 10 => "Oct", 11 => "Nov", 12 => "Dec" },
32
+ :narrow => :"calendars.gregorian.months.stand-alone.narrow",
33
+ :wide => { 1 => "January", 2 => "February", 3 => "March", 4 => "April", 5 => "May", 6 => "June", 7 => "July", 8 => "August", 9 => "September", 10 => "October", 11 => "November", 12 => "December" },
34
+ },
35
+ :"stand-alone" => {
36
+ :abbreviated => :"calendars.gregorian.months.format.abbreviated",
37
+ :narrow => { 1 => "J", 2 => "F", 3 => "M", 4 => "A", 5 => "M", 6 => "J", 7 => "J", 8 => "A", 9 => "S", 10 => "O", 11 => "N", 12 => "D" },
38
+ :wide => :"calendars.gregorian.months.format.wide",
39
+ },
40
+ }
41
+ assert_equal months, gregorian(locale: :en)[:months]
42
+ end
43
+
28
44
  test 'calendars days :de' do
29
45
  days = {
30
46
  :format => {
@@ -36,7 +36,12 @@ class TestCldrCurrencies < Test::Unit::TestCase
36
36
  currencies = Cldr::Export::Data::Currencies.new('de')[:currencies]
37
37
  assert_empty codes - currencies.keys, "Unexpected missing currencies"
38
38
  assert_empty currencies.keys - codes, "Unexpected extra currencies"
39
- assert_equal({ :one => 'Euro', :other => 'Euro', :symbol => '€' }, currencies[:EUR])
39
+ assert_equal({ :name => 'Euro', :one => 'Euro', :other => 'Euro', :symbol => '€' }, currencies[:EUR])
40
+ end
41
+
42
+ test 'currencies uses the label to populate :one when count is unavailable' do
43
+ currencies = Cldr::Export::Data::Currencies.new('ak')[:currencies]
44
+ assert_equal({ :name => 'Yuan', :one => 'Yuan' }, currencies[:CNY])
40
45
  end
41
46
 
42
47
  # Cldr::Export::Data.locales.each do |locale|
@@ -18,7 +18,7 @@ class TestCldrDataLanguages < Test::Unit::TestCase
18
18
  :csb, :cu, :cv, :cy, :da, :dak, :dar, :dav, :de, :"de-AT",
19
19
  :"de-CH", :del, :den, :dgr, :din, :dje, :doi, :dsb, :dtp,
20
20
  :dua, :dum, :dv, :dyo, :dyu, :dz, :dzg, :ebu, :ee, :efi,
21
- :egl, :egy, :eka, :el, :elx, :en, :"en-GB", :"en-US", :enm,
21
+ :egl, :egy, :eka, :el, :elx, :en, :enm,
22
22
  :eo, :es, :esu, :et, :eu, :ewo, :ext, :fa, :fan, :fat, :ff,
23
23
  :fi, :fil, :fit, :fj, :fo, :fon, :fr, :frc, :frm, :fro,
24
24
  :frp, :frr, :frs, :fur, :fy, :ga, :gaa, :gag, :gan, :gay,
@@ -0,0 +1,33 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__) + '/../../test_helper'))
4
+
5
+ class TestCldrDataSubdivisions < Test::Unit::TestCase
6
+ test 'subdivisions for Canada/Quebec in :ja' do
7
+ subdivisions = Cldr::Export::Data::Subdivisions.new(:ja)[:subdivisions]
8
+
9
+ assert_equal('ケベック州', subdivisions[:caqc])
10
+ end
11
+
12
+ test 'subdivisions for a non an unsupported locale :zz' do
13
+ subdivisions = Cldr::Export::Data::Subdivisions.new(:zz)
14
+
15
+ assert_empty(subdivisions)
16
+ end
17
+
18
+ test 'subdivisions locales are a subset of main locales' do
19
+ root = File.expand_path('./vendor/cldr/common')
20
+
21
+ main_locales = Dir["#{root}/main/*.xml"].map { |path| path =~ /([\w_-]+)\.xml/ && $1 }
22
+ subdivisions_locales = Dir["#{root}/subdivisions/*.xml"].map { |path| path =~ /([\w_-]+)\.xml/ && $1 }
23
+
24
+ assert_empty(subdivisions_locales - main_locales)
25
+ end
26
+
27
+ #
28
+ # test "extract subdivisions for #{locale}" do
29
+ # assert_nothing_raised do
30
+ # Cldr::Export::Data::Subdivisions.new(locale)
31
+ # end
32
+ # end
33
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-cldr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sven Fuchs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-21 00:00:00.000000000 Z
11
+ date: 2019-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -131,6 +131,7 @@ extra_rdoc_files:
131
131
  - README.textile
132
132
  - TODO
133
133
  files:
134
+ - CHANGELOG.md
134
135
  - Gemfile
135
136
  - Gemfile.lock
136
137
  - LICENSE
@@ -172,6 +173,7 @@ files:
172
173
  - lib/cldr/export/data/rbnf_root.rb
173
174
  - lib/cldr/export/data/region_currencies.rb
174
175
  - lib/cldr/export/data/segments_root.rb
176
+ - lib/cldr/export/data/subdivisions.rb
175
177
  - lib/cldr/export/data/territories.rb
176
178
  - lib/cldr/export/data/territories_containment.rb
177
179
  - lib/cldr/export/data/timezones.rb
@@ -209,6 +211,7 @@ files:
209
211
  - test/export/data/metazones_test.rb
210
212
  - test/export/data/numbers_test.rb
211
213
  - test/export/data/plurals_test.rb
214
+ - test/export/data/subdivisions_test.rb
212
215
  - test/export/data/territories_containment_test.rb
213
216
  - test/export/data/territories_test.rb
214
217
  - test/export/data/timezones_test.rb
@@ -245,8 +248,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
245
248
  - !ruby/object:Gem::Version
246
249
  version: '0'
247
250
  requirements: []
248
- rubyforge_project:
249
- rubygems_version: 2.7.9
251
+ rubygems_version: 3.0.4
250
252
  signing_key:
251
253
  specification_version: 4
252
254
  summary: Ruby library for exporting and using data from CLDR