diff options
| author | hukl <hukl@eight.local> | 2009-02-07 15:50:40 +0100 |
|---|---|---|
| committer | hukl <hukl@eight.local> | 2009-02-07 15:50:40 +0100 |
| commit | 36a2f1f3c085dd81171cf7d8220770d4ff921ab3 (patch) | |
| tree | 5ded15331b192bf428af4c94d46d1abb28ef0690 /vendor/plugins/globalize2/lib/globalize/translation.rb | |
| parent | ce9645d0092d42c7bf8781378181ffbd4ff3d088 (diff) | |
added globalize2 plugin as well as some modifications
which use the new translation facilities.
backend mostly.
Diffstat (limited to 'vendor/plugins/globalize2/lib/globalize/translation.rb')
| -rw-r--r-- | vendor/plugins/globalize2/lib/globalize/translation.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/vendor/plugins/globalize2/lib/globalize/translation.rb b/vendor/plugins/globalize2/lib/globalize/translation.rb new file mode 100644 index 00000000..a80afcd7 --- /dev/null +++ b/vendor/plugins/globalize2/lib/globalize/translation.rb | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | module Globalize | ||
| 2 | # Translations are simple value objects that carry some context information | ||
| 3 | # alongside the actual translation string. | ||
| 4 | |||
| 5 | class Translation < String | ||
| 6 | class Attribute < Translation | ||
| 7 | attr_accessor :requested_locale, :locale, :key | ||
| 8 | end | ||
| 9 | |||
| 10 | class Static < Translation | ||
| 11 | attr_accessor :requested_locale, :locale, :key, :options, :plural_key, :original | ||
| 12 | |||
| 13 | def initialize(string, meta = nil) | ||
| 14 | self.original = string | ||
| 15 | super | ||
| 16 | end | ||
| 17 | end | ||
| 18 | |||
| 19 | def initialize(string, meta = nil) | ||
| 20 | set_meta meta | ||
| 21 | super string | ||
| 22 | end | ||
| 23 | |||
| 24 | def fallback? | ||
| 25 | locale.to_sym != requested_locale.to_sym | ||
| 26 | end | ||
| 27 | |||
| 28 | def set_meta(meta) | ||
| 29 | meta.each {|name, value| send :"#{name}=", value } if meta | ||
| 30 | end | ||
| 31 | end | ||
| 32 | end \ No newline at end of file | ||
