vanguard-translate
v0.2.0
Published
A Vue 3 plugin to provide backend-defined translations for your Inertia app.
Downloads
7
Maintainers
Readme
Vanguard Translate Client
Vanguard Translate is a simple wrapping for dot notation on objects from Inertia JS props. When combined with the companion package it can be used to pass translations to the client side without any configuration, in the same way you would a blade.php template.
This package is built for use with Inertia JS and Vue 3.
Installation
The package can be installed using any of the common package managers.
npm i vanguard-translateUsage
Inside a .vue file, you can import the composable and use it to access translations from the server side.
<script setup>
import useTranslate from 'vanguard-translate'
const props = defineProps(['translations'])
const __ = useTranslate(props.translations)
</script>
<template>
{{ __('auth.login.label') }}
</template>If you do not pass the composable any arguments, it will resolve to use a translations prop by default. If neither is find, it will throw an error.
This behaviour allows the composable to be defined at a global scope, so you don't need to pass the translations prop to every component.
Licnese
The MIT License (MIT). Please see License File for more information.
