Skip to content
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

#humanize does not handle "é" #50

Open
francois opened this issue Aug 5, 2024 · 1 comment · May be fixed by #51
Open

#humanize does not handle "é" #50

francois opened this issue Aug 5, 2024 · 1 comment · May be fixed by #51

Comments

@francois
Copy link

francois commented Aug 5, 2024

Describe the bug

inflector.humanize("éclaireurs")
#=> "éclaireurs"

The uppercase version "é" is "É". I expected to receive "Éclaireurs". This affects all characters I tried: ê, ï, à.

It could be argued that it isn't the job of the inflector to work in such cases, but the API is convenient :)

In the Hanami 2.2 app that I'm building, humans will record roles in a field. The roles may be typed in different casings, but I normalize to downcase for sorting, then humanize for display. I will add a #normalized_role to make things consistent, but having this in the inflector sure would have been nice.

To Reproduce

require 'bundler/inline'
gemfile do
  gem 'dry-inflector', '~> 1.0'
end

puts RUBY_VERSION

inflector = Dry::Inflector.new
actual = inflector.humanize('éclaireurs')
if actual == 'Éclaireurs'
  puts 'OK'
else
  p actual
  puts 'failed'
end

Expected behavior

"éclaireurs" #=> "Éclaireurs"

My environment

  • Affects my production application: YES, but not a biggie for now
  • Ruby version: 3.2.4
  • OS: Sonoma 14.5 (23F79)
@cllns
Copy link
Member

cllns commented Aug 6, 2024

I feel like this should be supported. Especially since "éclaireurs".capitalize returns "Éclaireurs".

I have some work on a local branch that fixes this, but now I'm going through and making sure all the inflectors work with words that have diacritics.

@cllns cllns linked a pull request Sep 9, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants