blob: a80afcd7f9f5d7dc8b577bba8b3f28cae66a518f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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
|