I have 2 sites (fr and en), fr is default.

In index.php, I have define('CRAFT_SITE', 'fr') and define('CRAFT_SITE', 'en')

In templates, I'm using {{ 'Texte FR'|t }} tag.

In /craft/translations/en/site.php, I have my translation : 'Texte FR' => 'Text EN'

When I test the English version, it's OK.

When I test the French version, English translations are displayed.

If I remove translations folder, of course, it's OK.

If I add 'fr' folder in translations, Englishis still displayed.

Is there a way to trace the choice of the translation file by Craft?

I can't find why ...

Thank for help. :)

1 Answer 1


In Craft 3 the setup works a little bit different from the Craft 2 setup. You don't actually have to make changes to your index.php to switch the languages.

The languages are defined on a Site base. The translation folder now lives in the root of your projects: projectFolder/translations/fr/site.php.

As of Craft 3.1, you can set the Base Url of each site to a variable in your .env file and use that variable in the admin panel with the site setup. @web as your Base URL doesn't work to properly detect what site you are on.

So in your case, make two sites in the admin panel. Make two variables in your .env file:

SITE_URL_FR = '...'fr/'
SITE_URL_EN = '.../en/'

Use those variables to set your Base Url in the sites config. You can target them with $SITE_URL_FR. That should do the trick.

  • Thank you @Jan_dh I've remove "/www/fr" and "/www/en" folders I've add SITE_URL_FR and SITE_URL_EN in .env file I've change my sites config with this new env variables It's easier to manage now But, frontend still load english translation in the french environnement
    – akagibi
    Jan 25, 2019 at 10:21
  • Are you on Craft 3.1?
    – Jan_dh
    Jan 25, 2019 at 10:52
  • Does the folders you made in the translations also match the language handles of the site?
    – Jan_dh
    Jan 25, 2019 at 10:53
  • Craft CMS 3.1.3 - Yes, "/craftfolder/translations/en/site.php"
    – akagibi
    Jan 25, 2019 at 11:25
  • Not sure if it's relevant but when you visit your site, if you have have another tab opened and you're logged in as a user with english set as your main language, it might be taking over your frontend language maybe..? Not able to test but this came to mind when I read your issue :)
    – Oli
    Jan 25, 2019 at 11:25

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.