Sha256: ae170ded08dd4f655671379e7999845fb7309083b3d7dccee8e01be441b36c2a

Contents?: true

Size: 903 Bytes

Versions: 8

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/irregular'
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::Irregular.new(tag)
    end
    memoize :parse
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
locale-2.0.9 lib/locale/tag.rb
locale-2.0.8 lib/locale/tag.rb
locale-2.0.7 lib/locale/tag.rb
locale-2.0.6 lib/locale/tag.rb
locale-2.0.5 lib/locale/tag.rb
locale-2.0.4 lib/locale/tag.rb
locale-2.0.3 lib/locale/tag.rb
locale-2.0.2 lib/locale/tag.rb