Print translated links in custom page--front.tpl.php I have a custom template for my front page, where I have to manually set URLs. Some of them are Views paths (such as news), some - aliased node URLs (projects/project-1). How to get their path translation URL in raw PHP code?

If I say something like:

&lt;a href="&lt;?php print url('news', array('language'=&gt; $langcode, 'alias' =&gt; TRUE)) ?&gt;" ...&gt;&lt;/a&gt;

the rendered link is invalid langauge-crossed, such as mysite.com/es/news.

I tried also with the l() function but I'm getting untranslated link pointing to the root mysite.com/news.
This might be an obvious answer to experts, but hopefully this will help some newbie someday. I painstakingly investigated the url stuff in Drupal and my findings surprised me - especially when I referred them to the docs.

In the tpl I placed the following nasty debug lines:

&lt;?php dpm(drupal_get_normal_path('alias-en')) ?&gt;
&lt;?php dpm(drupal_get_normal_path('alias-en', 'es')) ?&gt;
&lt;?php dpm(drupal_get_normal_path('alias-en', 'en')) ?&gt;
&lt;?php dpm(drupal_get_normal_path('en/alias-en')) ?&gt;
&lt;?php dpm(drupal_get_normal_path('/en/alias-en')) ?&gt;
&lt;?php dpm(drupal_get_normal_path('es/alias-es')) ?&gt;
&lt;?php dpm(drupal_get_normal_path('/es/alias-es')) ?&gt;


And the results were:

alias-en
alias-en
node/298
en/alias-en
/en/alias-en
es/alias-es
/es/alias-es


Only the third result (node/298) was returned as desired, good for passing to i18n_get_path_translations. Even though the drupal_get_normal_path() function docs say the language parameter is optional, and subsequently called drupal_lookup_path() is said to put current language if NULL is passed, it does not seem to work this way.

drupal_get_normal_path() seems to require that you pass two parameters: alias and the language the alias is set for. Only then you'll get the result that will work reliably with i18n_get_path_translations.

I'm close to thinking it is a bug in Drupal or docs, and if no one sheds light on me, I'm going to file an issue.