Devisto supports multilingualism out of the box. Go to Settings → Languages to define the languages of your project.
When you create a new language, you have to choose an official language from a predefined list. Why? Because the language you choose has several consequences:
- The language on the
<html>tag and in the
- The default validation messages when you're building forms with validation.
- Using Faker, when seeding a table or by using the
faker()helper in your code.
- When translating values with Google from one language to another.
In all these cases, Devisto needs to know what official language it's dealing with, so everything works and translates as expected.
Be careful when you choose a slug for your new language, because the slug of an existent language can never be changed. The reason is that all translated data is saved in the database using the language slugs.
Languages In Code
Devisto provides some helpers to access the languages:
// Get all languages (returns a collection) $languages = languages(); // Get the current language $current = language(); // Get a language by slug $english = language('en'); // Properties language()->name; language()->slug; // Helper methods language()->url(); language()->active();
Take a look at the snippet Language Navigation for a complete example.