config/admin.php and how to use them.
Enabling localization
If the application needs multiple language versions, switch the parameter totrue. Then run the database migration, which creates the languages table and adds the language management module to the administration.
config/admin.php
The first language added in the administration becomes the default one.
Forced redirect to the default language
To redirect to the default language version automatically, add the global middleware toapp/Http/Kernel.php.
app/Http/Kernel.php
http://example.com/ redirects to http://example.com/sk.
With localization active, every route is redirected to the address carrying the language code — http://example.com/articles redirects to http://example.com/sk/articles.
Disabling the forced redirect
The forced redirect can be turned off. On the default language version, every URL is then available without the language code.config/admin.php
With this parameter, content on the default language is available only without the language code —
http://example.com/articles instead of http://example.com/sk/articles.Gettext — translating static texts
Together with the Gettext extension, CrudAdmin collects every static source text in the application and makes it translatable as .po files for PoEdit, or through the online editor in the administration.Enabling Gettext
Enable the extension inconfig/admin.php.
config/admin.php
@gettext blade directive handles it — place it in the main layout as the first script in the order. The system injects the translation libraries and caches them.
resources/views/layout.blade.php
this constructor of every component.
resources/js/app.js
CrudAdmin scans the directories where translatable files may live and reloads every source text on change. The scanned paths are defined in the advanced configuration and can be overridden with your own list.
Writing translations in the application
For translations to be picked up, static texts have to be written in the right form. The examples below cover both singular and plural.PHP files
PHP files follow the standard functions from the PHP documentation.Blade files
Blade files are translated the same way as plain PHP.JavaScript files
CrudAdmin reads translations from JavaScript files as well, through the methods of the injected library.Vue components
Vue components use the same JavaScript functions. They are bound into every component, so they are available globally as well as in thethis constructor.
Managing the translations
The generated interface for uploading files from PoEdit:


Translating dynamic content
Once language versions and static text translations are set up, the interface for translating the dynamic content stored in the database can be generated too.Unique records per language
- A relation between the model and the
languagestable is created automatically. - Each language version holds its own records.
- The language is switched under the administrator profile photo, or in the form of the module. Switching it lists the records of the selected language.


The language can only be switched in a module that supports language versions.
$localization property.
app/Article.php
localization() local scope.
app/Http/Controllers/ArticleController.php
Mirrored content
With mirrored content the record exists once in the database, but each language version holds a different value in the column. Enable it with thelocale parameter on the field you want to translate.
A translated field switches its column type to JSON, holding the values of every language version.