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.
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
:
1 2 3 4 |
return [ new Flarum\Extend\Locales(__DIR__ . '/locale'), // rest of extenders ]; |
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.