forked from ruby-i18n/i18n
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move exceptions to an extra file and store context information on exc…
…eptions
- Loading branch information
Sven Fuchs
committed
Jul 6, 2008
1 parent
b18b5f9
commit 80a941d
Showing
3 changed files
with
50 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,43 @@ | |||
module I18n | |||
class ArgumentError < ::ArgumentError; end | |||
class InvalidLocale < ArgumentError | |||
attr_reader :locale | |||
def initialize(locale) | |||
@locale = locale | |||
super "#{locale.inspect} is not a valid locale" | |||
end | |||
end | |||
|
|||
class MissingTranslationData < ArgumentError | |||
attr_reader :key, :locale, :options | |||
def initialize(key, locale, options) | |||
@key, @locale, @options = key, locale, options | |||
keys = I18n.send(:normalize_translation_keys, locale, key, options[:scope]) | |||
super "translation data missing for #{keys.inspect}" | |||
end | |||
end | |||
|
|||
class InvalidPluralizationData < ArgumentError | |||
attr_reader :entry, :count | |||
def initialize(entry, count) | |||
@entry, @count = entry, count | |||
super "translation data #{entry.inspect} can not be used with :count => #{count}" | |||
end | |||
end | |||
|
|||
class MissingInterpolationArgument < ArgumentError | |||
attr_reader :key, :string | |||
def initialize(key, string) | |||
@key, @string = key, string | |||
super %s(interpolation argument #{key} missing in "#{string}") | |||
end | |||
end | |||
|
|||
class ReservedInterpolationKey < ArgumentError | |||
attr_reader :key, :string | |||
def initialize(key, string) | |||
@key, @string = key, string | |||
super "reserved key #{key.inspect} used in #{string.inspect}" | |||
end | |||
end | |||
end |