What is the best way to get absolute url with correct language prefix?
The url()
function accepts language parameter but it seems that it is not using it to generate the prefix - only to get translated alias. I don't care about aliases - I need correct domain prefix.
When I'm on http://en.example.com/something
and use this code:
<?php
$all_languages = language_list();
url('something-else', array('language' => $all_languages['nl'], 'absolute' => true));
?>
I will get this: http://en.example.com/something-else
(en prefix).
How can I get this: http://nl.example.com/something-else
(nl prefix).
url
is not allowed to base it's choices on the target's language. How could it when target usually does not have any?language
parameter) if you are still redirecting user to a different language version than the alias language?undefined
), so only the third is taken into account byurl()
. I never said it's good, right?url()
to know language of the target element. That is not the point of my question. I would only want it to set the prefix specified by thelanguage
parameter. After all I am providing language different than current$base_url
not without a reason :)