0

Is it possible to make Craft 3 load a custom translation/language file? Even if not using multisite or locales?

My use case for this is just to change the way certain things are said. E.g. 'Invalid username or password.' => 'Invalid username or password.', when a user logs in. I wanted to be a bit more descriptive on this.

I can see the translation files in vendor/craftcms/cms/src/translations/[language code here] so I assume theres a way of adding bespoke ones to this, but outside of the vendor folder.

I just can't find it in the docs.

1

You are looking for Static Translations.

You can add a translation file for English to English (or whatever language you are using) to override default translations. In your case, you'll want to override the app translation category:

In your project folder:

website.com/
└── translations/
    └── en/
        └── app.php

And in app.php:

<?php

return [
    'Invalid username or password.' => 'Something new'
];
  • Thanks! I managed to fix it by doing this. My issue was I was calling the file site.php not app.php. Doh. – Jason Mayo Oct 7 at 10:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.