Edit on GitHub
Jump to docs navigation

Extending / Basics / Handling Translations

Note: You are currently reading the documentation for Bolt 3.1. Looking for the documentation for Bolt 3.5 instead?

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') }}
Edit this page on GitHub
Couldn't find what you were looking for? We are happy to help you in the forum, on Slack or on IRC.