0 Replies Latest reply: Aug 4, 2014 10:34 AM by GS1234 RSS

    Multi-lingual sites

    GS1234 Community Member

      Hi all,

      I could not find a good JavaScript for support of multi-lingual BC sites so I have created my own script that will replace the URL pathname and do conditional redirects to support multi-language sites. Don't know if it's overkill but it works as expected and the code is easy to read. Don't know how efficient the code is, probably a javascript ninja can do it better.

       

      It now has everything needed for multi-language support such as:

       

      • visitor can set language manually
      • cookie is created and read to store and read visitors language choice
      • support for multiple languages
      • support for any number of path name items in the URL
      • does not break the back button
      • workaround for BC's inability to automatically request the index page of a subfolder
      • set language based on visitors country location

       

      The script does seem to work on mobile devices, I have tested it on Android 4.3 and 2.3.6

       

      Found an edge case. If you selected a language when on the root page you get redirected to /[_language]/ (eg /_se/) which does not work they will get a Page not found. Therefore you should have a list of suggested links on the Page not found page.

       

      Subfolder without trailing / works, for example: /_se by making it as a page and then do a 301 redirect to /_se/index

       

      Check it out here: https://gist.github.com/Molnfront/da1f0bd7a0264fa8f477

      Example here: http://cashnew.businesscatalyst.com (switch between English and Swedish. Default english)