0

When using str_singular() function in Laravel to get a singular form of word 'leaves' it returning 'leaf'.

However I need to get 'leave' word, like in 'leave of absence'.

thisiskelvin
  • 4,136
  • 1
  • 10
  • 17
Mhmoud
  • 85
  • 1
  • 8
  • 1
    Laravel uses doctrine/inflector for singular/plural inflection. As far as I'm aware there's no way for it to natively distinguish between homographs, so you would need to define your own exception cases. – padarom Oct 15 '18 at 09:21
  • As @Padarom mentioned, why not just make an exception if this is the only case you need it for? – thisiskelvin Oct 15 '18 at 09:49
  • I did it explicitly as an exception but, thought there was a solution in these cases – Mhmoud Oct 15 '18 at 10:21
  • 1
    doctrine/inflector in itself is a piece of marvel my friend. I use it often in my works. Your request is so advanced even an AI has trouble with it. Google can provide understandable translations, but can't singular/plural a sentence. If sentences are predictable, you could make use of laravel's localization -> pluralization functionality. That's as close as it could possibly bring you. – Dimitri Mostrey Oct 15 '18 at 11:07

0 Answers0