xiCO2k / laravel-vue-i18n

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

Register globally to use within script tags #77

Closed robinvoor closed 1 year ago

robinvoor commented 1 year ago

Hi,

I noticed issue #28 - I was wondering if this is possible to register anything globally though. So instead of having to import trans each time (with import { trans } from "laravel-vue-i18n"), just use trans or $t or whatever immediately within the script tags like the following:

<script setup>
const someTranslation = $t('global.something'); // like in <template>
// or
const someTranslation = trans('global.something');
</script>
xiCO2k commented 1 year ago

Hey @robinvoor you can make it available globally by using:

import { trans } from "laravel-vue-i18n"

window.trans = trans;

No plans to add that to the plugin.

Thanks, Francisco