Sha256: 77036d143fea1621847f3f20a1364be6cd5072660085497d8793284c0f7ccd1e

Contents?: true

Size: 935 Bytes

Versions: 13

Compression:

Stored size: 935 Bytes

Contents

require 'i18n'

module Juli
  module Util
    # Locale is determined by 'locale' entry in .juli/config (default = en).
    #
    # Translation file is used at the following priority:
    #
    # 1. .juli/LC.yml
    # 1. LIB/juli/template/locale/LC.yml
    #
    # Where, LC is the value of 'locale' config (default = en), and
    # LIB is ruby library directory (e.g. /usr/lib/lib/ruby/site_ruby/1.9.1/).
    class JuliI18n
      def initialize(conf, juli_repo)
        I18n.locale = conf['locale'] || :en

        for candidate_dir in [
            File.join(juli_repo, Juli::REPO),
            File.join(Juli::TEMPLATE_PATH, 'locale')
            ] do
          locale_yml = File.join(candidate_dir, "#{I18n.locale}.yml")
          if File.exist?(locale_yml)
            I18n.load_path = [locale_yml]
            return
          end
        end
        raise Errno::ENOENT, "no #{I18n.locale}.yml found"
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
juli-2.3.2 lib/juli/util/juli_i18n.rb
juli-2.3.1 lib/juli/util/juli_i18n.rb
juli-2.3.0 lib/juli/util/juli_i18n.rb
juli-2.2.4 lib/juli/util/juli_i18n.rb
juli-2.2.3 lib/juli/util/juli_i18n.rb
juli-2.2.1 lib/juli/util/juli_i18n.rb
juli-2.2.0 lib/juli/util/juli_i18n.rb
juli-2.1.0 lib/juli/util/juli_i18n.rb
juli-2.0.4 lib/juli/util/juli_i18n.rb
juli-2.0.3 lib/juli/util/juli_i18n.rb
juli-2.0.2 lib/juli/util/juli_i18n.rb
juli-2.0.1 lib/juli/util/juli_i18n.rb
juli-2.0.0 lib/juli/util/juli_i18n.rb