Revision: Thu, 18 Apr 2024 09:24:14 GMT
v2.14 – outdated
This version of the documentation is outdated. Consider upgrading your project to Spiral Framework 3.12
Edit this page

Internalization - View Localization

The Spiral Framework includes the view process available for Twig and Stempler engines to translate view source code. The translated view will be stored in a separate view cache and provides the ability to translate views without the performance penalty.

View Translation

To activate view translation enable bootloader Spiral\Bootloader\Views\TranslatedCacheBootloader. Make sure to add this bootloader before view engine bootloaders:

php
protected const LOAD = [
    // ...
    Framework\Views\ViewsBootloader::class,
    Framework\Views\TranslatedCacheBootloader::class,
    // ...
];

Embrace the string to be translated with [[ string ]] in your template:

html
[[hello world]]

Note
Change the locale in your application to switch translation in view.