We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19889
    • 616 Posts
    Hello,
    I’m still struggling with setting up a multi-lingual website and I hope that some people can help. thank you in advance for your input.

    First of all, I’ve one main folder per language - I’d like to not duplicate snippets and chunks where possible. So where are the problems, I’m facing:

    1. footer links - I have some hard-coded links in the footer of my template - in other menus, ultimateParent works find - what’s the best way to set up the footer - maybe set up a footerChunk per language?
    2. What’s the best way to setup the home link that is the welcome page in each language?
    3. How do I setup the use of snippets like eform that I’m using as a contact form for instance - instead of just copying the contact-form chunk, is there a way to define and use language variables?
    4. last but not least, I’d like to have a language link on each page pointing to the corresponding page in the available languages - what’s the best way to go about this?

    finally, I was wondering whether there is a problem in using duplicate alias entries - I was thinking of setting up the whole tree structure for one language incl. alias names and when the structure is finalized just copy it over to a 2nd or 3rd language folder or would I have to change all those alias names and e.g. adding a suffix like contact_en? In this context, how could I e.g. get the document id of a document with the alias="xyz" and languageTV="en"?

    I hope you guys can shed some light into those issues.

    Once again, thank you for your help.
      • 29181
      • 480 Posts
      Firstly, I’m not sure if you’ve seen it but there is a page about multi-lingual stuff on the Wiki. I used it when I started setting flash-genie.de

      1.I think a chunk per language for the footer is a good idea. I set up a template variable at the top of each "folder" with a value and set that to @inherit. Then instead of the footer you can just add the [*footer*] TV which either points to the {{englishFooter}} or {{otherLanguage}} depending on the value.

      2.For the welcome page I just put it in two languages.

      3. Don’t know, if you have a page for each language anyway, then I don’t see anything wrong with just pointing it to a different template.

      4. You’ll find one method on the Wiki. That is the method i adopted which works quite well.

      As to finally...I have no idea, but hope that you find a solution.

      Taff

        Adrian Lawley: www.adrianlawley.com
        • 19889
        • 616 Posts
        Quote from: Taff at Jul 08, 2007, 07:07 AM

        Firstly, I’m not sure if you’ve seen it but there is a page about multi-lingual stuff on the Wiki. I used it when I started setting flash-genie.de

        1.I think a chunk per language for the footer is a good idea. I set up a template variable at the top of each "folder" with a value and set that to @inherit. Then instead of the footer you can just add the [*footer*] TV which either points to the {{englishFooter}} or {{otherLanguage}} depending on the value.

        2.For the welcome page I just put it in two languages.

        3. Don’t know, if you have a page for each language anyway, then I don’t see anything wrong with just pointing it to a different template.

        4. You’ll find one method on the Wiki. That is the method i adopted which works quite well.

        As to finally...I have no idea, but hope that you find a solution.

        Taff



        Thanks for your feedback - I’ve seen the solution in the wiki but I thought it’s kind of a pain having to enter all corresponding pages manually in the TV like en=46,it=47,fr=48,.... - I’ve a fairly large page - I hoped to find a solution that somehow could automize this process.

        as to the footer, just to get you right - I’ve set up a langTV as well as a footerTV, right - could you please elaborate a little how you’ve done it.

        moreover, I still don’t see how I would have snippets like ajaxSearch, eform etc. in multiple language without duplicating them
          • 19889
          • 616 Posts
          I’m afraid I missed that post - will try to find it again.
            • 29181
            • 480 Posts
            For the footer, yes I didn’t use any rocket science yet. I simply created a TV called [*footer*] with a list

            English footer=={{footer_eng}}|| German footer =={{footer_ger}}


            and a default value of @inherit.

            I then created 2 chunks (called footer_eng & footer_ger) with respecitve content.

            I editted my de "folder" with the german content, scrolled down to my footer TV and selected German footer and the alternative for the english footer in the en folder. Place the [*footer*] placeholder in the template and all is well.

            I had found a solution by setting one TV which defines numerous others using PHx but (always a but) I was testing some stuff on the page to show a client and managed to paste his template onto mine....and this was the most recent backup of the DB I had.

            I’m not sure at all how you could automate things other than possibly using an alias that creates a "other language link or flag" and grabs the current alias and strips the last 2 letters from the name.

            So e.g. if we are at www.mysite.com/contact_de.htm it strips the de and sends the link to contact_en.htm.

            That’s more or less how I did it in the past with my first ever flash site using directories.

            How many languages are you thinking of integrating 2, or more?

            No matter what, good luck in your quest!

            Taff
              Adrian Lawley: www.adrianlawley.com
              • 727
              • 502 Posts
              Some general info:

              In addition to the idea in the wiki, I added a template variable called "language" which contains "en", "de", etc. indicating the current language of the page.
              I then created chunks for example en_footer, de_footer, etc.
              Next I create a snippet called footer that when called gets the value of the language template variable and constructs the name of the chunk to use (by sticking it with "_footer". The snippet then returns the contents of the chunk.

              Why use a template variable? Because in my sites I tend to use a lot of custom snippets so I use this method over and over again in each snippet to show the correct chunks depending on the language. Then I don’t need to customize each snippet call - I just call it.

              Andy
                • 33372
                • 1,611 Posts
                Quote from: mmjaeger at Jul 08, 2007, 02:39 AM

                1. footer links - I have some hard-coded links in the footer of my template - in other menus, ultimateParent works find - what’s the best way to set up the footer - maybe set up a footerChunk per language?
                2. What’s the best way to setup the home link that is the welcome page in each language?
                3. How do I setup the use of snippets like eform that I’m using as a contact form for instance - instead of just copying the contact-form chunk, is there a way to define and use language variables?
                4. last but not least, I’d like to have a language link on each page pointing to the corresponding page in the available languages - what’s the best way to go about this?

                finally, I was wondering whether there is a problem in using duplicate alias entries - I was thinking of setting up the whole tree structure for one language incl. alias names and when the structure is finalized just copy it over to a 2nd or 3rd language folder or would I have to change all those alias names and e.g. adding a suffix like contact_en? In this context, how could I e.g. get the document id of a document with the alias="xyz" and languageTV="en"?

                RE #1: Taff’s @inherit TV idea sounds great to me (I’ve always used multiple chunks and different templates myself, but I’ve only ever done bilingual sites so far).

                RE #2: Check out the subsites/subdomains hacks. Usually I set one language as the default and then switch the home page to another based on the domain name (or subdomain). If you set a cookie to save user preferences, make sure that you can override it by clicking on a different language link.

                RE #3: That’s an interesting question (about eForm in particular). I’ve always just used multiple snippets, but that’s obviously not ideal. It shouldn’t be difficult to modify a snippet like eForm to accept the language variable as a snippet parameter, if it’s not already implemented (I’d post in the snippet’s particular thread if not).

                RE #4: I tend to use friendly aliases with folders (with each language’s name), which would mean that you could duplicate aliases all you like and just create links to the same alias in the correct language folder. I don’t do it that way myself, however, because I want my URLs to be in the target language as well (for both search engines and humans). So I’ve actually used a TV where you manually enter the docid of the other language’s page and created links based on those. Which is a somewhat tedious thing for administrators to do, and prone to human error, but so far it’s been the best method I’ve come up with. Perhaps a better way would be to use a matching value in some field other than alias (probably a TV) that could be automatically linked (although admins would still need to enter that value). I’d be interested to hear some other ideas as well, since I need to do my first five-language site this month.

                I also create a snippet that uses the default content (English) for other language pages if there is no translated content yet and prepends a "Sorry! This page is not yet translated..." message to it.

                Although I’ve had to duplicate templates, snippets, chunks, etc. and despite having to manually enter translation docids, I should say that overall I’ve been very happy with this system and so have our clients. It could definitely be improved with a little ingenuity, but it works and is relatively intuitive. It helps that so many MODx snippets are already constructed to be completely modular tools.
                  "Things are not what they appear to be; nor are they otherwise." - Buddha

                  "Well, gee, Buddha - that wasn't very helpful..." - ZAP

                  Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
                  • 29181
                  • 480 Posts
                  This is turning into a great thread. I like reading about other peoples ideas, it opens up many doors.

                  I also create a snippet that uses the default content (English) for other language pages if there is no translated content yet and prepends a "Sorry! This page is not yet translated..." message to it.

                  Fancy sharing some more information on this? It sounds like a very good idea indeed.

                  That’s an interesting question (about eForm in particular). I’ve always just used multiple snippets, but that’s obviously not ideal. It shouldn’t be difficult to modify a snippet like eForm to accept the language variable as a snippet parameter, if it’s not already implemented (I’d post in the snippet’s particular thread if not).

                  This made me wonder about using PHx inside the eform call to either point to one of the language templates like:

                  [!eForm? &formid=`ContactForm` &subject=`[+subject+]` &to=`[(emailsender)]` &ccsender=`0` &tpl=`[*phx:input=`[*lang*]`:is=`de`:then=`tpl_de`:else=`tpl_en`*]` &gotoid=`46`!]

                  I wonder if that would work...also on a whole I’m not too sure about how resources intensive PHx is. I’ve done away with all the language specific TV’s at the moment in favour of using PHx which is a definite improvement on 5 or 6 TV’s (from a user point of view at least). The other question (without looking) is whether PHx would be capable of doing that with 5 or more languages?!?

                  All the best,
                  Taff

                    Adrian Lawley: www.adrianlawley.com
                    • 33372
                    • 1,611 Posts
                    Quote from: Taff at Jul 09, 2007, 03:30 AM

                    I also create a snippet that uses the default content (English) for other language pages if there is no translated content yet and prepends a "Sorry! This page is not yet translated..." message to it.

                    Fancy sharing some more information on this? It sounds like a very good idea indeed.
                    It’s nothing all that impressive, but it works for me. Last time I used a TV for this, but I think I’ve used snippets before. Either way works, but this is what my last TV code looks like:
                    @EVAL
                    if($modx->documentObject['content'] > '') return $modx->documentObject['content'];
                    else{
                       $sql="SELECT * FROM ".$dbase."modx_site_tmplvar_contentvalues WHERE tmplvarid='6' AND contentid='".$modx->documentIdentifier."'";
                       $rs=$modx->dbQuery($sql);
                       $row_rs=mysql_fetch_assoc($rs);
                       $transDocID=$row_rs["value"];
                       $transText='<div class="note"><p>Lo sentimos. Esta página todavía no está traducida al español. Si quieres ayudar a traducirlo, <a href="http://www.mydomain.org/forums/index.php?board=9.0" target="_foros"">haz clic aquí</a> para participar en el foro de traducciones.</p>';
                       if( $transDocID != '' ) {
                          $transDocInfo = $modx->getDocument($transDocID);
                          $transText.='<p>Abajo está el contenido en inglés.</p><p> </p></div><br clear="all" />'.$transDocInfo['content'];
                       }
                       else $transText.='</div>';
                       return $transText;
                    }

                    The TV with id 6 is the one that stores the docid of the page in the opposite language (English or Spanish).

                    Kind of a dirty hack, and you could certainly move the text into chunks for easier administration, but it did what I needed at the time and I haven’t looked back at it until now (dunno why I didn’t use the getTemplateVarOutput() function from the API instead of that SQL query, for example)...
                      "Things are not what they appear to be; nor are they otherwise." - Buddha

                      "Well, gee, Buddha - that wasn&#39;t very helpful..." - ZAP

                      Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
                      • 30223
                      • 1,010 Posts

                      3. How do I setup the use of snippets like eform that I’m using as a contact form for instance - instead of just copying the contact-form chunk, is there a way to define and use language variables?

                      RE #3: That’s an interesting question (about eForm in particular). I’ve always just used multiple snippets, but that’s obviously not ideal. It shouldn’t be difficult to modify a snippet like eForm to accept the language variable as a snippet parameter, if it’s not already implemented (I’d post in the snippet’s particular thread if not).

                      Sadly this is one thing that is sorely missing from eForm. For the current eForm version you could write a function for the eFormOnBeforeParse event in which you could dynamically load language strings into the templates, but that would be the extend of it. eForm’s language file can not be changed dynamically (which provides many of the form error messages for example), although you can set the &language parameter for this if you have separate eform calls on each language page.

                      The good news is that I’ve just started working again on a brand new eForm version and internationalization is one of the issues I’m trying to address.

                      This made me wonder about using PHx inside the eform call to either point to one of the language templates like:

                      [!eForm? &formid=`ContactForm` &subject=`[+subject+]` &to=`[(emailsender)]` &ccsender=`0` &tpl=`[*phx:input=`[*lang*]`:is=`de`:then=`tpl_de`:else=`tpl_en`*]` &gotoid=`46`!]

                      No, that won’t work. Firstly PHx and eForm are not compatible and secondly Modx tags inside the eForm call are evaluated too late to be of any use inside eForm. You might see the result in the browser but eForm wouldn’t know about them. The latter is something that’s being addrerssed as well in the new version.