I am making a website with Craft 3 and I have some static text that needs to be translated.

I followed Craft's documentation on it. I created my translations/fr/site.php file and use the {{ 'String'|t }} format to translate my strings.

I tried everything I found on the web, but I can not make it work. My strings stay in english and doesn't translate. It doesn't even seem to access the site.php file.

I tried to clear my cache, restart my Docker container, change the folder name to fr-CA instead of fr ...

I found another member here that had the same problem as me, but he updated Craft and it worked. My Craft configuration is up to date...

Is there something I am missing?

Thank you.

  • What do you get in an incognito window? – Oli Dec 5 '19 at 23:01
  • Have you tried copying a working translation's English string and "statically" translating it in it's stead to check if that works? --- Example: {{ welcome_message|t }} let's say welcome_message is Welcome User! so you replace the dynamic reference as follows {{ 'Welcome User!'|t }} --- If that works but your other static translations don't, then there's an error with your input string or your translation array having the wrong text as key. – Campiotti Dec 6 '19 at 10:43
  • Hi, I did try with an incognito windows and it didn't work. And I don't use dynamic reference, I simply use plain static strings. – Mikko109 Dec 6 '19 at 13:16

I'm simply trying to follow the docs as good as possible.

Try the following:

Example String we'll be using: "cheese" | "fromage"

  1. in your config/general.php make sure you have your siteUrl set as an array with at least two entries, example:'siteUrl' => ['my_site_en' => 'http://localhost:1234, 'my_site_fr => 'http://localhost:1234/fr/'];
  2. in your translations/fr/site.php make sure it only contains the following

    return [
      'cheese' => 'fromage',
  3. in your twig file add the following <h1>{{ "cheese"|t }}</h1>

4. important: Access your Control Panel (cpTrigger in config/general.php for the first part of the URL), => http://localhost:1234/%CP_TRIGGER%/settings/sites and make sure you have 2 sites, both in the same group, one in en, one in fr & their URLs must also be set!
It should look similar to this Craft CP with two sites, main english, additional french

As long as all 4 steps are followed, it should work.

Hope this helps!

  • I was seriously hoping this would work, but it didn't. I seriously don't know what I am doing wrong, but it is genuinely frustrating! – Mikko109 Dec 10 '19 at 13:35
  • Alright well let's not give up just quite yet, we still have a few things we can try... clear your logs storage/logs/* and then call an URL which should (if it worked) translate a string to another language. After that please zip your entire storage/logs folder and upload it to some file-sharing website and post the link in the comments so I can take a look at it, I think that'd be a good place to check as the logs sometimes have some info which may get overlooked otherwise. (For example you could use send.firefox.com) – Campiotti Dec 10 '19 at 14:02
  • Hi Campiotti. Here are the logs files: send.firefox.com/download/49de7f59e66f4879/… The two lines I'm trying to translate are called "Email Address" and "Go!" in case it helps you find something. – Mikko109 Dec 12 '19 at 17:47
  • Oh I forgot about the time-limit on the send.firefox.com downloads sorry! I miseed the download span and am now unable to download the logs... I think it might be better if a more non-temporary file hoster would be used like mediafire.com . Sorry about that, but could you please upload the logs once more but to that file hoster? Then the link wouldn't expire so fast and I'll try and take a look at the logs to see if I can find anything, thanks. – Campiotti Dec 16 '19 at 6:46
  • There you go: mediafire.com/file/8zkvrlzi2na9mvx/logs.zip/file – Mikko109 Dec 16 '19 at 18:16

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.