Skip to content

Commit

Permalink
removed #populate and #store_translations from API
Browse files Browse the repository at this point in the history
  • Loading branch information
mseppae authored and Sven Fuchs committed Aug 27, 2008
1 parent dd76298 commit f4e514a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 33 deletions.
12 changes: 0 additions & 12 deletions lib/i18n.rb
Expand Up @@ -49,13 +49,6 @@ def exception_handler=(exception_handler)
@@exception_handler = exception_handler
end

# Allow client libraries to pass a block that populates the translation
# storage. Decoupled for backends like a db backend that persist their
# translations, so the backend can decide whether/when to yield or not.
def populate(&block)
backend.populate(&block)
end

# Allows client libraries to pass arguments that specify a source for
# translation data to be loaded by the backend. The backend defines
# acceptable sources.
Expand All @@ -66,11 +59,6 @@ def load_translations(*args)
backend.load_translations(*args)
end

# Stores translations for the given locale in the backend.
def store_translations(locale, data)
backend.store_translations locale, data
end

# Translates, pluralizes and interpolates a given key using a given locale,
# scope, and default, as well as interpolation values.
#
Expand Down
8 changes: 4 additions & 4 deletions test/i18n_exceptions_test.rb
Expand Up @@ -79,22 +79,22 @@ def force_invalid_locale
end

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

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

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

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

class I18nTest < Test::Unit::TestCase
def setup
I18n.store_translations :'en-US', {
I18n.backend.store_translations :'en-US', {
:currency => {
:format => {
:separator => '.',
Expand Down Expand Up @@ -71,22 +71,6 @@ def test_delegates_localize_to_backend
I18n.localize :whatever, :locale => 'de-DE'
end

def test_delegates_store_translations_to_backend
I18n.backend.expects(:store_translations).with 'de-DE', {:foo => :bar}
I18n.store_translations 'de-DE', {:foo => :bar}
end

def test_delegates_populate_to_backend
I18n.backend.expects(:populate) # can't specify a block here as an expected argument
I18n.populate{ }
end

def test_populate_yields_the_block
tmp = nil
I18n.populate do tmp = 'yielded' end
assert_equal 'yielded', tmp
end

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

0 comments on commit f4e514a

Please sign in to comment.