We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 48291
    • 13 Posts
    Hi. Site has multiple contexts and languages respectively(ru, en, de,...). Also, it uses formIt, template:
    <form action="/" method="post" name="video" class="ajax_form white-popup-block">
    	<input type="text" name="name" id="name" value="[[!+fi.name]]" />
    	<span class="error error_name">[[!+fi.error.name]]</span>
    	<input type="text" name="email" id="email" value="[[!+fi.email]]" />
    	<span class="error error_email">[[!+fi.error.email]]</span>
    	<input type="submit" value="[[%form.send?Topic=`label`]]" class="f-bu f-bu-default" name="video-yes" id="yes_btn" />
    </form>
    


    How to do that in all contexts, except 'ru', language form was English? Thanks.
      • 19328
      • 433 Posts
      Maybe you can create a snippet and call this in the top of your page:

      $modx->setOption('locale', '[[++cultureKey]]');


      Now, add a context key to every context named 'cultureKey' and set the desired language code (en, de, ru)
        • 46309
        • 79 Posts
        Or you can try to use lexicon and namespaces (Read about Namespace and Lexicons skip Actions and Menus):
        http://rtfm.modx.com/revolution/2.x/case-studies-and-tutorials/developing-an-extra-in-modx-revolution/developing-an-extra-in-modx-revolution,-part-ii#DevelopinganExtrainMODXRevolution%2CPartII-Namespaces

        - Create Namespace, for example "myTraslations"
        - Create Lexicon for English version
        {namespace_path}/lexicon/en/contacts.inc.php
        and insert there somthing like this:
        <?php
        $_lang['name'] = 'name';


        Create Lexicon for Russian version (just to see how it works, because name is the same in english and german)
        {namespace_path}/lexicon/ru/contacts.inc.php
        and insert there somthing like this:
        <?php
        $_lang['name'] = 'Имя';

        German:
        {namespace_path}/lexicon/de/contacts.inc.php
        and insert there somthing like this:
        <?php
        $_lang['name'] = 'Name';

        - In your formit code you need to display the translation under placeholder like this:
        <form action="/" method="post" name="video" class="ajax_form white-popup-block">
            <input type="text" name="name" id="name" placeholder="[[%* name? &topic=`contacts` &namespace=`myTraslations` &language=`[[++cultureKey]]`]]"  value="[[!+fi.name]]" />
            ...
        </form>


        In your contact you will see under name in en Name in de and Имя in ru language. Don't forget to set the language keys.

        Here is also some explanation about the internationalization:
        http://rtfm.modx.com/revolution/2.x/developing-in-modx/advanced-development/internationalization#Internationalization-LexiconsviaTag%28incontent%2Cchunks%2Ctemplatesetc%29
          peace&love / bike&ride