aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/string/inflections.rb
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2019-03-11 13:38:39 -0400
committerGitHub <noreply@github.com>2019-03-11 13:38:39 -0400
commit878e98091d93603e07620ca9177f58a880ab9cb8 (patch)
treec30bbdfe26c6857d194debb75eb8851986f237cf /activesupport/lib/active_support/core_ext/string/inflections.rb
parentf1b8bb4e1f16e4029ddf05515db0c01942521116 (diff)
parentbc9711fb7d6dd89094ccc9c8f3147bcf3ddd63bc (diff)
downloadrails-878e98091d93603e07620ca9177f58a880ab9cb8.tar.gz
rails-878e98091d93603e07620ca9177f58a880ab9cb8.tar.bz2
rails-878e98091d93603e07620ca9177f58a880ab9cb8.zip
Merge pull request #35571 from KaanOzkan/ko-parameterize-locale
Add locale option to #parameterize
Diffstat (limited to 'activesupport/lib/active_support/core_ext/string/inflections.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/string/inflections.rb9
1 files changed, 7 insertions, 2 deletions
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 <tt>nil</tt> 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) %>
# # => <a href="/person/1-Donald-E-Knuth">Donald E. Knuth</a>
- 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