Skip to content

Commit

Permalink
Fix plural rules and other resources (do not merge :en locale data).
Browse files Browse the repository at this point in the history
  • Loading branch information
KL-7 committed Oct 10, 2014
1 parent a676c51 commit 8a65a5c
Show file tree
Hide file tree
Showing 314 changed files with 238 additions and 17,648 deletions.
18 changes: 16 additions & 2 deletions lib/twitter_cldr/data_readers/number_data_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class NumberDataReader < DataReader
DEFAULT_FORMAT = :default
DEFAULT_SIGN = :positive

REDIRECT_REGEX = /\Anumbers\.formats\.\w+\.patterns\.\w+\z/

attr_reader :type, :format

def self.types
Expand Down Expand Up @@ -70,7 +72,7 @@ def pattern(number = nil, decimal = true)
TYPE_PATHS[:default]
end

pattern = traverse(path)
pattern = get_pattern_data(path)

if pattern[format]
pattern = pattern[format]
Expand Down Expand Up @@ -109,6 +111,16 @@ def formatter

private

def get_pattern_data(path)
data = traverse(path)

if data.is_a?(Symbol) && data.to_s =~ REDIRECT_REGEX
get_pattern_data(data.to_s.split('.').map(&:to_sym))
else
data
end
end

def abbreviated?(type)
ABBREVIATED_TYPES.include?(type)
end
Expand All @@ -133,7 +145,9 @@ def pattern_for_number(pattern, number, decimal)
pattern_sample = range_pattern.values.first

if pattern_sample != 0
range_pattern.fetch(pluralization_rule(number, pattern_sample, decimal))
rule = pluralization_rule(number, pattern_sample, decimal)
# fall back to :other and raise an exception if it's missing as well
range_pattern.fetch(rule, range_pattern.fetch(:other))
else
0
end
Expand Down
3 changes: 0 additions & 3 deletions resources/locales/af/calendars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,6 @@
:am: "vm."
:noon: "middag"
:pm: "nm."
:variant:
:am: "am"
:pm: "pm"
:stand-alone: {}
:quarters:
:format:
Expand Down
Loading

0 comments on commit 8a65a5c

Please sign in to comment.