Forums / Developer / multi lingual url: how to make a link between two versions ?
Xavier Dutoit
Monday 12 November 2007 8:49:12 am
Hi,
With the new feature allowing multi language urls:http://ez.no/doc/ez_publish/technical_manual/3_10/features/multi_language_support_for_url_aliases
The previous code examples to make link between two linguistic versions doesn't work (well)
When I'm reading example.com/en/company/about_us I wan't to display a french flag with a link to example.com/fr/companie/a_propos
Any example of how to do that ? I didn't remember having seen something.
Any suggestion more than welcome.
X+
http://www.sydesy.com
Stéphane Bullier
Tuesday 13 November 2007 1:09:56 am
Hello Xavier,
I use the template "Template look" and add matrix "Language settings" with 3 colums : Site URL, Siteaccess, Language name.
I fetch the template look :
{def $pagedesign = fetch( 'content', 'object', hash( 'object_id', '54' ) ) } <ul id="languages"> {foreach $pagedesign.data_map.language_settings.content.rows.sequential as $row} {def $site_url = $row.columns[0] $site_access = $row.columns[1] $language = $row.columns[2]} {if $row.columns[0]} {set $site_url = $site_url|append( "/" )} {/if} {if $row.columns[1]} {set $site_access = $site_access|append( "/" )} {/if} {if $row.columns[0]} <li> {if is_set($DesignKeys:used.url_alias)} {if $row.columns[1]|downcase()|eq($access_type.name)} <span>{$language}</span> {else} <a href="{concat( "http://", $site_url, $DesignKeys:used.url_alias )}">{$language}</a> {/if} {else} <a href="{concat( "http://", $site_url, $uri_string )}">{$language}</a> {/if} </li> {/if} {undef $site_url $site_access $language} {/foreach} </ul>
Stéphane
Tuesday 20 November 2007 1:11:03 am
Does it work in 3.10 ? With the multi-lingual url feature activated ?
I have to admit that I didn't test the code you shared with us, but it doesn't look like the
/en/This-address can be transformed into /fr/Cette-adresse
Or am I missing something ?
Tuesday 20 November 2007 1:28:20 am
See a related discussion there:http://ez.no/developer/forum/developer/multi_lingual_url_how_to_make_a_link_between_two_versions
Wednesday 21 November 2007 2:00:18 am
Hello,
Sorry my script was for 3.9 version.
I try to install an 3.10 version with ezwebin_site extension. And the script for switch between language is :
<div id="languages"> {if $locales|count|gt( 1 )} <ul> {foreach $pagedesign.data_map.language_settings.content.rows.sequential as $row} {def $site_url = $row.columns[0] $language = $row.columns[2]} {if $row.columns[0]} {set $site_url = $site_url|append( "/" )} <li{if $row.columns[1]|downcase()|eq($access_type.name)} class="current_siteaccess"{/if}> {if is_set($DesignKeys:used.url_alias)} <a href="{concat( "http://", $site_url, $DesignKeys:used.url_alias )}">{$language}</a> {else} <a href="{concat( "http://", $site_url, $uri_string )}">{$language}</a> {/if} </li> {/if} {undef $site_url $language} {/foreach} </ul> {/if} </div>
This code work for MatchOrder=uri
Wednesday 21 November 2007 3:03:38 am
Thanks for sharing. Are you using it with the new url format ?
Still got an issue, and I can't get both
/en/Company/About-Us and it's translated url/fr/Companie/A-Propos
Does it work for you or did you keep the "old" url format (I wish I had)?
Thursday 22 November 2007 5:33:36 am
I use the new format with default parameters. I don't override transform.ini
fre/Companie/A-proposeng/Company/About-company
But when you switch to fre/Companie/A-propos from eng you have : eng/Companie/A-propos
The url is not refreshed.
Friday 23 November 2007 1:07:00 am
Ok,
I have the same result, with the same page having various urls.
Am I the only one thinking that's really really bad SEO practice ?
Tobias Vogel
Tuesday 27 November 2007 8:23:38 am
I made a custom operator, to fetch the url-alias of a node in a specific language by node-id.
Example usage:
<a href={fetch_url_alias($node.node_id, 'ger-DE')|ezurl()}>Read it in german</a> <a href={fetch_url_alias($node.node_id, 'eng-US')|ezurl()}>Read it in english</a>
The operator is avilable via an extension, see the following link for details more and downloading:http://ez.no/developer/contribs/hacks/fetch_multilingual_url_alias_by_locale
Hope this helps and kind regards,Tobias