johannschopplich / kirby-vue3-starterkit

✨ Kirby + Vue SPA starter: automatic routing, i18n, SEO and more!
MIT License
206 stars 19 forks source link

Custom language variables best practice #58

Closed leawinleawin closed 1 year ago

leawinleawin commented 1 year ago

Hi,

This is maybe more of a question than an issue. I would like to use custom language variables for certain buttons etc. Unfortunately, translations specified in the e.g./languages/en.php file are not contained in the site.languages object. In the kirby docs it says there is the t('...') helper function for multi-language setups to access these variables. Did you implement something similiar yet for this version of the starterkit? Or can you recommend an approach/a best practice to do so?

Thank you!

johannschopplich commented 1 year ago

Hey there, glad to see you're using this setup. Unfortunately, I'm not actively maintaining it anymore (especially the multi-language setup). I have evolved it into my headless Kirby and Nuxt starter for better SEO etc. Feel free to look into that, it also covers all of your i18n needs.

The Kirby helpers aren't available inside the Vue instance. You will have to load the languages into the site object:

'languages' => kirby()
    ->languages()
    ->toArray(),

But this won't include translations. I'd recommend the vue-i18n library, which includes a t() translation helper and lets you add translation messages in the Vue part of your app.