aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2008-11-02 03:52:15 +0530
committerPratik Naik <pratiknaik@gmail.com>2008-11-02 03:52:15 +0530
commit1147453fce0890ea229c3af5f43c909ebe53061e (patch)
tree221d816ef0c908044fd6029950ccad064866ab8f /activesupport
parenta3aa0c17ef8594a0084511f4852be7b5dc66e5e2 (diff)
parent5a02f0bccf55191c2cfbcc69bd8165df6d7a2012 (diff)
downloadrails-1147453fce0890ea229c3af5f43c909ebe53061e.tar.gz
rails-1147453fce0890ea229c3af5f43c909ebe53061e.tar.bz2
rails-1147453fce0890ea229c3af5f43c909ebe53061e.zip
Merge commit 'mainstream/master'
Conflicts: railties/doc/guides/html/layouts_and_rendering.html railties/doc/guides/source/active_record_basics.txt railties/doc/guides/source/layouts_and_rendering.txt
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/CHANGELOG9
-rw-r--r--activesupport/lib/active_support/core_ext/array/conversions.rb2
-rw-r--r--activesupport/lib/active_support/deprecation.rb4
-rw-r--r--activesupport/lib/active_support/string_inquirer.rb2
-rwxr-xr-xactivesupport/lib/active_support/vendor/i18n-0.0.1/i18n.rb15
-rw-r--r--activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb36
6 files changed, 44 insertions, 24 deletions
diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG
index 819a67adfa..e77affc315 100644
--- a/activesupport/CHANGELOG
+++ b/activesupport/CHANGELOG
@@ -1,3 +1,12 @@
+*2.2.1 [RC2 or 2.2 final]*
+
+* Added render :js for people who want to render inline JavaScript replies without using RJS [DHH]
+
+* Fixed the option merging in Array#to_xml #1126 [Rudolf Gavlas]
+
+* Make I18n::Backend::Simple reload its translations in development mode [DHH/Sven Fuchs]
+
+
*2.2.0 [RC1] (October 24th, 2008)*
* TimeWithZone#freeze: preload instance variables so that we can actually freeze [Geoff Buesing]
diff --git a/activesupport/lib/active_support/core_ext/array/conversions.rb b/activesupport/lib/active_support/core_ext/array/conversions.rb
index 11c128da22..cf3e03f62c 100644
--- a/activesupport/lib/active_support/core_ext/array/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/array/conversions.rb
@@ -172,7 +172,7 @@ module ActiveSupport #:nodoc:
else
xml.tag!(root, options[:skip_types] ? {} : {:type => "array"}) {
yield xml if block_given?
- each { |e| e.to_xml(opts.merge!({ :skip_instruct => true })) }
+ each { |e| e.to_xml(opts.merge({ :skip_instruct => true })) }
}
end
end
diff --git a/activesupport/lib/active_support/deprecation.rb b/activesupport/lib/active_support/deprecation.rb
index 950bca60a6..b4d8f61b8c 100644
--- a/activesupport/lib/active_support/deprecation.rb
+++ b/activesupport/lib/active_support/deprecation.rb
@@ -51,8 +51,8 @@ module ActiveSupport
private
def deprecation_message(callstack, message = nil)
- message ||= "You are using deprecated behavior which will be removed from Rails 2.0."
- "DEPRECATION WARNING: #{message} See http://www.rubyonrails.org/deprecation for details. #{deprecation_caller_message(callstack)}"
+ message ||= "You are using deprecated behavior which will be removed from the next major or minor release."
+ "DEPRECATION WARNING: #{message}. #{deprecation_caller_message(callstack)}"
end
def deprecation_caller_message(callstack)
diff --git a/activesupport/lib/active_support/string_inquirer.rb b/activesupport/lib/active_support/string_inquirer.rb
index cd722a3cfb..e6b1f39225 100644
--- a/activesupport/lib/active_support/string_inquirer.rb
+++ b/activesupport/lib/active_support/string_inquirer.rb
@@ -11,7 +11,7 @@ module ActiveSupport
#
class StringInquirer < String
def method_missing(method_name, *arguments)
- if method_name.to_s.ends_with?("?")
+ if method_name.to_s[-1,1] == "?"
self == method_name.to_s[0..-2]
else
super
diff --git a/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n.rb b/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n.rb
index 344c77aecf..40e82d8225 100755
--- a/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n.rb
+++ b/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n.rb
@@ -67,6 +67,13 @@ module I18n
def load_path=(load_path)
@@load_path = load_path
end
+
+ # Tells the backend to reload translations. Used in situations like the
+ # Rails development environment. Backends can implement whatever strategy
+ # is useful.
+ def reload!
+ backend.reload!
+ end
# Translates, pluralizes and interpolates a given key using a given locale,
# scope, and default, as well as interpolation values.
@@ -150,10 +157,10 @@ module I18n
# I18n.t [:foo, :bar], :scope => :baz
def translate(key, options = {})
locale = options.delete(:locale) || I18n.locale
- backend.translate locale, key, options
+ backend.translate(locale, key, options)
rescue I18n::ArgumentError => e
raise e if options[:raise]
- send @@exception_handler, e, locale, key, options
+ send(@@exception_handler, e, locale, key, options)
end
alias :t :translate
@@ -180,8 +187,8 @@ module I18n
# keys are Symbols.
def normalize_translation_keys(locale, key, scope)
keys = [locale] + Array(scope) + [key]
- keys = keys.map{|k| k.to_s.split(/\./) }
- keys.flatten.map{|k| k.to_sym}
+ keys = keys.map { |k| k.to_s.split(/\./) }
+ keys.flatten.map { |k| k.to_sym }
end
end
end \ No newline at end of file
diff --git a/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb b/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb
index 30e3655b7b..bdda55d3fe 100644
--- a/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb
+++ b/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb
@@ -10,7 +10,7 @@ module I18n
# plain Ruby (*.rb) or YAML files (*.yml). See #load_rb and #load_yml
# for details.
def load_translations(*filenames)
- filenames.each {|filename| load_file filename }
+ filenames.each { |filename| load_file(filename) }
end
# Stores translations for the given locale in memory.
@@ -23,12 +23,12 @@ module I18n
def translate(locale, key, options = {})
raise InvalidLocale.new(locale) if locale.nil?
- return key.map{|k| translate locale, k, options } if key.is_a? Array
+ return key.map { |k| translate(locale, k, options) } if key.is_a? Array
reserved = :scope, :default
count, scope, default = options.values_at(:count, *reserved)
options.delete(:default)
- values = options.reject{|name, value| reserved.include? name }
+ values = options.reject { |name, value| reserved.include?(name) }
entry = lookup(locale, key, scope)
if entry.nil?
@@ -37,8 +37,8 @@ module I18n
raise(I18n::MissingTranslationData.new(locale, key, options))
end
end
- entry = pluralize locale, entry, count
- entry = interpolate locale, entry, values
+ entry = pluralize(locale, entry, count)
+ entry = interpolate(locale, entry, values)
entry
end
@@ -69,8 +69,12 @@ module I18n
@initialized ||= false
end
- protected
+ def reload!
+ @initialized = false
+ @translations = nil
+ end
+ protected
def init_translations
load_translations(*I18n.load_path)
@initialized = true
@@ -88,7 +92,7 @@ module I18n
def lookup(locale, key, scope = [])
return unless key
init_translations unless initialized?
- keys = I18n.send :normalize_translation_keys, locale, key, scope
+ keys = I18n.send(:normalize_translation_keys, locale, key, scope)
keys.inject(translations) do |result, k|
if (x = result[k.to_sym]).nil?
return nil
@@ -170,21 +174,21 @@ module I18n
# for all other file extensions.
def load_file(filename)
type = File.extname(filename).tr('.', '').downcase
- raise UnknownFileType.new(type, filename) unless respond_to? :"load_#{type}"
+ raise UnknownFileType.new(type, filename) unless respond_to?(:"load_#{type}")
data = send :"load_#{type}", filename # TODO raise a meaningful exception if this does not yield a Hash
- data.each{|locale, d| merge_translations locale, d }
+ data.each { |locale, d| merge_translations(locale, d) }
end
# Loads a plain Ruby translations file. eval'ing the file must yield
# a Hash containing translation data with locales as toplevel keys.
def load_rb(filename)
- eval IO.read(filename), binding, filename
+ eval(IO.read(filename), binding, filename)
end
# Loads a YAML translations file. The data must have locales as
# toplevel keys.
def load_yml(filename)
- YAML::load IO.read(filename)
+ YAML::load(IO.read(filename))
end
# Deep merges the given translations hash with the existing translations
@@ -192,16 +196,16 @@ module I18n
def merge_translations(locale, data)
locale = locale.to_sym
translations[locale] ||= {}
- data = deep_symbolize_keys data
+ data = deep_symbolize_keys(data)
# deep_merge by Stefan Rusterholz, see http://www.ruby-forum.com/topic/142809
- merger = proc{|key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }
- translations[locale].merge! data, &merger
+ merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }
+ translations[locale].merge!(data, &merger)
end
# Return a new hash with all keys and nested keys converted to symbols.
def deep_symbolize_keys(hash)
- hash.inject({}){|result, (key, value)|
+ hash.inject({}) { |result, (key, value)|
value = deep_symbolize_keys(value) if value.is_a? Hash
result[(key.to_sym rescue key) || key] = value
result
@@ -209,4 +213,4 @@ module I18n
end
end
end
-end
+end \ No newline at end of file