Hi @alex. I've been following your different inertia courses over the last bit and I have to say that I enjoy Inertia more than Livewire and Alpine. I've been a Codecourse follower for years and years since the early YouTube days, and your videos are some of the best out there when it comes to all things PHP :)
Anyways, to the point. In your translations with inertia course, you say that the code in lang.js covers about 80% of all usecases. well, one of the cases it doesn't seem to cover is translating validations and pagination links and some other translations.
At first I thought it was some weird caching issue, but now I'm not so sure. I have 4 languages, English, Norwegian, German and Spanish, and only the English version of validation and pagination translations are shown. That is no matter what language is set to default in config/app nor chosen in selectbox. I've tried php artisan optimize:clear
and changing caching methods with no luck. I can even delete the validation.php
file, or change it's contents, and it still will output the default english validation errors and such. In my contact form I get The name field is required.
when english is selected, with all other languages I get validation.required
in stead.
What am I missing? can you replicate the problem with your code? Every other translations I've made are working as expected.
Another problem is that I can't translate inside controllers. This might be a separate issue, and I don't know if it can be done with inertia at all. For example return redirect()->back()->with('success', __('contact.the message has been sent'));
wont be translated when I flash the message on the frontend. Any suggestions here?
Best Regards
Nony
Hello @Nony,
If you are using custom keys for validation messages, you will need to override the defaults.
Customizing The Error Messages
Custom Messages For Specific Attributes
As for your other issue, are you sure that key exists?
Perhaps you could share more code so we can help you better.