-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fall through to I18n.fallbacks when defined
- Loading branch information
Showing
5 changed files
with
33 additions
and
1 deletion.
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
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
module Mobility | ||
=begin | ||
Subclasses +I18n::Locale::Fallbacks+ such that instances of this class | ||
fall through to fallbacks defined in +I18n.fallbacks+. This allows models to | ||
customize fallbacks while still falling through to any fallbacks defined | ||
globally. | ||
=end | ||
class Fallbacks < ::I18n::Locale::Fallbacks | ||
# @param [Symbol] locale | ||
# @return [Array] locales | ||
def [](locale) | ||
super | I18n.fallbacks[locale] | ||
end | ||
|
||
# For this set of fallbacks, return a new fallbacks hash. | ||
# @param [Hash] fallbacks | ||
# @return [I18n::Locale::Fallbacks,Mobility::Fallbacks] fallbacks hash | ||
def self.build(fallbacks) | ||
if I18n.respond_to?(:fallbacks) | ||
new(fallbacks) | ||
else | ||
I18n::Locale::Fallbacks.new(fallbacks) | ||
end | ||
end | ||
end | ||
end |
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