We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6848
    • 52 Posts
    Hi,
    I have following configuration:

    - YAMS is configured with root name mode
    - YAMS is configured with redirection mode "current". This I need to be able to use AjaxSearch with Ajax mode

    Everything is working fine, except that the starting of the site is in the language which depends on the browser configuration.

    I need the site to open (start) always in the default language (The client requires this)
    For the moment I cannot figure out how to do this. I cannot switch the redirection mode to "default" because the AjaxSearch will stop to work properly.
    Help is appreciated.

    Regards
      • 22851
      • 805 Posts
      Quote from: ddim at Dec 18, 2009, 09:25 AM

      I have following configuration:

      - YAMS is configured with root name mode
      - YAMS is configured with redirection mode "current". This I need to be able to use AjaxSearch with Ajax mode

      Everything is working fine, except that the starting of the site is in the language which depends on the browser configuration.

      Mode "Current" selects the language of the last visited page if one has already been visited (a cookie has been set) else it selects the default language.

      Mode "Current else browser" selects the language of the last visited page one has already been visited (a cookie has been set) else it selects a best match language based on the browser settings.

      So, unless there is a bug that I haven’t yet discovered, what you say doesn’t make sense to me. I have just tried the following experiment to test it, and I get the desired results. This is easiest to do with two different browsers. Browser 1 - logged into the MODx manager. Browser 2 - browses the website.

      On browser 1.
      1. Set the redirection mode to current.
      2. Check the default language is set correctly. Lets call it [tt]aa[/tt].
      3. If you have changed the default language then clear the site cache.

      On browser 2.
      4. Clear the browser cache, removing all cookies for the site.
      5. Browse to the site home without the root name: [tt]http://mysite.com/[/tt]. You should be redirected to the default language home page: [tt]http://mysite.com/aa/[/tt].
      6. Now browse to a page in a different language, [tt]bb[/tt].
      7. Revisit the site home without the root name. This time you should be redirected to a page in the language [tt]bb[/tt].

      Now repeat the test with a different language.

      Perhaps you are expecting that if the user leaves the site and comes back that they will be redirected to the default language page once again. However, unless their yams_lang browser cookie has expired since or is cleared somehow this wont work. Currently the language cookie is hard-wired to expire after a period of 7 days, but I could give you instructions for how to change it or make it configurable via the module interface if you like.
        YAMS: Yet Another Multilingual Solution for MODx
        YAMS Forums | Latest: YAMS 1.1.9 | YAMS Documentation
        Please consider donating if you appreciate the time and effort spent developing and supporting YAMS.
        • 6848
        • 52 Posts
        sorry for late reply, I solved my case.
        I do not know if this is interesting for someone else, but to explain it:

        1. The client wants that the site is opened in the default language (In my case Bulgarian) independent on the browser settings.
        Very often here the operating system and the browsers are configured for default English, so I cannot use "current else browser".
        With such a configuration in 60-70% of the initial visits the site would open in English, which is not the behavior wanted by the client.

        2. I want the search to work in Ajax mode. The only way I managed to achieve this to work properly is with setting the YAMS mode to "current".
        Actually what happens is, that the search results are OK, but the links are not good for YAMS
        and independent where the result is found (in English or Bulgarian part of the page) the link is the same.
        With mode set to "current" the result is correct in 99% of the cases, because normal user behavior is to search in the language he sees currently.

        These 2 requirements are partially contradicting
        - initial open in the default language independent on the browser setting and needed "current" mode of YAMS to have proper search behavior

        How I solved this:
        - Generally speaking with quite dirty redirect
        -- created start page with monolingual template
        -- in this page simple snippet is called, which redirects to the real start page with proper root setting.
        The snippet looks like this:
        <?php
        header('Content-language: bg');
        header('HTTP/1.1 301 Moved Permanently');
        header('Location: http://www.bbr.bg/bg/bulgarian-development-bank.html');
        ?>


        As you can see this is quite dirty, but it solves the problem I have.

        I don’t know if this problem is not too specific,
        but clean and elegant solution would be if YAMS has mode, which is "current else default"

        I would expect such configuration is needed in countries where it is normal to use the OS (and browsers configuration) in English,
        But to expect the sites to open in different language smiley

        Regards,
          • 22851
          • 805 Posts
          Hi ddim

          You have chosen to use a root name for each language:
          example.com/bg/
          example.com/en/
          ...

          This means that when a user visits example.com/ it is unclear which language was intended or is the most appropriate to display. In that case some guessing/logic has to take place. YAMS provides different redirection modes:

          Default
          Redirect to the correct URL for the default language.
          Current
          Redirect to the correct URL for the current language, whatever that happens to be. (Will be the language of the last multilingual page if they have previously visited one, or the default language.)
          Current else Browser
          Redirect to the correct URL for the current language, whatever that happens to be. (Will be the language of the last multilingual page if they have previously visited one, else it will be determined from the browser settings, else the default language.)
          Browser
          Choose the language based on the Accept-Language request header. If a suitable language doesn’t exist then use default language. Redirect to the correct URL for the language.
          Note that ’Current’ mode is actually doing ’Current else Default’ (which is something you were looking for?) - Perhaps I should rename this option.

          You have removed the ambiguity by including a permanent redirect from the site root to the Bulgarian home page. A different way to achieve the same thing but avoid the permanent redirect (which would probably not be very search engine friendly, because you generally want them to index example.com rather than example.com/bg/...) would be to remove the root name from the default language (Bulgarian in your case) so making it the site root:

          example.com/ (Bulgarian)
          example.com/en/ (English)
          ...

          Then anyone visiting example.com will see the Bulgarian home page and no redirection is required. Remember to update your htaccess if you remove the root name.

          A quick note about AjaxSearch. Normally the AjaxSearch snippet is set up to only search within the template variables of the current language. The URLs in the search results are standard MODx URLs and either ’Current’ or ’Current else Browser’ mode needs to be used to ensure that when a user clicks on a search result they are taken to a page that’s displayed in the correct language (eg: the language of the page containing their search term = the current language). This should be correct 100% of the time. I don’t currently know of a way to search across all languages and have the result displayed in whatever language contained the search term, if that’s what you were looking for.
            YAMS: Yet Another Multilingual Solution for MODx
            YAMS Forums | Latest: YAMS 1.1.9 | YAMS Documentation
            Please consider donating if you appreciate the time and effort spent developing and supporting YAMS.