Sha256: c8527d5550d883c998923dbded20a44395c0e4146b93b8d4bd7c6523694caa19

Contents?: true

Size: 960 Bytes

Versions: 8

Compression:

Stored size: 960 Bytes

Contents

# frozen_string_literal: true

require 'fast_gettext/mo_file'
require 'fast_gettext/storage'
require 'fast_gettext/translation'
require 'fast_gettext/translation_repository'
require 'fast_gettext/vendor/string'
require 'fast_gettext/version'

module FastGettext
  extend FastGettext::Storage
  extend FastGettext::Translation

  LOCALE_REX = /^[a-z]{2,3}$|^[a-z]{2,3}_[A-Z]{2,3}$/.freeze
  NAMESPACE_SEPARATOR = '|'
  CONTEXT_SEPARATOR = "\004"

  # helper block for changing domains
  def self.with_domain(domain)
    old_domain = FastGettext.text_domain
    FastGettext.text_domain = domain
    yield
  ensure
    FastGettext.text_domain = old_domain
  end

  def self.add_text_domain(name, options)
    translation_repositories[name] = TranslationRepository.build(name, options)
  end

  # some repositories know where to store their locales
  def self.locale_path
    translation_repositories[text_domain].instance_variable_get(:@options)[:path]
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
fast_gettext-3.1.0 lib/fast_gettext.rb
fast_gettext-2.3.0 lib/fast_gettext.rb
fast_gettext-2.2.0 lib/fast_gettext.rb
fast_gettext-2.1.0 lib/fast_gettext.rb
fast_gettext-2.0.3 lib/fast_gettext.rb
fast_gettext-2.0.2 lib/fast_gettext.rb
fast_gettext-2.0.1 lib/fast_gettext.rb
fast_gettext-2.0.0 lib/fast_gettext.rb