def subpatterns_from(locale)
      parts = locale.to_s.split('-')
      parts.map.with_index { |part,index| parts[0..index].join('-') }
    end
def subpatterns_from(locale)
      parts = locale.to_s.split('-')
      parts.map.with_index { |part,index| parts[0..index].join('-') }
    end
Generates subpatterns for the specified locale (i.e. IETF language tag).
 Subpatterns are all more generic variations of a locale.
 E.g. subpatterns for en-US are en-US and en. Subpatterns for az-Latn-IR are az-Latn-IR, az-Latn and az