Skip to content

Commit

Permalink
Changed process of storing translations from the
Browse files Browse the repository at this point in the history
client libraries to the backend: clients now can pass a block to
backend#populate which can contain code to load and register translations.

This makes sense for backends that persist their translations (e.g. to db)
so the repeated loading and passing of translations throughout the server
startup would be wasted resources.
  • Loading branch information
Sven Fuchs committed Jun 21, 2008
1 parent 585c8c1 commit c1e2506
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 48 deletions.
4 changes: 3 additions & 1 deletion actionpack/lib/action_view.rb
Expand Up @@ -32,7 +32,9 @@
require 'action_view/partials'
require 'action_view/template_error'

require 'action_view/lang/en-US.rb'
I18n.backend.populate do
require 'action_view/lang/en-US.rb'
end

ActionView::Base.class_eval do
include ActionView::Partials
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_view/lang/en-US.rb
@@ -1,4 +1,4 @@
I18n.backend.set_translations :'en-US', {
I18n.backend.store_translations :'en-US', {
:date => {
:formats => {
:default => "%Y-%m-%d",
Expand Down
2 changes: 1 addition & 1 deletion actionpack/test/template/number_helper_i18n_test.rb
Expand Up @@ -7,7 +7,7 @@ class NumberHelperI18nTests < Test::Unit::TestCase
def setup
@request = mock
@defaults = {:separator => ".", :unit => "$", :format => "%u%n", :delimiter => ",", :precision => 2}
I18n.backend.set_translations 'en-US', :currency => {:format => @defaults}
I18n.backend.store_translations 'en-US', :currency => {:format => @defaults}
end

def test_number_to_currency_given_a_locale_it_does_not_check_request_for_locale
Expand Down
5 changes: 4 additions & 1 deletion activerecord/lib/active_record.rb
Expand Up @@ -81,4 +81,7 @@

require 'active_record/schema_dumper'

require 'active_record/lang/en-US.rb'
I18n.backend.populate do
require 'active_record/lang/en-US.rb'
end

2 changes: 1 addition & 1 deletion activerecord/lib/active_record/lang/en-US.rb
@@ -1,4 +1,4 @@
I18n.backend.set_translations :'en-US', {
I18n.backend.store_translations :'en-US', {
:active_record => {
:error_messages => {
:inclusion => "is not included in the list",
Expand Down
80 changes: 40 additions & 40 deletions activerecord/test/cases/validations_i18n_test.rb

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion activesupport/lib/active_support.rb
Expand Up @@ -55,7 +55,10 @@
require 'active_support/base64'

require 'active_support/time_with_zone'
require 'active_support/lang/en-US.rb'

I18n.backend.populate do
require 'active_support/lang/en-US.rb'
end

Inflector = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('Inflector', 'ActiveSupport::Inflector')
Dependencies = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('Dependencies', 'ActiveSupport::Dependencies')
Expand Down
2 changes: 1 addition & 1 deletion activesupport/lib/active_support/lang/en-US.rb
@@ -1,4 +1,4 @@
I18n.backend.set_translations :'en-US', {
I18n.backend.store_translations :'en-US', {
:support => {
:array => {
:sentence_connector => 'and'
Expand Down
2 changes: 1 addition & 1 deletion activesupport/lib/active_support/vendor/i18n-0.0.1
Submodule i18n-0.0.1 updated from 1af343 to 8e43af

0 comments on commit c1e2506

Please sign in to comment.