Sophisticated, Lightweight and Simple

Jump to docs navigation
Edit on GitHub

Extending » Basics » Handling Translations

Translations can now be automatically included in your extension. This can be done by creating a new directory in the root folder of your extension called translations.

Place translation files in that folder with the following naming scheme en.yml or sv.yml. Then you can use the translations anywhere in your extension.

If you would like to use your translations in PHP, then you can do the following:

use Bolt\Translation\Translator as Trans;

class MyClass
    public function doThing()
        echo Trans::__('string to translate');

Or in Twig:

    {{ __('string to translate') }}

Couldn't find what you were looking for? We are happy to help you in the forum, on Slack or on IRC.
Spotted a typo, or have something to add? Edit this page on GitHub.