Forums / Setup & design / Link to translation of an article

Link to translation of an article

Author Message

Ted Striker

Wednesday 18 February 2009 3:31:44 pm

Hi!

I'm working on a multilanguage site, what I'm doing is trying to put a link from an article to it's translation to another language (if exists).

how can I do this?

Thanks in advance.

Can you feel it Mr. Anderson? Closing in on you? Oh I can, I really should thank you after all. It was, after all, it was your life that taught me the purpose of all life. Purpose of life is to end.

Norbert Wagner

Thursday 19 February 2009 4:50:31 am

It depends on your exact needs.
Do you have different SiteAccesses for every language and want to put a link to between them remaining on the same content in the other language?
Or would you just want to show the other language on the same siteaccess?

The latter one can bee achieved by using a list fetch specifying the language[1], which could be passed as custom view parameters[2].

[1] http://ez.no/doc/ez_publish/technical_manual/4_0/reference/modules/content/fetch_functions/list
[2] http://ez.no/doc/ez_publish/technical_manual/4_0/templates/basic_template_tasks

Happy coding,
Norbert

Ted Striker

Thursday 19 February 2009 6:22:42 am

Thanks Norbet,

Whay I have is 2 siteaccesses (/en for english and /es for spanish) and I want to put a link in the english site's top of the page to go to the spanish version of the page.

Is that possible?

How can I retrieve this info from the $module_result? (that's because the link is on in the design and not in the content)

Thnaks again!

 

Can you feel it Mr. Anderson? Closing in on you? Oh I can, I really should thank you after all. It was, after all, it was your life that taught me the purpose of all life. Purpose of life is to end.

Norbert Wagner

Thursday 19 February 2009 7:05:27 am

I did it like this:

<a 
href={concat("/index.php/en/",$requested_uri_string)|ezroot}><img src={'eng-US'|flag_icon()} alt="english"></img></a>

Obviously you have to adjust it for your case. If you are using vhost mode with subdomains it could work like this:

<a 
href="http://en.yourdomain.com/"{$requested_uri_string}"><img src={'eng-US'|flag_icon()} alt="english"></img></a>

I don't know if this is the best way to do it, but for me it works.

Regards,
Norbert

André R.

Thursday 19 February 2009 8:21:06 am

Ted:
http://ez.no/developer/contribs/hacks/fetch_multilingual_url_alias_by_locale

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

justin kazadi

Thursday 19 February 2009 9:12:12 am

Hi,
ted said that he want to show the link only if the translation exit:

.... it's translation to another language (if exists).

for this i think you can use this code:

{def  $counter='' }
{set $counter=$node.object.available_languages|count-1}

{for  0 to $counter as $counters}
                    {if  $node.object.available_languages[$counters]|eq('eng-GB')}

                      {* here use the fetch_url_alias operator like said Andre R 
                         replace eng-GB by your desired code of country
                      *}

		{break}
		{/if}
	{/for}

best regards

The theory is when we know everything and nothing works.
The practice is when everything works and nobody knows why.
If the practice and theory are met, nothing works and we do not know why.

Albert Einstein

Ted Striker

Friday 20 February 2009 12:47:55 am

Thank you everybody for the answes.

I'm going to try some of this codes!

Can you feel it Mr. Anderson? Closing in on you? Oh I can, I really should thank you after all. It was, after all, it was your life that taught me the purpose of all life. Purpose of life is to end.