Closed kskrlinnorth2 closed 1 year ago
are you using the vite plugin to import the php
translations?
This is my vite config
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import i18n from "laravel-vue-i18n/vite";
import laravel from "laravel-vite-plugin";
export default defineConfig({
plugins: [
laravel({
input: ["resources/css/datepicker.scss", "resources/js/app.js"],
ssr: "resources/js/ssr.js",
refresh: true,
}),
vue({
template: {
transformAssetUrls: {
base: null,
includeAbsolute: false,
},
},
}),
i18n(),
],
ssr: {
noExternal: ["@inertiajs/server"],
},
});
humm can you try to use wTrans
instead?
It works, but it outputs my translations with extra double quotes around it.
<li v-for="item in settingsNav" :key="item.name">{{ item.name }}</li>
Gives me this output with quotes visible:
"Some value"
<li v-for="item in settingsNav" :key="item.name">{{ item.name.value }}</li>
Gives me output without quotes
My workaround was not to use trans and instead just pass translation key and in my template just output it with $t(item.name)
which would return correct translation (without quotes) and without need of extra value call.
yes that's the way to go, and the way this package was designed to work.
Thanks for the feedback @kskrlinnorth2
We used this package in previous project, but there we used json translations. It turned out it wasn't easy to maintain or organize so we switched to only php translations for next project. However the trans() method doesn't return translated string, only key,
When using trans and $t in template for same translation key, it works.
Using L10 with Inertia and vue3.
app.js![image](https://user-images.githubusercontent.com/61736280/222399392-a1289712-5e3d-4934-9220-2ddb1ac25193.png)
lang/en/app.php translations![image](https://user-images.githubusercontent.com/61736280/222399717-486f8d17-44b2-406d-9fce-d9d8d93938de.png)
some code that uses those translations![image](https://user-images.githubusercontent.com/61736280/222400015-d091369b-4488-4bdd-9be6-b3d65f6f9d2f.png)
All i get when I output name, description and btnLabel from settingsNav are translation keys.
Code is inside persistent layout under script setup.
Is there any workaround, other than sending my settingsNav as prop from Laravel controller?