From 7771e6687237858e5978d4bc5a46fa832da81f3e Mon Sep 17 00:00:00 2001 From: DAddYE Date: Thu, 18 Feb 2010 19:58:29 +0100 Subject: [PATCH] [padrino-core] Removed auto_locale, we need a core smaller and faster, so people that need it can easly use a extension/initializer. --- .../padrino-admin/generators/app/app.rb.tt | 1 - padrino-core/lib/padrino-core/application.rb | 19 ----------------- padrino-core/test/test_application.rb | 21 ------------------- .../lib/padrino-gen/generators/app/app.rb.tt | 1 - .../generators/project/app/app.rb.tt | 1 - 5 files changed, 43 deletions(-) diff --git a/padrino-admin/lib/padrino-admin/generators/app/app.rb.tt b/padrino-admin/lib/padrino-admin/generators/app/app.rb.tt index 631b27b69..5aa38c409 100644 --- a/padrino-admin/lib/padrino-admin/generators/app/app.rb.tt +++ b/padrino-admin/lib/padrino-admin/generators/app/app.rb.tt @@ -9,7 +9,6 @@ class Admin < Padrino::Application # set :reload, false # Reload application files (default in development) # set :default_builder, "foo" # Set a custom form builder (default 'StandardFormBuilder') # set :locale_path, "bar" # Set path for I18n translations (default your_app/locales) - # enable :auto_locale # Auto Set locale if url match /:locale/foo/bar (disabled by default) # disable :padrino_helpers # Disables padrino markup helpers (enabled by default if present) # disable :padrino_mailer # Disables padrino mailer (enabled by default if present) # disable :flash # Disables rack-flash (enabled by default) diff --git a/padrino-core/lib/padrino-core/application.rb b/padrino-core/lib/padrino-core/application.rb index 4c7109f39..3788f6c04 100644 --- a/padrino-core/lib/padrino-core/application.rb +++ b/padrino-core/lib/padrino-core/application.rb @@ -183,7 +183,6 @@ def default_configuration! set :authentication, false # Padrino locale set :locale_path, Proc.new { Dir[File.join(self.root, "/locale/**/*.{rb,yml}")] } - set :auto_locale, false # Plugin specific set :padrino_mailer, defined?(Padrino::Mailer) set :padrino_helpers, defined?(Padrino::Helpers) @@ -468,24 +467,6 @@ def route!(base=self.class, pass_block=nil) route_missing end end - - ## - # When we set :auto_locale, true then if we use param locale like: - # - # ==== Examples - # - # get "/:locale/some/foo" do; ...; end - # - # we automatically set the I18n locale to params[:locale] - # - def route_eval(&block) - if options.auto_locale - if params[:locale] - I18n.locale = params[:locale].to_sym rescue options.locale - end - end - super(&block) - end ## # Hijacking the sinatra render for do three thing: diff --git a/padrino-core/test/test_application.rb b/padrino-core/test/test_application.rb index 1d7583dd7..edea3ddbc 100644 --- a/padrino-core/test/test_application.rb +++ b/padrino-core/test/test_application.rb @@ -147,25 +147,4 @@ class PadrinoTestApp < Padrino::Application; end end end end - - context 'for application i18n functionality' do - - should 'have auto_locale disabled' do - mock_app do - assert !auto_locale - end - end - - should 'set locale when auto_locale is enabled' do - mock_app do - enable :auto_locale - get("/:locale"){ I18n.locale.to_s } - end - - %w(it de fr).each do |lang| - get("/#{lang}") - assert_equal lang, body - end - end - end end \ No newline at end of file diff --git a/padrino-gen/lib/padrino-gen/generators/app/app.rb.tt b/padrino-gen/lib/padrino-gen/generators/app/app.rb.tt index bbb09874f..c8a7aa570 100644 --- a/padrino-gen/lib/padrino-gen/generators/app/app.rb.tt +++ b/padrino-gen/lib/padrino-gen/generators/app/app.rb.tt @@ -9,7 +9,6 @@ class <%= @class_name %> < Padrino::Application # set :reload, false # Reload application files (default in development) # set :default_builder, "foo" # Set a custom form builder (default 'StandardFormBuilder') # set :locale_path, "bar" # Set path for I18n translations (default your_app/locales) - # enable :auto_locale # Auto Set locale if url match /:locale/foo/bar (disabled by default) # disable :padrino_helpers # Disables padrino markup helpers (enabled by default if present) # disable :padrino_mailer # Disables padrino mailer (enabled by default if present) # disable :flash # Disables rack-flash (enabled by default) diff --git a/padrino-gen/lib/padrino-gen/generators/project/app/app.rb.tt b/padrino-gen/lib/padrino-gen/generators/project/app/app.rb.tt index bbb09874f..c8a7aa570 100644 --- a/padrino-gen/lib/padrino-gen/generators/project/app/app.rb.tt +++ b/padrino-gen/lib/padrino-gen/generators/project/app/app.rb.tt @@ -9,7 +9,6 @@ class <%= @class_name %> < Padrino::Application # set :reload, false # Reload application files (default in development) # set :default_builder, "foo" # Set a custom form builder (default 'StandardFormBuilder') # set :locale_path, "bar" # Set path for I18n translations (default your_app/locales) - # enable :auto_locale # Auto Set locale if url match /:locale/foo/bar (disabled by default) # disable :padrino_helpers # Disables padrino markup helpers (enabled by default if present) # disable :padrino_mailer # Disables padrino mailer (enabled by default if present) # disable :flash # Disables rack-flash (enabled by default)