class Stringex::Localization::Backend::Internal

Constants

DEFAULT_LOCALE

Public Class Methods

default_locale() click to toggle source
   # File lib/stringex/localization/backend/internal.rb
16 def default_locale
17   @default_locale || DEFAULT_LOCALE
18 end
default_locale=(new_locale) click to toggle source
   # File lib/stringex/localization/backend/internal.rb
20 def default_locale=(new_locale)
21   @default_locale = @locale = new_locale.to_sym
22 end
initial_translation(scope, key, locale) click to toggle source
   # File lib/stringex/localization/backend/internal.rb
40 def initial_translation(scope, key, locale)
41   translations[locale][scope][key.to_sym]
42 end
locale() click to toggle source
   # File lib/stringex/localization/backend/internal.rb
 8 def locale
 9   @locale || default_locale
10 end
locale=(new_locale) click to toggle source
   # File lib/stringex/localization/backend/internal.rb
12 def locale=(new_locale)
13   @locale = new_locale.to_sym
14 end
store_translations(locale, scope, data) click to toggle source
   # File lib/stringex/localization/backend/internal.rb
36 def store_translations(locale, scope, data)
37   self.translations[locale.to_sym][scope.to_sym] = Hash[data.map { |k, v| [k.to_sym, v] }] # Symbolize keys
38 end
translations() click to toggle source
   # File lib/stringex/localization/backend/internal.rb
31 def translations
32   # Set up hash like translations[:en][:transliterations]["é"]
33   @translations ||= Hash.new { |k, v| k[v] = Hash.new({}) }
34 end
with_locale(new_locale) { || ... } click to toggle source
   # File lib/stringex/localization/backend/internal.rb
24 def with_locale(new_locale, &block)
25   original_locale = locale
26   self.locale = new_locale
27   yield
28   self.locale = original_locale
29 end