0

Ok, I have my own menu on my multilingual site. I have a page with the alias "about" in english. And english is my default language. So, when I am browsing the site in spanish I would like the spanish alias. I have tried all combinations I can think of to get the url() fucntion to translate "about" to "acercade",as it is in the system. What would be the correct way? Is it even working?

url('about',array=("absolute"=>TRUE, "alias"=>TRUE)) ;

thats my best guess.

Thanks for any hint, Michael

1 Answer 1

3

No need for $options['alias'] = TRUE, that will prevent alias lookup.

If you provide an internal path and $options['alias'] is set to TRUE, the path is assumed already to be the correct path alias, and the alias is not looked up.

Use the node/$nid path and let Drupal find the correct alias.

If that doesn't work, you could try manually passing the $options['language'] parameter

'language': An optional language object. If the path being linked to is internal to the site, $options['language'] is used to look up the alias for the URL. If $options['language'] is omitted, the global $language_url will be used.

https://api.drupal.org/api/drupal/includes%21common.inc/function/url/7

2
  • Hi, thanks for your answer. Ok, so when I do the following: url('node/6', array( "language" => language_list()['es'])); what i get is /es/node/6. So while this works technically, I do not get the translation, which would be better for search engines.
    – dmeu
    Commented Oct 29, 2013 at 16:38
  • is it possible that it is a problem that the translation in spanish (es) does not have node-id 6 but 8?
    – dmeu
    Commented Oct 29, 2013 at 16:51

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.