The application can be managed multilingual. The translation of your admin panel can
be done in php
using
laravel's localization service or
in vue
using
vue-i18n. It uses the
laravel syntax for translation string. All translation strings are formatted so they can be used
in vue-i18n
as well.
In Laravel applications that include the litstack package, there are two different locales, one for your website and one for the admin application. So for example, a user can manage german content in the admin application and still see the interface in the english version.
The following examples refer to the translations which look like this:
Translations of the admin panel are managed in the litstack/lang repository, if it doesn't contain your language, you are welcome to contribute. The languages in which your admin panel should be translatable can be specified in the lit.translatable
config.
You can configure the translatability of your app in the config/translatable.php
config.
If more than one locale is specified, form fields can be edited in multiple languages.
To translate your admin panel using the locale of the authenticated litstack user, the __lit()
helper method is
used, just like __()
from laravel's
localization.
__lit('messages.welcome', ['name', 'Jannes'])
Pluralization can be used with the __lit_choice
function or the short version
__lit_c
.
'apples' => '{0} There are none|[1,19] There are some|[20,*] There are many',
...
__lit_choice('apples', 10)
__lit_c('apples', 10)
In Vue
the vue-i18n
format is used.
<template>
<div>
{{ $t('messages.welcome', { name: 'Jannes' }) }}
</div>
</template>
You may also use the Larvel localization helpers in Vue components.
To determine the locale the function getLocale
can be used on the Lit
facade
like this:
use Ignite\Support\Facades\Lit;
$litLocale = Lit::getLocale();
if (Lit::isLocale('en')) {
//
}
By default the path lit/resources/lang
is imported for the admin translation.
You can register any number of paths with localization files in your service
providers. However, it is recommended to keep the translations for the admin
application and your website separate.
use Ignite\Support\Facades\Lang;
Lang::addPath(base_path('yourpath/lang/'));
All translation attributes are merged, which makes it easy to extend existing localizations for parts like validation or others.