statamic / ssg

The official Statamic Static Site Generator
229 stars 23 forks source link

Translate tag picks the wrong language when using multisite #166

Open tao opened 1 month ago

tao commented 1 month ago

I have some translated keywords in Laravel Lang files, but when I used ssg:generate after updating to v3 then it randomly generates from other languages...

This happens even when I specify the site in the trans tag

{{ trans:legal.disclaimer site="{locale}" }}

Screenshot 2024-05-23 at 17 23 27

You can see it ends up with a mix of all different languages on this page, so now I have Spanish and Arabic on the same page.

The same is happening with the get_content tag.

It seems most languages end up being generated with Arabic which is alphabetically the first site in our sites list... besides that I don't have any other clues as to what is going on.

tao commented 1 month ago

When I generated the site again to debug it, it seemed like {{ site }} and {{ locale }} had a mismatch:

Screenshot 2024-05-23 at 19 57 00

So here bg was correct for Bulgarian but the locale was zh_tw for Chinese.

Screenshot 2024-05-23 at 20 00 03

Here the site es was correct but the locale el for Greek was incorrect.

tao commented 1 month ago

Since the {{ site }} variable is correct, I tried using that but it seems more like the get_content and trans tags are not working correctly then... as even if I try overload them with the correct site it doesn't work:

{{ get_content from="/fragments/disclaimer" site="{site}" locale="{site}" }}
     <p>{{ content }}</p>
{{ /get_content }}

Using the example above it would revert back to getting the Chinese zh_tw disclaimer instead of the correct one for the site bg.