API (Vue)
VueTolgee
plugin
VueTolgee
plugin attaches tolgee to Vue instance. That mean, that you can use global
$t
function in any vue component.
import { VueTolgee } from '@tolgee/vue';
...
app.use(VueTolgee, { tolgee });
...
<div>
{{ $t('key', 'Default value') }}
</div>
Check
tolgee.tfunction interface.
It's also possible to use Tolgee without
VueTolgee
. Then you can use just
TolgeeProvider
and
useTranslate
for translating.
TolgeeProvider
Provides Tolgee context. Use in root of your application.
import { TolgeeProvider } from '@tolgee/vue';
...
<TolgeeProvider>
<App />
</TolgeeProvider>
Prop
fallback?
String | JSX.Element
- it is rendered when Tolgee is loading translations instead of provided content.
You can pass custom loading element when using Vue with JSX.
Prop
tolgee?
Optionally provide tolgee instance. If you use
VueTolgee
, it's not necessary.
Slot
fallback
Alternative for
fallback
use when you are using Vue with templates:
<TolgeeProvider>
<App />
<template v-slot:fallback>
<div>Loading...</div>
</template>
</TolgeeProvider>
T
component
import { T } from '@tolgee/vue';
<T keyName="..." :params="{ param: '...' }" />
Prop
keyName
String
- translation key.
Prop
defaultValue?
String
- You can pass default value, which will be rendered if there is no translation