~ubuntu-branches/ubuntu/vivid/ruby-i18n/vivid

« back to all changes in this revision

Viewing changes to lib/i18n/config.rb

  • Committer: Package Import Robot
  • Author(s): Jonas Genannt
  • Date: 2013-11-27 19:26:54 UTC
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: package-import@ubuntu.com-20131127192654-ihh1sn3y680fvh29
Tags: upstream-0.6.5
ImportĀ upstreamĀ versionĀ 0.6.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
      @@exception_handler = exception_handler
66
66
    end
67
67
 
 
68
    # Returns the current handler for situations when interpolation argument
 
69
    # is missing. MissingInterpolationArgument will be raised by default.
 
70
    def missing_interpolation_argument_handler
 
71
      @@missing_interpolation_argument_handler ||= lambda do |missing_key, provided_hash, string|
 
72
        raise MissingInterpolationArgument.new(missing_key, provided_hash, string)
 
73
      end
 
74
    end
 
75
 
 
76
    # Sets the missing interpolation argument handler. It can be any
 
77
    # object that responds to #call. The arguments that will be passed to #call
 
78
    # are the same as for MissingInterpolationArgument initializer. Use +Proc.new+
 
79
    # if you don't care about arity.
 
80
    #
 
81
    # == Example:
 
82
    # You can supress raising an exception and return string instead:
 
83
    #
 
84
    #   I18n.config.missing_interpolation_argument_handler = Proc.new do |key|
 
85
    #     "#{key} is missing"
 
86
    #   end
 
87
    def missing_interpolation_argument_handler=(exception_handler)
 
88
      @@missing_interpolation_argument_handler = exception_handler
 
89
    end
 
90
 
68
91
    # Allow clients to register paths providing translation data sources. The
69
92
    # backend defines acceptable sources.
70
93
    #