Sha256: 82846ba04711cc8a028439c9111f5ca017d53b8ab86aea76b7c61648b6b24a9e
Contents?: true
Size: 1.91 KB
Versions: 1
Compression:
Stored size: 1.91 KB
Contents
# encoding: UTF-8 # Copyright 2012 Twitter, Inc # http://www.apache.org/licenses/LICENSE-2.0 $:.push(File.dirname(__FILE__)) $KCODE = 'UTF-8' unless RUBY_VERSION >= '1.9.0' require 'yaml' require 'date' require 'time' require 'forwardable' require 'twitter_cldr/version' module TwitterCldr autoload :Formatters, 'twitter_cldr/formatters' autoload :Normalizers, 'twitter_cldr/normalizers' autoload :Shared, 'twitter_cldr/shared' autoload :Tokenizers, 'twitter_cldr/tokenizers' autoload :Utils, 'twitter_cldr/utils' extend SingleForwardable # version of CLDR that was used for generating YAML files in the resources/ directory CLDR_VERSION = '21.0' # release date: 2012-02-10 DEFAULT_LOCALE = :en DEFAULT_CALENDAR_TYPE = :gregorian RESOURCES_DIR = File.join(File.dirname(File.dirname(File.expand_path(__FILE__))), 'resources') # maps twitter locales to cldr locales TWITTER_LOCALE_MAP = { :msa => :ms, :'zh-cn' => :zh, :'zh-tw' => :'zh-Hant' } def_delegator :resources, :get_resource def_delegator :resources, :get_locale_resource class << self def resources @resources ||= TwitterCldr::Shared::Resources.new end def get_locale if defined?(FastGettext) locale = FastGettext.locale locale = DEFAULT_LOCALE if locale.to_s.empty? else locale = DEFAULT_LOCALE end (supported_locale?(locale) ? locale : DEFAULT_LOCALE).to_sym end def convert_locale(locale) locale = locale.to_sym TWITTER_LOCALE_MAP.fetch(locale, locale) end def supported_locales @supported_locales ||= Dir.glob(File.join(RESOURCES_DIR, 'locales', '*')).map { |f| File.basename(f).to_sym } end def supported_locale?(locale) locale = locale.to_sym supported_locales.include?(locale) || supported_locales.include?(convert_locale(locale)) end end end require 'twitter_cldr/core_ext'
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
twitter_cldr-1.3.0 | lib/twitter_cldr.rb |