internationalizationmodxmodx-revolutionmodx-templates

How to organize templates in multilingual modx


I'm building a multilingual website with ModX, so I installed the Babel extra and the things seem to be working fine.

I am now wondering how to handle my templates and I can't come up with a solution for using the same template for pages with different languages (would be ideal, no code duplication).

Indeed, consider this code in my template that lists posts in the sidebar:

   <h3>Archives</h3>
   <ul>
     [[!Archivist? &target=`7` &parents=`3,4`]]
   </ul>

target=7 and parents=3,4 refer to Resources in English, so I obviously cannot use this code in my template for Resources in Chinese. The only workaround I could think of is to have different templates for each language. Is this the right way to go?


Solution

  • You can create system settings in the language contexts. [click on the context in the resource tree & go to settings.] You can then use these just like system settings:

    [[!Archivist? &target=`[[++system_setting_1]]` &parents=`[[++system_setting_2]]`]]
    

    As for the

    Archives

    - you can use lexicon settings for those or detect the context:

    [[*context_key:is=`French`:then=`Archiv`:else=`Archives`]]