TransWikia.com

Using static translations for the primary site / site.php being ignored

Craft CMS Asked by tomkiss on September 4, 2021

I’m having trouble outputting static translations for the primary site, and only the primary site.

Translations structure:

  • translations
    • en-US
      • site.php

site.php

<?php

return [
  'UNIQUE_KEY_NAME' => `This is the string I'd like to appear.`,
];

Template

{{ 'UNIQUE_KEY_NAME' | t }}

Output

UNIQUE_KEY_NAME

Is there a way to make this pattern work?
The advantage of storing microcopy and site furniture in a single location is that it is much easier to update and share with copywriters.

If there is a second site, then it appears the site.php for that language will be respected, but when there is just one site, the primary site, its corresponding site.php translation file appears to be ignored. Is this intended?

Thanks ?

One Answer

I think the error is to do with the fact that you are using backticks (slanted quote) instead of single/double quote marks.

Copy/paste the below and it should work for you

<?php

return [
  'UNIQUE_KEY_NAME' => 'This should now work',
];

Correct answer by Oli on September 4, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP