OSDN Git Service

Rails 2.3.11
[redminele/redminele.git] / ruby / lib / ruby / gems / 1.8 / gems / activesupport-2.3.11 / lib / active_support / vendor / i18n-0.4.1 / i18n / locale / tag / simple.rb
diff --git a/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.11/lib/active_support/vendor/i18n-0.4.1/i18n/locale/tag/simple.rb b/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.11/lib/active_support/vendor/i18n-0.4.1/i18n/locale/tag/simple.rb
new file mode 100644 (file)
index 0000000..0fddb36
--- /dev/null
@@ -0,0 +1,41 @@
+# encoding: utf-8
+
+# Simple Locale tag implementation that computes subtags by simply splitting
+# the locale tag at '-' occurences.
+module I18n
+  module Locale
+    module Tag
+      class Simple
+        class << self
+          def tag(tag)
+            new(tag)
+          end
+        end
+
+        include Parents
+
+        attr_reader :tag
+
+        def initialize(*tag)
+          @tag = tag.join('-').to_sym
+        end
+
+        def subtags
+          @subtags = tag.to_s.split('-').map { |subtag| subtag.to_s }
+        end
+
+        def to_sym
+          tag
+        end
+
+        def to_s
+          tag.to_s
+        end
+
+        def to_a
+          subtags
+        end
+      end
+    end
+  end
+end