File: fully_qualify_i18n_locale

package info (click to toggle)
ruby-locale-rails 2.0.5-6
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,240 kB
  • sloc: ruby: 727; makefile: 2
file content (65 lines) | stat: -rw-r--r-- 2,301 bytes parent folder | download | duplicates (2)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Author: "Marc Dequènes (Duck)" <duck@duckcorp.org>
Origin: other
Bug-Debian: 588757
Forwarded: No
Reviewed-by: Gunnar Wolf <gwolf@debian.org>
Description: Fully qualify calls to Locale in order to avoid name clashes with I18N

Index: liblocale-rails-ruby-2.0.5/lib/locale_rails/i18n.rb
===================================================================
--- liblocale-rails-ruby-2.0.5.orig/lib/locale_rails/i18n.rb	2010-09-12 21:55:11.000000000 -0500
+++ liblocale-rails-ruby-2.0.5/lib/locale_rails/i18n.rb	2010-09-12 21:55:20.000000000 -0500
@@ -13,35 +13,35 @@
 
   # Gets the supported locales.
   def supported_locales 
-    Locale.app_language_tags
+    ::Locale.app_language_tags
   end
 
   # Sets the supported locales.
   #  I18n.set_supported_locales("ja-JP", "ko-KR", ...)
   def set_supported_locales(*tags)
-    Locale.set_app_language_tags(*tags)
+    ::Locale.set_app_language_tags(*tags)
   end
 
   # Sets the supported locales as an Array.
   #  I18n.supported_locales = ["ja-JP", "ko-KR", ...]
   def supported_locales=(tags)
-    Locale.set_app_language_tags(*tags)
+    ::Locale.set_app_language_tags(*tags)
   end
 
   # Sets the locale.
   #  I18n.locale = "ja-JP"
   def locale=(tag)
-    Locale.clear
-    tag = Locale::Tag::Rfc.parse(tag.to_s) if tag.kind_of? Symbol
-    Locale.current = tag
-    Thread.current[:locale] = Locale.candidates(:type => :rfc)[0]
+    ::Locale.clear
+    tag = ::Locale::Tag::Rfc.parse(tag.to_s) if tag.kind_of? Symbol
+    ::Locale.current = tag
+    Thread.current[:locale] = ::Locale.candidates(:type => :rfc)[0]
   end
 
   # Sets the default locale.
   #  I18n.default_locale = "ja"
   def default_locale=(tag)
-    tag = Locale::Tag::Rfc.parse(tag.to_s) if tag.kind_of? Symbol
-    Locale.default = tag
+    tag = ::Locale::Tag::Rfc.parse(tag.to_s) if tag.kind_of? Symbol
+    ::Locale.default = tag
     @@default_locale = tag
   end
   
@@ -50,7 +50,7 @@
     # MissingTranslationData is overrided to fallback messages in candidate locales.
     def locale_rails_exception_handler(exception, locale, key, options) #:nodoc:
       ret = nil
-      Locale.candidates(:type => :rfc).each do |loc|
+      ::Locale.candidates(:type => :rfc).each do |loc|
         begin
           ret = backend.translate(loc, key, options)
           break