How to change or add missing translations for Flarum

Translations for Flarum are managed by language packs, which are simple extensions providing translations strings. Usually installing language pack is enough – your forum instance should be available in your favorite language. But what if you don’t like some translations? Or language pack does not support one of used extensions? Creating your own language pack just for your forum may be an overkill, especially if you don’t want to translate extensions and just want to see untranslated description instead of ugly placeholders.

Translation keys instead of untranslated source
This is what you see in case of missing translations

Fortunately, there is a better solution – you can define translations directly in your forum instance. First, you should create a directory for translation files and YAML file for your translations for a specific locale (for example in locale/pl.yml for Polish translations). The directory structure of your forum should look similar to this:

Then in extend.php register translations using Flarum\Extend\Locales:

After this you should be able to add new and overwrite existing translations by defining them in yml files inside of locale directory. Don’t forget to clear cache after every change.

 

Leave a Reply

Your email address will not be published. Required fields are marked *