Answers.Body: <p>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 <code>index.php</code> to switch the languages. </p>
  
  <p>The languages are defined on a Site base. The translation folder now lives in the root of your projects: <code>projectFolder/translations/fr/site.php</code>. </p>
  
  <p>As of Craft 3.1, you can set the Base Url of each site to a variable in your <code>.env</code> file and use that variable in the admin panel with the site setup. <code>@web</code> as your Base URL doesn't work to properly detect what site you are on.</p>
  
  <p>So in your case, make two sites in the admin panel. Make two variables in your <code>.env</code> file:</p>
  
  <pre><code>SITE_URL_FR = '...'fr/'
  SITE_URL_EN = '.../en/'
  </code></pre>
  
  <p>Use those variables to set your Base Url in the sites config. You can target them with <code>$SITE_URL_FR</code>. That should do the trick.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-25T10:21:22.583Z
Answers.Text: 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
Answers.UserDisplayName: akagibi
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-25T10:52:38.757Z
Answers.Text: Are you on Craft 3.1?
Answers.UserDisplayName: Jan_dh
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-25T10:53:56.940Z
Answers.Text: Does the folders you made in the translations also match the language handles of the site?
Answers.UserDisplayName: Jan_dh
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-25T11:25:33.550Z
Answers.Text: Craft CMS 3.1.3 - Yes, "/craftfolder/translations/en/site.php"
Answers.UserDisplayName: akagibi
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-25T11:25:39.297Z
Answers.Text: 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 :)
Answers.UserDisplayName: Oli
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-25T11:34:41.447Z
Answers.Text: @Olivier Bon - No, same problem. Logged out, devMode false, ... strange because i've got other website without problem. ??..
Answers.UserDisplayName: akagibi
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-25T11:46:34.027Z
Answers.Text: Cleared your cache?
Answers.UserDisplayName: Oli
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-25T11:53:21.460Z
Answers.Text: Yes cache clear. I think there is an error during install
Answers.UserDisplayName: akagibi
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-25T15:34:54.347Z
Answers.Text: Hey, Craft 3.1.4 was available. After the update, everything work fine !
Answers.UserDisplayName: akagibi
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-25T15:47:51.583Z
Answers.Text: Good news! Glad you got it sorted :)
Answers.UserDisplayName: Oli
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-25T09:37:23.297Z
Answers.LastActivityDate: 2019-01-25T09:51:55.877Z
Answers.LastEditDate: 2019-01-25T09:51:55.877Z
Answers.UserDisplayName: Jan_dh
Body: <p>I have 2 sites (fr and en), fr is default.</p>
  
  <p>In <code>index.php</code>, I have <code>define('CRAFT_SITE', 'fr')</code> and <code>define('CRAFT_SITE', 'en')</code></p>
  
  <p>In templates, I'm using <code>{{ 'Texte FR'|t }}</code> tag.</p>
  
  <p>In <code>/craft/translations/en/site.php</code>, I have my translation : <code>'Texte FR' =&gt; 'Text EN'</code></p>
  
  <p>When I test the English version, it's OK.</p>
  
  <p>When I test the French version, English translations are displayed.</p>
  
  <p>If I remove translations folder, of course, it's OK.</p>
  
  <p>If I add 'fr' folder in translations, Englishis  still displayed.</p>
  
  <p>Is there a way to trace the choice of the translation file by Craft?</p>
  
  <p>I can't find why ...</p>
  
  <p>Thank for help. :)</p>
  
Tags: <craft3><localization>
Title: Craft CMS 3 - Always load "en" translation file
ThreadText: # Craft CMS 3 - Always load "en" translation file
  
  (Asked by: username_0 on 2019-01-25)
  
  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. :)
  
  **Tags:** craft3, localization
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-01-25. Score: 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.
  
  > **Comments:**
  > **username_0**: Thank you @username_1  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  
  > **username_1**: Are you on Craft 3.1?  
  > **username_1**: Does the folders you made in the translations also match the language handles of the site?  
  > **username_0**: Craft CMS 3.1.3 - Yes, "/craftfolder/translations/en/site.php"  
  > **username_2**: 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 :)  
  > **username_0**: @Olivier Bon - No, same problem. Logged out, devMode false, ... strange because i've got other website without problem. ??..  
  > **username_2**: Cleared your cache?  
  > **username_0**: Yes cache clear. I think there is an error during install  
  > **username_0**: Hey, Craft 3.1.4 was available. After the update, everything work fine !  
  > **username_2**: Good news! Glad you got it sorted :)  
  
  ---
  
  