From 36a2f1f3c085dd81171cf7d8220770d4ff921ab3 Mon Sep 17 00:00:00 2001 From: hukl Date: Sat, 7 Feb 2009 15:50:40 +0100 Subject: added globalize2 plugin as well as some modifications which use the new translation facilities. backend mostly. --- .../globalize2/lib/globalize/translation.rb | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 vendor/plugins/globalize2/lib/globalize/translation.rb (limited to 'vendor/plugins/globalize2/lib/globalize/translation.rb') 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 @@ +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 \ No newline at end of file -- cgit v1.3