xiCO2k / laravel-vue-i18n

Allows to connect your `Laravel` Framework translation files with `Vue`.
MIT License
594 stars 49 forks source link

Feature request default tChoice number to 1 #113

Closed timyourivh closed 1 year ago

timyourivh commented 1 year ago

The problem

When I use

tChoice('foo') // Without second param

It throws an error:

image

And causes my app to not render the view.

The solution

It would be great to prevent this error and have the number param default to 1 if nothing is defined. Or be able to use t('foo') which would then pick the first one. (my preference)

Nice to haves

Support for negative and zero. It now picks the last unless specifically defined with brackets. For example:

{
  "foo": "foo|foos",
  "bar": "{*,1}bar|bars",
}
tChoice('foo', -1) // Expected: "foo". Outputs: "foos".
tChoice('foo', 0)  // Expected: "foo". Outputs: "foos".

tChoice('bar', -1) // Expected: "bar". Outputs: "bar".
tChoice('bar', 0)  // Expected: "bar". Outputs: "bar".
xiCO2k commented 1 year ago

Hey @timyourivh will check that out.