If the links are menu items the destinations of the links are always with the language inherited from the previous pages. But how can I do the same thing for the internal links using ordinal <a href=""> tags? I have some internal links in some blocks but those links can't keep the language prefix the use is currently viewing of. For example:

<a href="/about-us"> takes the user to my-site.com/about-us though the user is currently viewing the page with the language prefix "jp" which is Japanese. But I would like to make the destination of the link to my-site.com/jp/about-us.

I've been searching for the solution for days but no luck so far. I have tried pathfilter and pathologic but they don't seem to work for this purpose.

1 Answer 1


Generally you want to use Drupal core functions as much as possible. Both the l() and url() functions fit perfectly your need. The difference between them is that l() returns an anchor tag, and url() returns a URL without HTML.

As a perk, the l() function allows you to specify the language for the link. Example:

$options = array('language' => 'jp');
$link = l('About Us', 'about-us', $options);
  • Your solution will only work if PHP Filter module is enabled and the whole block or node content is composed in the PHP input format, is that correct? This seems very dangerous, as I don't want to grant all editors PHP permissions but I will need all internal links within their content to properly respect language prefixes. Is there a workaround?
    – deinqwertz
    Commented Jul 29, 2013 at 0:17
  • @deinqwertz your response is true granted that you are entering that code into a block using the Drupal GUI. Yes, you are correct, this is not safe and should be avoided if possible. However my solution is more geared towards developers who are creating their blocks from within custom modules–as opposed the GUI. Commented Aug 2, 2013 at 6:17

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.