Module: Air18n

Defined in:
lib/air18n/prim_and_proper.rb,
lib/air18n.rb,
lib/air18n/phrase.rb,
lib/air18n/backend.rb,
lib/air18n/metrics.rb,
lib/air18n/version.rb,
lib/air18n/priority.rb,
lib/air18n/reflection.rb,
lib/air18n/screenshot.rb,
lib/air18n/chunk_cache.rb,
lib/air18n/smart_count.rb,
lib/air18n/xss_detector.rb,
lib/air18n/class_methods.rb,
lib/air18n/mock_priority.rb,
lib/air18n/logging_helper.rb,
lib/air18n/pseudo_locales.rb,
lib/air18n/phrase_revision.rb,
lib/air18n/translator_info.rb,
lib/air18n/less_silly_chain.rb,
lib/air18n/phrase_screenshot.rb,
lib/air18n/phrase_translation.rb,
lib/air18n/default_text_change_observer.rb,
lib/air18n/testing_support/factories/phrase.rb,
lib/generators/air18n/migration/migration_generator.rb,
lib/air18n/testing_support/factories/translator_info.rb

Overview

Automatic conversion of one locale to another where it is possible, like American to British English.

Defined Under Namespace

Modules: ChunkCache, ClassMethods, DefaultTextChangeObserver, LoggingHelper, Metrics, Priority, PseudoLocales, Reflection, SmartCount, XssDetector Classes: AmericanToAustralian, AmericanToBritish, AmericanToCanadian, AmericanToColonial, AmericanToKiwi, AmericanToSinglish, Backend, GermanToSwissGerman, LessSillyChain, MigrationGenerator, MockPriority, Phrase, PhraseRevision, PhraseScreenshot, PhraseTranslation, PrimAndProper, Screenshot, TranslatorInfo

Constant Summary collapse

AIR18N_RESERVED_KEYS =
[:routes_context, :suppress_ct, :default_is_low_priority, :disable_xss_check, :disable_bookkeeping, :context]
RTL_LOCALES =
[ :he, :ar ]
VERSION =
"0.5.1"

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/air18n.rb', line 18

def self.included(base)
  base.class_eval do
    class << self
      extend ActiveSupport::Memoizable

      module_eval do
        include ClassMethods
      end

      # Country, as a symbol. This is separate from locale, and should set based
      # only on the domain name or IP address or some other kind of geographic
      # location.
      attr_accessor :country

      # Like country; set it to :US if we're on the global domain to show
      # correct terms/conditions
      attr_accessor :tld_country

      # An instance of I18n::Locale::Fallbacks for computing locale fallbacks.
      attr_reader :fallbacks

      # Manages prioritization of translation keys. If set, must implement
      # methods of Air18n::Priority.
      attr_accessor :priority

      # Used as routes context if not specified in options passed to translate().
      attr_accessor :fallback_routes_context

      # Currency for the current request.
      @currency = 'USD'
      attr_reader :currency

      # Cache used to store translation data from the database.
      attr_accessor :cache

      # Whether to wrap phrases in HTML that allows them to be translated by
      # the user from directly on the page.
      @contextual_translation = false

      alias_method :t_with_routes_context, :translate_with_routes_context
      alias_method_chain :t, :routes_context
      alias_method_chain :translate, :routes_context

      memoize :language_from_locale
    end
  end
end