1 # encoding: utf-8
2
3 class KeyError < IndexError
4 def initialize(message = nil)
5 super(message || "key not found")
6 end
7 end unless defined?(KeyError)
8
9 module I18n
10 class ArgumentError < ::ArgumentError; end
11
12 class InvalidLocale < ArgumentError
13 attr_reader :locale
14 def initialize(locale)
15 @locale = locale
16 super "#{locale.inspect} is not a valid locale"
17 end
18 end
19
20 class MissingTranslationData < ArgumentError
21 attr_reader :locale, :key, :options
22 def initialize(locale, key, opts = nil)
23 @key, @locale, @options = key, locale, opts || {}
24 keys = I18n.normalize_keys(locale, key, options[:scope])
25 keys << 'no key' if keys.size < 2
26 super "translation missing: #{keys.join(', ')}"
27 end
28 end
29
30 class InvalidPluralizationData < ArgumentError
31 attr_reader :entry, :count
32 def initialize(entry, count)
33 @entry, @count = entry, count
34 super "translation data #{entry.inspect} can not be used with :count => #{count}"
35 end
36 end
37
38 class MissingInterpolationArgument < ArgumentError
39 attr_reader :values, :string
40 def initialize(values, string)
41 @values, @string = values, string
42 super "missing interpolation argument in #{string.inspect} (#{values.inspect} given)"
43 end
44 end
45
46 class ReservedInterpolationKey < ArgumentError
47 attr_reader :key, :string
48 def initialize(key, string)
49 @key, @string = key, string
50 super "reserved key #{key.inspect} used in #{string.inspect}"
51 end
52 end
53
54 class UnknownFileType < ArgumentError
55 attr_reader :type, :filename
56 def initialize(type, filename)
57 @type, @filename = type, filename
58 super "can not load translations from #{filename}, the file type #{type} is not known"
59 end
60 end
61 en