Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/cldr/export/data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module Data
autoload :Layout, "cldr/export/data/layout"
autoload :LikelySubtags, "cldr/export/data/likely_subtags"
autoload :Lists, "cldr/export/data/lists"
autoload :LocaleDisplayPattern, "cldr/export/data/locale_display_pattern"
autoload :Metazones, "cldr/export/data/metazones"
autoload :NumberingSystems, "cldr/export/data/numbering_systems"
autoload :Numbers, "cldr/export/data/numbers"
Expand Down
22 changes: 22 additions & 0 deletions lib/cldr/export/data/locale_display_pattern.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

module Cldr
module Export
module Data
class LocaleDisplayPattern < Base
def initialize(locale)
super
update(locale_display_pattern: locale_display_pattern)
end

private

def locale_display_pattern
@locale_display_pattern ||= select("localeDisplayNames/localeDisplayPattern/*").each_with_object({}) do |node, result|
result[node.name.underscore] = node.content
end
end
end
end
end
end
18 changes: 18 additions & 0 deletions test/export/data/locale_display_pattern_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# encoding: utf-8
# frozen_string_literal: true

require File.expand_path(File.join(File.dirname(__FILE__) + "/../../test_helper"))

class TestLocaleDisplayPattern < Test::Unit::TestCase
test "locale_display_pattern :de" do
expected = {
"locale_key_type_pattern" => "{0}: {1}",
"locale_pattern" => "{0} ({1})",
"locale_separator" => "{0}, {1}",
}

actual = Cldr::Export::Data::LocaleDisplayPattern.new(:de)[:locale_display_pattern]

assert_equal expected, actual
end
end
Loading