xiCO2k / laravel-vue-i18n

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

Validation error messages received without being translated #175

Closed zacktagnan closed 1 month ago

zacktagnan commented 4 months ago

Congratulations on the plugin. Changing the language of texts set in Vue files is satisfactory.

However, I have to notify that when error validation messages are received on a form, they still arrive in the default language set by the "APP_LOCALE" environment variable of the ".env" file since version 11 of Laravel (the default value of this environment variable is "es", so Spanish). Even if the language is changed thanks to the switcher established to make that language change. For example, if I change the language to English with this switcher, I still received the validation error messages in Spanish and not in English.

And maybe, if this happens with the validation messages, the same thing may happen with the translation messages of the "auth" or "password" files, for example.

Indicate that, in the project in which I have installed the package, the ARRAY of validation errors is received within the Pinia Store implemented from the Backend part. Therefore, the text should be translated, I believe. Or I do not know.

Without having a solution to what I am notifying, for the moment, instead of displaying the error message corresponding to the validation rule not met by the form field, I display a generic message for that form field. And that is the one that I can translate through the plugin.

Greetings.

xiCO2k commented 3 months ago

Hey @zacktagnan thanks for the full description, is it possible for you to create a public repo with that exact case for me to debug?

Thanks

zacktagnan commented 3 months ago

Hey @zacktagnan thanks for the full description, is it possible for you to create a public repo with that exact case for me to debug?

Thanks

Through the link provided in my previous comment (again, project), you will be able to access the repository in which, as I mentioned, I installed your package and where you can clone and reproduce the case that I indicated. It is already a public repo, of course. Is that worth it to you?

Regards.

anttihyry commented 1 month ago

Hi @xiCO2k .. is this issue progressed? Is it possible to change Laravel backend locale when changing locale from frontend with loadLanguageAsync function?

xiCO2k commented 1 month ago

hey @zacktagnan I did clone and did the npm run build and everything seems to be working correctly, I did both APP_LOCALE=en and APP_LOCALE=es and all seemed to work properly.

zacktagnan commented 1 month ago

hey @zacktagnan I did clone and did the npm run build and everything seems to be working correctly, I did both APP_LOCALE=en and APP_LOCALE=es and all seemed to work properly.

So, is not enough to run "npm run dev" with Vite to have all the translations on local? It is necessary to run the "build" command, even on local development?

xiCO2k commented 1 month ago

should be good just with npm run dev just tried.

zacktagnan commented 1 month ago

I 'll take a look. Now, imposible (maybe tomorrow). And let you know as soon as possible.

zacktagnan commented 1 month ago

Hola Francisco: Acabo de ejecutar el proyecto en el que apliqué tu plugin y los mensajes de validación que vienen desde el Backend, ahora mismo, si que aparecen traducidos en el idioma que está activo en el sitio web (en este proyecto, tanto en inglés, como en castellano). Tras tanto tiempo desde que puse mi comentario, puede que no recuerde bien qué pasaba. Pero, al menos, por el momento, los mensajes de validación de errores en formularios aparecen traducidos en las vistas de Vue aunque, cuando creé mi entrada inicial no parecía que se tradujera como es debido. Sea como sea, gracias por tu atención. Y, si me vuelve a pasar, trataré de ser más detallado respecto a la incidencia sufrida. Saludos.

xiCO2k commented 1 month ago

Awesome, Saludos!!