martinlindhe/laravel-vue-i18n-generator

Multiple name formation in a phrase

dobosiati opened this issue · 1 comments

When I use multiple connected replacement parameter in my laravel localisation files like this:

'image_size_between' => 'The size of this image must to be between :minWidthx:minHeight and :maxWidthx:maxHeight',

In a laravel balde the result of

@lang('validation.image_size_between', [
    'minWidth'  => 720,
    'minHeight' => 540,
    'maxWidth'  => 1920,
    'maxHeight' => 1200,
])"

is
The size of this image must to be between 720x540 and 1920x1200

I want to make a vue-i18n formation in a vue component but unfortunately this part of the vue-i18n-locales.generated.js file is
"image_size_between": "The size of this image must to be between {minWidthx}{minHeight} and {maxWidthx}{maxHeight}",

what is not good for me, because I need that x between those two parameters (an with space it looks ugly).

Is there any idea to solve this issue with this package?

I understand your issue, but I have no idea how this package could figure out the length of the variable names as used in your example as there is not enough information given in the translation source, since you are defining the variables in the blade view.

Unfortunately this is by design of how this package works, it only analyses your laravel translation files and ignores your blade views.
It extracts variable names from valid ASCII sequence following the : symbol.

You can solve the issue for example by using a non-ASCII character for the x, use one of these unicode forms: https://en.wikipedia.org/wiki/X_mark#Unicode

Or, you could break down the translation string into multiple parts.

I hope this helps, if not please add more comments to this issue.