We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • I want to use some chunks to create additional parts of a multilanguage website (done with BABEL or just contexts). These chunks contain snippet calls and also "real" text which must be different for each language.
    Since the MODx Revo lexicon does only work for the manager I wonder how I can create a lexicon for the resources. Calling a "translate snippet" with some parameters would do the job. Is there already something out there so I don’t have to invent it a second time? Or does anybody have a better idea for me?
    Thanks!
      MINDEFFECTS – DESIGN for PRINT, WEB and MEDIA
      http://twitter.com/mindeffects · http://www.facebook.com/mindeffects · http://www.youtube.com/mindeffects/ · skype://mindeffects_oliver
      • 31946
      • 116 Posts
      Hi mindeffects,

      Lexicon does also work in the Frontend! I’m also using Babel for a project now with lexicon-keys. Since you’re using Babel, the cultureKey is set
      different in each context. You can create your lexicon keys, for example:

      Key’s in Namespace babel:
      babel.welcome_message (de) = Willkommen
      babel.welcome_message (en) = Welcome
      


      In your chunk, use:
      [[%babel.welcome_message? &namespace=`babel`]]


      Another solution, if you call the same Chunk in different Language-Resources, is to
      use Properties:
      Property: welcome, Default = Welcome
      [[$chunkName? &welcome=`Willkommen`]]
      [[$chunkName? &welcome=`Bienvenu`]]
      

      Instead of a fixed value in the Chunk for the Welcome-Message, use the created Placeholder for your Property:
      [[+welcome]]
      • Is there a way to make these babel namespaces available for editors so that they can translate all these namespaces?
          • 11455
          • 6 Posts
          Great, exactely the solution I was looking for customizing chunks in different languages! Thanks a lot.
            • 36604
            • 268 Posts
            Hi,

            I recently decided to create my own lexicon. I was puzzled by the fact they all comes with real components but it's not mandatory. A lexicon can lives without components.
            So I named my new lexicon name space i18ncustom

            • in manager menu System >namespaces, create a new name space (i18ncustom in my case)
            • create a new folder at the right place : {core_path}components/i18ncustom/
            • and into it create a /lexicon folder, then again any language subfolder as needed (fr,de,nl...)
            • in those languages subfolder create a new default.inc.php files (better to copy a file from a compoent to get the right syntax).
            • Name each key as in relationship with the names space you create earlier:
              for ex:
            $_lang['i18n.nom'] = 'Nom';
            $_lang['i18n.nom_title'] = 'Merci de saisir votre Nom';


            • check in system>lexicon menu if everything is fine
            • Now you can put in any chunk a language parameterized string :
              for ex:

            <p class="contact_form_field"><span class="form-error"></span> <label for="name">[[%i18n.nom? &language=`fr` &namespace=`i18ncustom`]] </label> <input required="required" id="name" title="[[%i18n.nom_title? &language=`fr` &namespace=`i18ncustom`]]" type="text" name="name" value="" /></p>


            It's a bit long syntax but it's universal now. mostly if you directly use cultureKey inside instead of an explicit language code.
            like this:

            <label for="name"> [[%i18n.nom? &language=`[[++cultureKey]]` &namespace=`i18ncustom`]] </label>