evo-mark / inertia-i18n
Inertia项目的国际化支持
v1.0.1
2024-05-10 03:52 UTC
Requires (Dev)
- orchestra/testbench: ^8.19
README
Inertia I18n
安装
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); }, });
使用
安装后,您可以使用前端本地化包如常使用
<template> <div>{{ $t('messages.hello_world') }}</div> </template>
或者
<script setup> import { useI18n } from 'vue-i18n'; const { t } = useI18n(); const translated = computed(() => t('message.hello_world)); </script>
查看相应前端包的文档以获取更多信息
Vue: vue-i18n