From c7fc843431ffd2b775cc798d4c2c844fee3c9958 Mon Sep 17 00:00:00 2001 From: Eito Katagiri Date: Sat, 12 Oct 2013 20:47:57 +0900 Subject: fix pluralize behavior for words that consist of non-ascii characters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The code below returns "猫" in 3.2, but "猫s" in 4.0. ```ruby ActiveSupport::Inflector.inflections do |inflect| inflect.uncountable "猫" end "猫".pluralize ``` --- activesupport/lib/active_support/inflector/methods.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/inflector/methods.rb b/activesupport/lib/active_support/inflector/methods.rb index be369d21c6..cb36a16a51 100644 --- a/activesupport/lib/active_support/inflector/methods.rb +++ b/activesupport/lib/active_support/inflector/methods.rb @@ -372,7 +372,7 @@ module ActiveSupport def apply_inflections(word, rules) result = word.to_s.dup - if word.empty? || inflections.uncountables.include?(result.downcase[/\b\w+\Z/]) + if word.empty? || inflections.uncountables.include?(result.downcase[/\b\p{Word}+\Z/]) result else rules.each { |(rule, replacement)| break if result.sub!(rule, replacement) } -- cgit v1.2.3