Add Globalize2 so that we get some nice fall backs to other languages when a translation is missing in the requested language.
This commit is contained in:
parent
6ba51da46e
commit
283a3e9ba9
42 changed files with 2670 additions and 0 deletions
32
vendor/plugins/globalize2/lib/globalize/translation.rb
vendored
Normal file
32
vendor/plugins/globalize2/lib/globalize/translation.rb
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
module Globalize
|
||||
# Translations are simple value objects that carry some context information
|
||||
# alongside the actual translation string.
|
||||
|
||||
class Translation < String
|
||||
class Attribute < Translation
|
||||
attr_accessor :requested_locale, :locale, :key
|
||||
end
|
||||
|
||||
class Static < Translation
|
||||
attr_accessor :requested_locale, :locale, :key, :options, :plural_key, :original
|
||||
|
||||
def initialize(string, meta = nil)
|
||||
self.original = string
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
def initialize(string, meta = nil)
|
||||
set_meta meta
|
||||
super string
|
||||
end
|
||||
|
||||
def fallback?
|
||||
locale.to_sym != requested_locale.to_sym
|
||||
end
|
||||
|
||||
def set_meta(meta)
|
||||
meta.each {|name, value| send :"#{name}=", value } if meta
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue