Skip to content

Commit 992db38

Browse files
committed
feat: export locale_display_pattern
1 parent 5c5b2c7 commit 992db38

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

lib/cldr/export/data.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ module Data
1919
autoload :Layout, "cldr/export/data/layout"
2020
autoload :LikelySubtags, "cldr/export/data/likely_subtags"
2121
autoload :Lists, "cldr/export/data/lists"
22+
autoload :LocaleDisplayPattern, "cldr/export/data/locale_display_pattern"
2223
autoload :Metazones, "cldr/export/data/metazones"
2324
autoload :NumberingSystems, "cldr/export/data/numbering_systems"
2425
autoload :Numbers, "cldr/export/data/numbers"
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# frozen_string_literal: true
2+
3+
module Cldr
4+
module Export
5+
module Data
6+
class LocaleDisplayPattern < Base
7+
def initialize(locale)
8+
super
9+
update(locale_display_pattern: locale_display_pattern)
10+
end
11+
12+
private
13+
14+
def locale_display_pattern
15+
@locale_display_pattern ||= select("localeDisplayNames/localeDisplayPattern/*").each_with_object({}) do |node, result|
16+
result[node.name.underscore] = node.content
17+
end
18+
end
19+
end
20+
end
21+
end
22+
end
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# encoding: utf-8
2+
# frozen_string_literal: true
3+
4+
require File.expand_path(File.join(File.dirname(__FILE__) + "/../../test_helper"))
5+
6+
class TestLocaleDisplayPattern < Test::Unit::TestCase
7+
test "locale_display_pattern :de" do
8+
expected = {
9+
"locale_key_type_pattern" => "{0}: {1}",
10+
"locale_pattern" => "{0} ({1})",
11+
"locale_separator" => "{0}, {1}",
12+
}
13+
14+
actual = Cldr::Export::Data::LocaleDisplayPattern.new(:de)[:locale_display_pattern]
15+
16+
assert_equal expected, actual
17+
end
18+
end

0 commit comments

Comments
 (0)