New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add String#downcase_first method #45827
Conversation
I didn't see any mention of |
Can you share a real-world use case for this method? |
We wanted to prepend verbiage to a standard message in some cases but not others. Our standard message includes several interpolations, and we wanted to keep things DRY while not introducing a variable in haml and (for better or worse) not creating a helper method. For example: en.yml
500 page:
403 page:
While there are other, arguably better, ways of implementing something like this, #downcase_first would have been convenient. The comment examples for #upcase_first indicate that the method was introduced for convenience in adjusting verbiage, and in our case, we wanted the same convenience in the opposite direction. |
110214d
to
c406d8d
Compare
For what it's worth, it's generally not a good idea to concatenate strings for I18n. In lot of languages |
c406d8d
to
2c209ff
Compare
2c209ff
to
f16a365
Compare
Let's add that. |
Rails 5 added String#upcase_first, which converts the first letter of a string to uppercase (returning a duplicate). This commit adds the corollary method, converting the first letter to lowercase.
f16a365
to
69b550f
Compare
Added. |
Rails 5 added String#upcase_first, which converts the first letter of a
string to uppercase (returning a duplicate). This commit adds the
corollary method, converting the first letter to lowercase.
Summary
This adds
String#downcasecase_first
method viaActiveSupport::Inflector
, whichis how
String#upcase_first
was added.