Skip to content
Browse files

Updating territories to new global locale format

  • Loading branch information...
1 parent 63a1285 commit 22865b9f7bd48b79b175787d221242938460c090 @camertron camertron committed Jan 12, 2013
Showing with 10 additions and 10 deletions.
  1. +2 −2 lib/twitter_cldr.rb
  2. +4 −4 lib/twitter_cldr/shared/territories.rb
  3. +4 −4 spec/shared/territories_spec.rb
View
4 lib/twitter_cldr.rb
@@ -80,8 +80,8 @@ def with_locale(locale)
end
def register_locale_fallback(proc_or_locale)
- case proc_or_locale.class.to_s
- when "Symbol", "String", "Proc"
+ case proc_or_locale
+ when Symbol, String, Proc
locale_fallbacks << proc_or_locale
else
raise "A locale fallback must be of type String, Symbol, or Proc."
View
8 lib/twitter_cldr/shared/territories.rb
@@ -10,7 +10,7 @@ module Territories
class << self
def all
- all_for(TwitterCldr.get_locale)
+ all_for(TwitterCldr.locale)
end
def all_for(code)
@@ -20,15 +20,15 @@ def all_for(code)
end
def from_territory_code(territory_code)
- from_territory_code_for_locale(territory_code, TwitterCldr.get_locale)
+ from_territory_code_for_locale(territory_code, TwitterCldr.locale)
end
# Returns how to say a given territory in a given locale.
#
# This method does not work for three-digit United Nation "area
# codes" (UN M.49; for example, 014 for Eastern Africa and 419 for Latin
# America).
- def from_territory_code_for_locale(territory_code, locale = TwitterCldr.get_locale)
+ def from_territory_code_for_locale(territory_code, locale = TwitterCldr.locale)
get_resource(locale)[:territories][TwitterCldr::Utils::Territories.normalize_territory_code(territory_code)]
rescue
nil
@@ -39,7 +39,7 @@ def from_territory_code_for_locale(territory_code, locale = TwitterCldr.get_loca
# This method does not work for three-digit United Nation "area
# codes" (UN M.49; for example, 014 for Eastern Africa and 419 for Latin
# America).
- def translate_territory(territory_name, source_locale = :en, dest_locale = TwitterCldr.get_locale)
+ def translate_territory(territory_name, source_locale = :en, dest_locale = TwitterCldr.locale)
territory_code, _ = get_resource(source_locale)[:territories].find do |_, other_territory_name|
other_territory_name.downcase == territory_name.downcase
end
View
8 spec/shared/territories_spec.rb
@@ -32,14 +32,14 @@
Territories.translate_territory("RUSSIA", :en, :es).should match_normalized("Rusia")
end
- it "defaults the destination language to English (or whatever FastGettext.locale is)" do
+ it "defaults the destination language to English (or whatever the global locale is)" do
Territories.translate_territory("Rusia", :es).should match_normalized("Russia")
Territories.translate_territory("Россия", :ru).should match_normalized("Russia")
end
it "defaults source and destination language to English if not given" do
Territories.translate_territory("Russia").should match_normalized("Russia")
- FastGettext.locale = :es
+ TwitterCldr.locale = :es
Territories.translate_territory("Russia").should match_normalized("Rusia")
end
@@ -73,7 +73,7 @@
it "should return the language in the default locale for the given locale code" do
Territories.from_territory_code(:ES).should match_normalized("Spain")
Territories.from_territory_code(:RU).should match_normalized("Russia")
- FastGettext.locale = :es
+ TwitterCldr.locale = :es
Territories.from_territory_code(:ES).should match_normalized("España")
end
end
@@ -98,7 +98,7 @@
territories[:ru].should match_normalized("Russia")
territories[:de].should match_normalized("Germany")
- FastGettext.locale = :es
+ TwitterCldr.locale = :es
territories = Territories.all
territories.should be_a(Hash)
territories[:ru].should match_normalized("Rusia")

0 comments on commit 22865b9

Please sign in to comment.
Something went wrong with that request. Please try again.