Laravel Vue i18n is a package by Francisco Madeira that allows you to connect your Laravel translation files with Vue projects:
This package uses the same logic as the built-in localization features:
1<h1>{{ $t('Welcome :name!', { name: 'Francisco' }) }}. </h1>2<div>3 Logged in {{ $tChoice('{1} :count minute ago|[2,*] :count minutes ago', 10) }}4</div>
Here are a few more examples of the package's API from the readme:
1/* 2// lang/pt.json 3{ 4 "Welcome!": "Bem-vindo!", 5 "Welcome, :name!": "Bem-vindo, :name!", 6 "There is one apple|There are many apples": "Existe uma maça|Existe muitas maças", 7 "{0} There are none|[1,19] There are some|[20,*] There are many": "Não tem|Tem algumas|Tem muitas", 8 "{1} :count minute ago|[2,*] :count minutes ago": "{1} há :count minuto|[2,*] há :count minutos", 9}10*/11 12import { trans } from 'laravel-vue-i18n';13 14trans('Welcome!'); // Bem-vindo!15trans('Welcome, :name!', { name: 'Francisco' }) // Bem-vindo Francisco!16trans('Welcome, :NAME!', { name: 'Francisco' }) // Bem-vindo FRANCISCO!17 18transChoice('There is one apple|There are many apples', 1); // Existe uma maça19transChoice('{0} There are none|[1,19] There are some|[20,*] There are many', 19); // Tem algumas20transChoice('{1} :count minute ago|[2,*] :count minutes ago', 10); // Há 10 minutos.
This package allows you to change the locale at runtime via the loadLanguageAsync()
function. You can learn more about this package, get full installation instructions, and view the source code on GitHub.
0 comments:
Post a Comment
Thanks