Vanguard utilizes Laravel's default localization mechanism to allow you to translate it into any language you want. All translation files are located inside resources/lang
folder. Within this directory there should be a subdirectory for each language supported by the application:
/resources
/lang
/en
app.php
/es
app.php
Available Locales
Out of the box, you can switch among the following locales:
- English
- Serbian Latin
- German
More locales will be added in the future.
Translating Vanguard
If you want to translate the Vanguard application, all you need to do is to create a subfolder inside resources/lang
directory that matches your locale, copy the files from the existing locale (en
for example), and translate them into your language.
Note! Vanguard specific file is app.php
. All other files are Laravel's default localization files, and there is a big chance that someone has already translated those files for you. Check it out here.
For example, if we want to translate Vanguard to Russian, we will do the following:
-
Create a new folder inside
resources/lang
calledru
. -
Copy the
app.php
files fromresources/lang/en
to your newly createdru
folder. -
Translate the copied file to Russian.
- Download Laravel's default translation files for the Russian language from here and put them inside your newly created
ru
folder.
Enabling a New Application Locale
Now, when you have your translations ready, you just need to update the app/Support/Locale.php file and add the new translation.
For example, if we want to set our language to Russian, we would set that variable as follows:
//... public const AVAILABLE_LOCALES = ['en', 'de', 'sr', 'ru'];
public static function flagUrl(string $locale): ?string
{
return match ($locale) {
'en' => url('/flags/GB.png'),
'de' => url('/flags/DE.png'),
'sr' => url('/flags/RS.png'), 'ru' => url('/flags/RU.png'),
default => null,
};
} //...
After this, a new locale will show up in the language dropdown and you will be able to switch to it right away.