Module: FastGettext
- Extended by:
- Storage, Translation
- Defined in:
- lib/fast_gettext/vendor/iconv.rb,
lib/fast_gettext.rb,
lib/fast_gettext/cache.rb,
lib/fast_gettext/mo_file.rb,
lib/fast_gettext/po_file.rb,
lib/fast_gettext/storage.rb,
lib/fast_gettext/version.rb,
lib/fast_gettext/translation.rb,
lib/fast_gettext/vendor/mofile.rb,
lib/fast_gettext/vendor/poparser.rb,
lib/fast_gettext/translation_repository.rb,
lib/fast_gettext/translation_repository/db.rb,
lib/fast_gettext/translation_repository/mo.rb,
lib/fast_gettext/translation_repository/po.rb,
lib/fast_gettext/translation_repository/base.rb,
lib/fast_gettext/translation_repository/yaml.rb,
lib/fast_gettext/translation_repository/chain.rb,
lib/fast_gettext/translation_repository/merge.rb,
lib/fast_gettext/translation_repository/logger.rb
Overview
Modifications wrapped inside FastGettext namespace to reduce conflic
Defined Under Namespace
Modules: GetText, Storage, Translation, TranslationAliased, TranslationMultidomain, TranslationRepository Classes: Cache, MoFile, PoFile
Constant Summary collapse
- LOCALE_REX =
/^[a-z]{2,3}$|^[a-z]{2,3}_[A-Z]{2,3}$/.freeze
- NAMESPACE_SEPARATOR =
'|'
- CONTEXT_SEPARATOR =
"\004"
- VERSION =
rubocop:disable Naming/ConstantName
Version = '4.1.0'
- TRANSLATION_METHODS =
[:_, :n_, :s_, :p_, :ns_, :np_].freeze
- NIL_BLOCK =
-> { nil }
Constants included from Storage
Storage::DEFAULT_PLURALIZATION_RULE
Class Method Summary collapse
- .add_text_domain(name, options) ⇒ Object
-
.allow_invalid_keys! ⇒ Object
deprecated, just a crutch to migrate to new api.
-
.locale_path ⇒ Object
some repositories know where to store their locales.
-
.with_domain(domain) ⇒ Object
helper block for changing domains.
Methods included from Storage
available_locales, best_locale_in, cache, cached_find, cached_plural_find, current_repository, default_locale, default_locale=, expire_cache_for, key_exist?, locale, locale=, pluralisation_rule, reload!, set_locale, silence_errors, text_domain, translation_repositories, with_locale
Methods included from Translation
N_, Nn_, _, n_, np_, ns_, p_, s_
Class Method Details
.add_text_domain(name, options) ⇒ Object
27 28 29 |
# File 'lib/fast_gettext.rb', line 27 def self.add_text_domain(name, ) translation_repositories[name] = TranslationRepository.build(name, ) end |
.allow_invalid_keys! ⇒ Object
deprecated, just a crutch to migrate to new api
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/fast_gettext.rb', line 32 def self.allow_invalid_keys! eval(<<~CODE) class ::String alias :_fast_gettext_old_format_m :% def %(*args) begin _fast_gettext_old_format_m(*args) rescue KeyError self end end end CODE end |
.locale_path ⇒ Object
some repositories know where to store their locales
48 49 50 |
# File 'lib/fast_gettext.rb', line 48 def self.locale_path translation_repositories[text_domain].instance_variable_get(:@options)[:path] end |
.with_domain(domain) ⇒ Object
helper block for changing domains
19 20 21 22 23 24 25 |
# File 'lib/fast_gettext.rb', line 19 def self.with_domain(domain) old_domain = FastGettext.text_domain FastGettext.text_domain = domain yield ensure FastGettext.text_domain = old_domain end |