0

I have site translations that works with language prefix

m.mysite.com/ - default language (lithuanian)
m.mysite.com/en - english
...

If i translate site to foreign language and pushed menu button on mobile website, it redirects to the default language.
For example, if I were in m.mysite.com/en (website translated in english) and pressed button "News" it redirects me to m.mysite.com/news-page that is in default language.

I should redirect to m.mysite.com/en/news-page that is translated in english and has language prefix /en/.

So, how to add language prefix to the link and redirect correctly (without losing current site translation)?

1 Answer 1

0

We've come across a similar problem in our site on a desktop platform. So far, we've discovered the following about links in Drupal (for example, the href on an <a> tag in a Block Body):

  • If you use a link without a preceding /, Drupal will replace the last url element with your link name (i.e. mysite.com/en/area1/thing1 will become mysite.com/en/area1/thing2 when a user clicks a link configured as href="thing2" on a page in area1).

  • If you use a preceding / in your link, Drupal appends it to the domain directly (i.e. href="/thing2" directs to mysite.com/thing2).

We leveraged this to make language prefixes work, with limited success. As long as all our links are within the same uri path (i.e. all links on pages within area1 go to area1 pages), the language prefix is preserved. Once you try to leave that path, though (i.e. href = "/area2/thing3" on a page in area1), you must use the / and lose the language prefix. For those pages, you'll need to add URL aliases. We're still looking for a module/solution that saves us the time and effort of aliasing our menu system and cross links.

Note that in any case the base url (mysite.com) is preserved, so you should get the same results regardless of your platform (mobile or desktop).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.