evo-mark/inertia-i18n

Internationalisation support for Inertia projects

Installs: 26

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Language:JavaScript

v1.0.1 2024-05-10 03:52 UTC

This package is auto-updated.

Last update: 2024-05-10 03:55:00 UTC


README

evoMark company logo

Build status Total Downloads License

Inertia I18n

Installation

composer require evo-mark/inertia-i18n
npm install ./vendor/evo-mark/inertia-i18n
--
pnpm add ./vendor/evo-mark/inertia-i18n
import InertiaI18n from "inertia-i18n/vite";

export default {
  plugins: [InertiaI18n()],
};
import useInertiaI18nVue from "inertia-i18n/vue";

createInertiaApp({
  setup({ el, App, props, plugin }) {
    const inertiaI18nPlugin = useInertiaI18nVue(props);

    createSSRApp({ render: () => h(App, props) })
      .use(plugin)
      .use(inertiaI18nPlugin)
      .mount(el);
  },
});

Usage

After installation, you can use your frontend localisation package as usual:

<template>
    <div>{{ $t('messages.hello_world') }}</div>
</template>

OR

<script setup>
import { useI18n } from 'vue-i18n';

const { t } = useI18n();
const translated = computed(() => t('message.hello_world));
</script>

See the documentation for the respective frontend packages for more information:

Vue: vue-i18n