Code Monkey home page Code Monkey logo

Comments (6)

aesmail avatar aesmail commented on July 17, 2024

It's worth mentioning that Kaffy has the plural_name admin function to customize the plural form of any schema.

Having said that, I think Kaffy could be smarter in dealing with plural names out of the box.

Alternatively, since the package is licensed on MIT, perhaps a large part of it could be just pulled into Kaffy, without reinventing the wheel.

This would be my preference if we're going that route.

Please feel free to submit a PR for this 🙏🏻.

Maybe we should also consider more options and use cases.

from kaffy.

aesmail avatar aesmail commented on July 17, 2024

inflex seems to be the most popular and still maintained.

I'm still not sure whether it's a good idea to bring an additional dependency just so we can have better support for inflections.

Still up for discussion though.

from kaffy.

katafrakt avatar katafrakt commented on July 17, 2024

Oh, didn't know about inflex. Nice. However, I too think that pulling it as a dependency would be too much. As such, I see following options:

1. Optional support for inflex

With something like:

plural = 
  if Code.ensure_loaded?(Inflex) do
    Inflex.pluralize(term)
  else
    fallback_pluralize(term)
  end

In my experience, this works, however is very tricky to test both paths - with and without Inflex module present.

2. Support inflex via config

config :kaffy, inflector: Inflex

# and then

inflector = Application.get_env(:kaffy, :inflector, Kaffy.Inflector)
inflector.pluralize(term)

3. Not support it at all, relying on a built-in Kaffy inflector

If Kaffy should have its own inflector, again - two options:

  • Pull in something almost complete, like inflectorex or inflex and have to support this code (not sure if I'm comfortable with that, seems a bit complex)
  • Build something much simpler, incomplete by design, but still covering much more cases that just appending s.

from kaffy.

aesmail avatar aesmail commented on July 17, 2024

I think we could combine 2 things:

  • Support inflex via config.
  • Build something much simpler, incomplete by design, but still covering much more cases that just appending s.

I like the idea of supporting an inflection package via config because this could potentially be beneficial for other languages as well in the future.

from kaffy.

katafrakt avatar katafrakt commented on July 17, 2024

Sounds good. I'll try to create a PR soon.

from kaffy.

aesmail avatar aesmail commented on July 17, 2024

Closing this issue as #233 has been merged

from kaffy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.