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

Incorrect inflection when using an underscored '_fee' or 'taxes' #52

Open
mrship opened this issue Sep 25, 2024 · 0 comments
Open

Incorrect inflection when using an underscored '_fee' or 'taxes' #52

mrship opened this issue Sep 25, 2024 · 0 comments

Comments

@mrship
Copy link

mrship commented Sep 25, 2024

Describe the bug

  • When using pluralize for things like property_fee you get property_ves.
  • When singularising taxes you get taxis

To Reproduce

#!/usr/bin/env ruby

require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'
  ruby '3.3.4'

  gem 'dry-inflector'
end

require 'dry-inflector'

inflector = Dry::Inflector.new

puts "**** Incorrect inflection"

puts "pluralize: 'payment_provider_fee' => #{inflector.pluralize("payment_provider_fee")}"
puts "pluralize: 'payment_fee' => #{inflector.pluralize("payment_fee")}"
puts "pluralize: 'property_fee' => #{inflector.pluralize("property_fee")}"
puts "singularize: 'taxes' => #{inflector.singularize("taxes")}"

puts "**** Corrected inflection"

fixed = Dry::Inflector.new do |i|
  i.plural("payment_provider_fee", "payment_provider_fees")
  i.plural("payment_fee", "payment_fees")
  i.plural("property_fee", "property_fees")
  i.singular("taxes", "tax")
end

puts "pluralize: 'payment_provider_fee' => #{fixed.pluralize("payment_provider_fee")}"
puts "pluralize: 'payment_fee' => #{fixed.pluralize("payment_fee")}"
puts "pluralize: 'property_fee' => #{fixed.pluralize("property_fee")}"
puts "singularize: 'taxes' => #{fixed.singularize("taxes")}"

Expected behavior

  • That a something_fee is pluralised as something_fees
  • That taxes is singularised as tax, not taxis

My environment

  • Affects my production application: YES (although we can workaround it)
  • Ruby version: 3.3.4
  • OS: macOS/Ubuntu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant