Reload Ziggy @routes via Inertia links without reloading page? #465
-
Hey there.
I use
Also on front-end I use
When I reload the page via Inertia link with new locale I can see, that interface is translated, BUT if I press some button or link, that uses
Only If I press F5 (full page reloading), then If instead on Inertia links I use simple My custom
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Try something like this: #463 (comment) You may need to move your Ziggy routes into Inertia's shared data so they get reloaded on every request. |
Beta Was this translation helpful? Give feedback.
-
This is my app.js |
Beta Was this translation helpful? Give feedback.
-
I found a solution to my own problem. I don't know if I'm doing it right but it worked for me. @maxonfjvipon @bakerkretzmar app.js createInertiaApp({
title: (title) => ` ${title} - ${appName} `,
resolve: (name) => resolvePageComponent(`./Pages/${name}.vue`, import.meta.glob('./Pages/**/*.vue')),
setup({ el, app, props, plugin }) {
const captcheKey = props.initialPage.props.recaptcha_site_key;
const application = createApp({ render: () => h(app, props) })
.use(plugin)
.use(VueReCaptcha, { siteKey: captcheKey })
.component('Head', Head)
.component('Link', Link)
.component('Icon', Icon)
.mixin({
methods: {
// added here
changeLocale: function (locale) {
Ziggy.defaults = {
locale: locale,
};
},
}
})
.use(i18nVue, {
resolve: async lang => {
const langs = import.meta.glob('../../lang/*.json');
return await langs[`../../lang/${lang}.json`]();
}
})
.use(ZiggyVue, Ziggy);
application.mount(el);
return application;
},
}); Layout.vue <script>
import { defineComponent } from "vue";
import { loadLanguageAsync } from "laravel-vue-i18n";
export default defineComponent({
data() {},
created() {
loadLanguageAsync(this.$page.props.locale.locale);
// added here
this.changeLocale(this.$page.props.locale.locale);
},
...
<script> |
Beta Was this translation helpful? Give feedback.
Try something like this: #463 (comment)
You may need to move your Ziggy routes into Inertia's shared data so they get reloaded on every request.