Permalink
Browse files

Updating readme spec, history.txt, added default locale to DateTimeFo…

…rmatter
  • Loading branch information...
1 parent 83560c5 commit 8441736fad086708d582e2c2770031f741ffe44a Cameron Dutro committed Nov 29, 2012
View
@@ -1,12 +1,13 @@
== 2.0.0
-* Added locales bg, cy, gl, lv, sk, sq, sr, and ta.
-* Additional date formats.
+* Added locales ga, ta, gl, cy, sr, bg, ku, ro, lv, be, sq, sk, and bn.
+* Added additional date formats.
* Upgraded to CLDR 22.1.
-* Improved currency formatting and symbols from CLDR.
-* Short numbers (eg. 1M for 1 million).
-* Better RCov support.
+* Imported currency symbols and formatting rules from CLDR.
+* Added support for short/long numbers (eg. 1M for 1,000,000).
+* Improved RCov/Simplecov support.
* Added custom Hungarian plurals rule.
+* Added support for approximate timespans (relative times).
=== 1.9.1
@@ -52,6 +52,10 @@ def additional_format_selector
@tokenizer.additional_format_selector
end
+ def self.additional_formats_for(locale)
+ new(:locale => locale).additional_format_selector.patterns.map(&:to_s)
+ end
+
protected
# there is incomplete era data in CLDR for certain locales like Hindi
@@ -8,7 +8,7 @@ module Localized
class LocalizedTimespan < LocalizedObject
def initialize(seconds, options = {})
- super(seconds, options[:locale], options)
+ super(seconds, options[:locale] || TwitterCldr.get_locale, options)
end
def to_s(options = {})
View
@@ -50,6 +50,14 @@ def spaces(str)
TwitterCldr::Shared::Currencies.for_code("CAD").should == { :currency => :CAD, :symbol => "CA$", :name => "Canadian dollar"}
end
+ it "verifies short and long decimals" do
+ 2337.localize.to_short_decimal.to_s.should == "2K"
+ 1337123.localize.to_short_decimal.to_s.should == "1M"
+
+ 2337.localize.to_long_decimal.to_s.should == "2 thousand"
+ 1337123.localize.to_long_decimal.to_s.should == "1 million"
+ end
+
it "verifies dates" do
date_time = DateTime.new(2011, 12, 12, 21, 44, 57, -8.0 / 24.0)
date = date_time.localize.to_date.base_obj
@@ -74,6 +82,13 @@ def spaces(str)
dt.to_short_s.should == "12/12/11 21:44"
end
+ it "verifies additional date formats" do
+ date_time = DateTime.new(2011, 12, 12, 21, 44, 57, -8.0 / 24.0)
+ TwitterCldr::Formatters::DateTimeFormatter.additional_formats_for(:ja).should be_a(Array)
+ date_time.localize(:ja).to_s.should == "2011/12/12 21:44:57"
+ date_time.localize(:ja).to_s(:format => "EEEEd").should == "12日月曜日"
+ end
+
it "verifies relative time spans" do
(DateTime.now - 1).localize.ago.to_s.should match_normalized("1 day ago")
(DateTime.now - 0.5).localize.ago.to_s.should match_normalized("12 hours ago") # (i.e. half a day)
@@ -99,6 +114,12 @@ def spaces(str)
ts.to_s(:unit => :hour).should match_normalized("Vor 24 Stunden")
end
+ it "verifies approximate timespans" do
+ TwitterCldr::Localized::LocalizedTimespan.new(44).to_s(:approximate => true).should == "In 44 seconds"
+ TwitterCldr::Localized::LocalizedTimespan.new(45).to_s(:approximate => true).should == "In 1 minute"
+ TwitterCldr::Localized::LocalizedTimespan.new(52).to_s(:approximate => true).should == "In 1 minute"
+ end
+
it "verifies plural rules" do
1.localize(:ru).plural_rule.should == :one
2.localize(:ru).plural_rule.should == :few

0 comments on commit 8441736

Please sign in to comment.