We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21642
    • 23 Posts
    Hello.

    I have too an multilanguage site. Like Zap, I have 2 folders for the language.
    Then I have a call to wayfinder with UltimateParent. What I have to do now is 2 use the same template for both language. Anyone?
    The solution that I’ve adapted is here, in the wiki: http://wiki.modxcms.com/index.php/Make_Multi_Lingual_Site . The benefits is: good doc structure, search engine frindly URL, automate menu building for each language.
    What I want nnow is to automate the css.
    Regards,
    Cristian Nica
      • 33372
      • 1,611 Posts
      @marco: Glad you got it working. You can actually use the same WayFinder snippet and just pass it different start IDs (and templates if you like). So you’d just have something like:

      [!Wayfinder? &startId=`0` &hereClass=`current` &level=`1` &outerClass=`topnavEng`!] = English pages
      [!Wayfinder? &startId=`50` &hereClass=`current` &level=`1` &outerClass=`topnavEsp`!] = Spanish pages

      Most MODx snippets are designed to be used for multiple purposes and in many locations in the same website, so it’s rare that you need to duplicate them (although it usually works just as well if you do).

      @nlcluigi: If you really need to use the same template for both languages, you can (I never do because I always find other language-specific things that are easiest to change in my templates). If you have a subfolder for each of your languages, then you just need to use something other than UltimateParent as the startID for your WayFinder call. If all of your documents are one level below the language folders, you could of course just use [*parent*]; you could also use an inherited TV or modify the UltimateParent snippet to return the penultimate parent (which would be the main subfolder for each language).

      You could use that same value (the docID of the main language subfolder) to automatically switch your CSS (just place it in your template as part of your CSS include or styles).

      It’s great to see more bilingual sites getting built in MODx and people feeling like it’s intuitive and easy to do.
        "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
        • 12269
        • 1 Posts
        Quote from: TobyL at Jan 20, 2007, 08:33 AM

        I find it a problem to copy the whole site before you start translating. If you have a one man operated fairly static site that’s ok perhaps but with a frequently changing site with multiple contributors, who are not necessarily the translators things can become quite messy pretty quickly. By the time a whole section is translated a significant amount of the original has already changed.

        Instead I’ve implemented a very similar system with a folder per language and a cross-reference table, except that only the page (or a small group of pages) currently being translated is copied over. A simple plugin checks and serves a translated page if it is available. I use a customised menu script that makes the same checks. If a visitor has chosen a particular language the menu-items with a translated page will be translated and the rest will be shown in the default language.

        It’s true this can be produce a bit of a miss-match site for a while but in practice my experience is that nobody is too bothered by that and the site in all languages stays much more up to date.

        Hi, Can you give me some detail on the plugin you have used to check and serve the translated pages. I am looking to put in place a setup that same as you have described here. tks.
          • 10916
          • 13 Posts
          Hi, thanks a lot for this great solution.

          I am having the strangest problem, i think it could be something to do with the local web server i am working on, but here goes.

          Everything seems to work OK. But after I have visited the homepage and have been redirected to the english start page once, any subsequent visit to the homepage doesn’t redirect to the english start page. It just sits on the page that has the redirect snippet.

          To make matters even stranger, if in the manager I open and save either the english start page or the redirect snippet, it will work again, but only once! again! laugh

          Strange, isn’t it? Any ideas?
            • 33372
            • 1,611 Posts
            Sounds like a caching issue to me (I’m not sure which method you’re implementing to redirect, but check that you’re doing in uncached).
              "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
              • 10916
              • 13 Posts
              Thanks ZAP, working fine now. smiley
                • 19315
                • 84 Posts
                Hi,

                Just in case anyone finds this useful, I have slightly modified the snippet that presents the flags with language choices. In my case I have a multi-lingual MaxiGallery, as in http://modxcms.com/forums/index.php/topic,24577.0.html , which in "normal" view uses GET variables to choose which picture to display.

                Thus I have added to the snippet the following code:

                // Recreate GET query, but remove q term
                $get = "";
                if (sizeof($_GET) > 1) {
                  $getArray = $_GET;
                  unset($getArray['q']);
                  $get = "?".http_build_query($getArray);
                }


                And replaced

                $modx->makeUrl($targetid)
                by
                $modx->makeUrl($targetid).$get


                This adds the original GET query onto the URL for the translation. Thus people can move from a picture in one language to a picture in another if they wish.

                Note: the "remove q term" is because I use friendly URLs: I think the q term is added "internally" by the .htaccess file and contains the path to the document requested. This seems to be part of the $_GET variable, but it is not required when constructing links. I’m not sure what would happen if friendly URLs are off.

                Also: I’m by no means a PHP expert, so what I’ve written could be done in a better way, or there could be some cases where this does something dodgy!

                Michal
                  • 19315
                  • 84 Posts
                  Also:

                  I’m not sure, but I think that in the img tag, there should be a lang attribute and/or an xml:lang attribute (depending on doctype) that contains the language code of the target language. This so the "alt" text, which contains the language name, but in the target language (e.g. Deutsch and not German), can be read correctly by screenreaders.

                  Michal.
                    • 19315
                    • 84 Posts
                    Just for reference in case someone finds it useful, I use a slightly modified method to the one here. I have a "main" language has its content in the root of the site (i.e. not in a sub folder of it’s language name), and then other languages have their content in subfolders. I then use the method at http://modxcms.com/forums/index.php/topic,24793.0.html to get the menus working properly.

                    Michal.
                      • 2058
                      • 1 Posts
                      I had to use
                      [!Wayfinder? &startId=`[[UltimateParent? &topLevel=`2`]]`!]

                      for the menu on the Template file as the original

                      [!Wayfinder? &startId=`[[UltimateParent]]`!]

                      was showing me both languages..

                      would be good to have this language stuff out of the box! smiley