Sha256: 1f22ea27ab273710c0e3ce16bf1f99ac9cea521f7f7392c15b4196a912cc9fa6

Contents?: true

Size: 903 Bytes

Versions: 1

Compression:

Stored size: 903 Bytes

Contents

=begin
  tag.rb - Locale::Tag module

  Copyright (C) 2008,2009  Masao Mutoh
 
  You may redistribute it and/or modify it under the same
  license terms as Ruby.
=end

require 'locale/tag/simple'
require 'locale/tag/illegular'
require 'locale/tag/common'
require 'locale/tag/rfc'
require 'locale/tag/cldr'
require 'locale/tag/posix'
require 'locale/util/memoizable'

module Locale

  # Language tag / locale identifiers.
  module Tag
    include Util::Memoizable
    module_function
    # Parse a language tag/locale name and return Locale::Tag
    # object.
    # * tag: a tag as a String. e.g.) ja-Hira-JP
    # * Returns: a Locale::Tag subclass.
    def parse(tag)
      # Common is not used here.
      [Simple, Common, Rfc, Cldr, Posix].each do |parser|
        ret = parser.parse(tag)
        return ret if ret
      end
      Locale::Tag::Illegular.new(tag)
    end
    memoize :parse
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
locale-2.0.1 lib/locale/tag.rb