Skip to content

Commit

Permalink
Using :'en' as a default locale (in favor of :'en-US'). Bump version …
Browse files Browse the repository at this point in the history
…to 0.1.1.
  • Loading branch information
yaroslav committed Nov 20, 2008
1 parent 3696c92 commit c4b10b2
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 109 deletions.
8 changes: 4 additions & 4 deletions i18n.gemspec
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = "i18n"
s.version = "0.1.0"
s.version = "0.1.1"
s.date = "2008-10-26"
s.summary = "Internationalization support for Ruby"
s.email = "rails-i18n@googlegroups.com"
Expand All @@ -20,8 +20,8 @@ Gem::Specification.new do |s|
'test/all.rb',
'test/i18n_exceptions_test.rb',
'test/i18n_test.rb',
'test/locale/en-US.rb',
'test/locale/en-US.yml',
'test/locale/en.rb',
'test/locale/en.yml',
'test/simple_backend_test.rb'
]
end
end
6 changes: 3 additions & 3 deletions lib/i18n.rb
Expand Up @@ -11,7 +11,7 @@
module I18n
@@backend = nil
@@load_path = nil
@@default_locale = :'en-US'
@@default_locale = :'en'
@@exception_handler = :default_exception_handler

class << self
Expand All @@ -25,7 +25,7 @@ def backend=(backend)
@@backend = backend
end

# Returns the current default locale. Defaults to 'en-US'
# Returns the current default locale. Defaults to :'en'
def default_locale
@@default_locale
end
Expand Down Expand Up @@ -57,7 +57,7 @@ def exception_handler=(exception_handler)
# files which are either named *.rb and contain plain Ruby Hashes or are
# named *.yml and contain YAML data. So for the SimpleBackend clients may
# register translation files like this:
# I18n.load_path << 'path/to/locale/en-US.yml'
# I18n.load_path << 'path/to/locale/en.yml'
def load_path
@@load_path ||= []
end
Expand Down
20 changes: 10 additions & 10 deletions test/i18n_exceptions_test.rb
Expand Up @@ -23,15 +23,15 @@ def test_missing_translation_data_stores_locale_key_and_options
force_missing_translation_data
rescue I18n::ArgumentError => e
options = {:scope => :bar}
assert_equal 'de-DE', e.locale
assert_equal 'de', e.locale
assert_equal :foo, e.key
assert_equal options, e.options
end

def test_missing_translation_data_message
force_missing_translation_data
rescue I18n::ArgumentError => e
assert_equal 'translation missing: de-DE, bar, foo', e.message
assert_equal 'translation missing: de, bar, foo', e.message
end

def test_invalid_pluralization_data_stores_entry_and_count
Expand Down Expand Up @@ -79,22 +79,22 @@ def force_invalid_locale
end

def force_missing_translation_data
I18n.backend.store_translations 'de-DE', :bar => nil
I18n.backend.translate 'de-DE', :foo, :scope => :bar
I18n.backend.store_translations 'de', :bar => nil
I18n.backend.translate 'de', :foo, :scope => :bar
end

def force_invalid_pluralization_data
I18n.backend.store_translations 'de-DE', :foo => [:bar]
I18n.backend.translate 'de-DE', :foo, :count => 1
I18n.backend.store_translations 'de', :foo => [:bar]
I18n.backend.translate 'de', :foo, :count => 1
end

def force_missing_interpolation_argument
I18n.backend.store_translations 'de-DE', :foo => "{{bar}}"
I18n.backend.translate 'de-DE', :foo, :baz => 'baz'
I18n.backend.store_translations 'de', :foo => "{{bar}}"
I18n.backend.translate 'de', :foo, :baz => 'baz'
end

def force_reserved_interpolation_key
I18n.backend.store_translations 'de-DE', :foo => "{{scope}}"
I18n.backend.translate 'de-DE', :foo, :baz => 'baz'
I18n.backend.store_translations 'de', :foo => "{{scope}}"
I18n.backend.translate 'de', :foo, :baz => 'baz'
end
end
36 changes: 18 additions & 18 deletions test/i18n_test.rb
Expand Up @@ -8,7 +8,7 @@

