Skip to content

Commit

Permalink
Load all default fallbacks for a specific locale, by including all pr…
Browse files Browse the repository at this point in the history
…efix subpatterns.
  • Loading branch information
michieldewit committed Mar 20, 2015
1 parent 4de2f0b commit d9f6ad3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/i18n_country_translations/railtie.rb
Expand Up @@ -19,7 +19,13 @@ def self.add(pattern)

def self.pattern_from(args)
array = Array(args || [])
array = array.map { |locale| subpatterns_from locale }.flatten
array.blank? ? '*' : "{#{array.join ','}}"
end

def self.subpatterns_from(locale)
parts = locale.to_s.split('-')
parts.map.with_index { |part,index| parts[0..index].join('-') }
end
end
end

0 comments on commit d9f6ad3

Please sign in to comment.