File: active_support/vendor/i18n-0.4.1/i18n/config.rb

Overview
Module Structure
Class Hierarchy
Code

Overview

Module Structure

  module: <Toplevel Module>
  module: I18n#1
  class: Config#2
inherits from
  Object ( Builtin-Module )
has properties
method: locale #5
method: locale= / 1 #10
method: backend #15
method: backend= / 1 #20
method: default_locale #25
method: default_locale= / 1 #30
method: available_locales #37
method: available_locales= / 1 #42
method: default_separator #47
method: default_separator= / 1 #52
method: exception_handler #57
method: exception_handler= / 1 #62
method: load_path #74
method: load_path= / 1 #80

Class Hierarchy

Object ( Builtin-Module )
  Config ( I18n ) #2

Code

   1  module I18n
   2    class Config
   3      # The only configuration value that is not global and scoped to thread is :locale.
   4      # It defaults to the default_locale.
   5      def locale
   6        @locale ||= default_locale
   7      end
   8 
   9      # Sets the current locale pseudo-globally, i.e. in the Thread.current hash.
  10      def locale=(locale)
  11        @locale = locale.to_sym rescue nil
  12      end
  13 
  14      # Returns the current backend. Defaults to +Backend::Simple+.
  15      def backend
  16        @@backend ||= Backend::Simple.new
  17      end
  18 
  19      # Sets the current backend. Used to set a custom backend.
  20      def backend=(backend)
  21        @@backend = backend
  22      end
  23 
  24      # Returns the current default locale. Defaults to :'en'
  25      def default_locale
  26        @@default_locale ||= :en
  27      end
  28 
  29      # Sets the current default locale. Used to set a custom default locale.
  30      def default_locale=(locale)
  31        @@default_locale = locale.to_sym rescue nil
  32      end
  33 
  34      # Returns an array of locales for which translations are available.
  35      # Unless you explicitely set the these through I18n.available_locales=
  36      # the call will be delegated to the backend and memoized on the I18n module.
  37      def available_locales
  38        @@available_locales ||= backend.available_locales
  39      end
  40 
  41      # Sets the available locales.
  42      def available_locales=(locales)
  43        @@available_locales = locales
  44      end
  45 
  46      # Returns the current default scope separator. Defaults to '.'
  47      def default_separator
  48        @@default_separator ||= '.'
  49      end
  50 
  51      # Sets the current default scope separator.
  52      def default_separator=(separator)
  53        @@default_separator = separator
  54      end
  55 
  56      # Return the current exception handler. Defaults to :default_exception_handler.
  57      def exception_handler
  58        @@exception_handler ||= :default_exception_handler
  59      end
  60 
  61      # Sets the exception handler.
  62      def exception_handler=(exception_handler)
  63        @@exception_handler = exception_handler
  64      end
  65 
  66      # Allow clients to register paths providing translation data sources. The
  67      # backend defines acceptable sources.
  68      #
  69      # E.g. the provided SimpleBackend accepts a list of paths to translation
  70      # files which are either named *.rb and contain plain Ruby Hashes or are
  71      # named *.yml and contain YAML data. So for the SimpleBackend clients may
  72      # register translation files like this:
  73      #   I18n.load_path << 'path/to/locale/en.yml'
  74      def load_path
  75        @@load_path ||= []
  76      end
  77 
  78      # Sets the load path instance. Custom implementations are expected to
  79      # behave like a Ruby Array.
  80      def load_path=(load_path)
  81        @@load_path = load_path
  82      end
  83    end
  84  en