class I18nTest < Test::Unit::TestCase
def setup
I18n.backend.store_translations :'en-US', {
I18n.backend.store_translations :'en', {
:currency => {
:format => {
:separator => '.',
Expand All @@ -29,24 +29,24 @@ def test_can_set_backend
end

def test_uses_en_us_as_default_locale_by_default
assert_equal 'en-US', I18n.default_locale
assert_equal 'en', I18n.default_locale
end

def test_can_set_default_locale
assert_nothing_raised{ I18n.default_locale = 'de-DE' }
assert_equal 'de-DE', I18n.default_locale
I18n.default_locale = 'en-US'
assert_nothing_raised{ I18n.default_locale = 'de' }
assert_equal 'de', I18n.default_locale
I18n.default_locale = 'en'
end

def test_uses_default_locale_as_locale_by_default
assert_equal I18n.default_locale, I18n.locale
end

def test_can_set_locale_to_thread_current
assert_nothing_raised{ I18n.locale = 'de-DE' }
assert_equal 'de-DE', I18n.locale
assert_equal 'de-DE', Thread.current[:locale]
I18n.locale = 'en-US'
assert_nothing_raised{ I18n.locale = 'de' }
assert_equal 'de', I18n.locale
assert_equal 'de', Thread.current[:locale]
I18n.locale = 'en'
end

def test_can_set_exception_handler
Expand All @@ -62,17 +62,17 @@ def test_uses_custom_exception_handler
end

def test_delegates_translate_to_backend
I18n.backend.expects(:translate).with 'de-DE', :foo, {}
I18n.translate :foo, :locale => 'de-DE'
I18n.backend.expects(:translate).with 'de', :foo, {}
I18n.translate :foo, :locale => 'de'
end

def test_delegates_localize_to_backend
I18n.backend.expects(:localize).with 'de-DE', :whatever, :default
I18n.localize :whatever, :locale => 'de-DE'
I18n.backend.expects(:localize).with 'de', :whatever, :default
I18n.localize :whatever, :locale => 'de'
end

def test_translate_given_no_locale_uses_i18n_locale
I18n.backend.expects(:translate).with 'en-US', :foo, {}
I18n.backend.expects(:translate).with 'en', :foo, {}
I18n.translate :foo
end

Expand Down Expand Up @@ -101,18 +101,18 @@ def test_translate_with_dot_separated_key_array_and_scope_works
end

def test_translate_with_options_using_scope_works
I18n.backend.expects(:translate).with('de-DE', :precision, :scope => :"currency.format")
I18n.with_options :locale => 'de-DE', :scope => :'currency.format' do |locale|
I18n.backend.expects(:translate).with('de', :precision, :scope => :"currency.format")
I18n.with_options :locale => 'de', :scope => :'currency.format' do |locale|
locale.t :precision
end
end

# def test_translate_given_no_args_raises_missing_translation_data
# assert_equal "translation missing: en-US, no key", I18n.t
# assert_equal "translation missing: en, no key", I18n.t
# end

def test_translate_given_a_bogus_key_raises_missing_translation_data
assert_equal "translation missing: en-US, bogus", I18n.t(:bogus)
assert_equal "translation missing: en, bogus", I18n.t(:bogus)
end

def test_localize_nil_raises_argument_error
Expand Down
1 change: 0 additions & 1 deletion test/locale/en-US.rb

This file was deleted.

3 changes: 0 additions & 3 deletions test/locale/en-US.yml

This file was deleted.

1 change: 1 addition & 0 deletions test/locale/en.rb
@@ -0,0 +1 @@
{:'en-Ruby' => {:foo => {:bar => "baz"}}}
3 changes: 3 additions & 0 deletions test/locale/en.yml
@@ -0,0 +1,3 @@
en-Yaml:
foo:
bar: baz

0 comments on commit c4b10b2

Please sign in to comment.