4

I have a site that is mixed English and Chinese. I've properly set up the locale to include Chinese as a locale, and have put Chinese translations for my fields in place. That all works.

However, the site isn't one where you'll pick Chinese or English, it's going to display both in many cases.

So is there a way to explicitly set the English or Chinese translation of a global (or any field for that matter)?

I tried:

{{ myGlobalSet.myGlobal.en }}

As well as:

{{ myGlobalSet.en.myGlobal }}

...but it didn't like either one of them. Is there a way to retrieve the localization of a field without having to switch the locale of the entire site?

2

It looks like I can do:

{% set myGlobalSet = craft.globals.getSetByHandle( 'setName', 'zh' ) %}
{{ myGlobalSet.myGlobalVar }}

If anyone has a better way to do it, please let me know... my plan is just to put this into a base template so that all of the pages can access the localization easily.

| improve this answer | |

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.