From bc9711fb7d6dd89094ccc9c8f3147bcf3ddd63bc Mon Sep 17 00:00:00 2001 From: Kaan Ozkan Date: Mon, 11 Mar 2019 11:44:28 -0400 Subject: Add locale option to parameterize Parameterize is triggering I18n#transliterate. This method already accepts a locale. It would be cleaner if similar to other string inflection methods #parameterize also accepted 'locale' as a parameter. --- activesupport/lib/active_support/core_ext/string/inflections.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'activesupport/lib/active_support/core_ext') diff --git a/activesupport/lib/active_support/core_ext/string/inflections.rb b/activesupport/lib/active_support/core_ext/string/inflections.rb index 8af301734a..e63b38b227 100644 --- a/activesupport/lib/active_support/core_ext/string/inflections.rb +++ b/activesupport/lib/active_support/core_ext/string/inflections.rb @@ -162,6 +162,11 @@ class String # Replaces special characters in a string so that it may be used as part of a 'pretty' URL. # + # If the optional parameter +locale+ is specified, + # the word will be parameterized as a word of that language. + # By default, this parameter is set to nil and it will use + # configured I18n.locale + # # class Person # def to_param # "#{id}-#{name.parameterize}" @@ -187,8 +192,8 @@ class String # # <%= link_to(@person.name, person_path) %> # # => Donald E. Knuth - def parameterize(separator: "-", preserve_case: false) - ActiveSupport::Inflector.parameterize(self, separator: separator, preserve_case: preserve_case) + def parameterize(separator: "-", preserve_case: false, locale: nil) + ActiveSupport::Inflector.parameterize(self, separator: separator, preserve_case: preserve_case, locale: locale) end # Creates the name of a table like Rails does for models to table names. This method -- cgit v1.2.3