Display available translations

Author Message

Kjell Knudsen

Thursday 12 August 2004 2:16:23 am

Searching for an hour for the answer to this - really strange I can't find.

Want to list the available translations of an object on the user side, with links to display them. (similar to how they are listed on right in admin)

Also wondering at how to change the name of the language - since I just want it to eg say "Spanish" or "Español" and not "Castillan (Spain)".

regards,

-kjell

Kjell Knudsen
http://www.icbl.org

Bård Farstad

Thursday 12 August 2004 5:26:46 am

Kjell,

Try something like this.

{section var=translation loop=$node.object.current_version.translation_list}
   {$translation}
{/section}

--bård

Documentation: http://ez.no/doc

Bård Farstad

Monday 16 August 2004 4:53:40 am

And the code which also will show a link would look something like:

{section var=translation loop=$node.object.current_version.translation_list}
   <a href={concat($node.url_alias,'/(language)/',$translation )|ezurl}>{$translation}</a>
{/section}

Normally we use different site accesses for the different translations, then the link would be different. E.g. with language code prepended in the url.

--bård

Documentation: http://ez.no/doc

Kjell Knudsen

Friday 03 September 2004 2:04:09 am

Here's the code which Peter made for me in the end- which solved all my issues very nicely. Listing the additional translations if there are any, and also allows me to override the system names for the languages:

{* Code to show list of translations *}
{* to use pictures, instead of text uses st.like this: 'esl-ES',concat('<img src=',"picture_name.png"|ezimage,'/>') *}

{let languages=hash('cat-ES','Catalan', 'chi-CN','Chinese', 'cze-CZ','Czech', 'dan-DK','Danish', 'dut-NL','Dutch', 'eng-CA','English (Canada)', 'eng-GB','English (United Kingdom)', 'eng-US','English', 'esl-ES','Español', 'esl-MX','Castillan', 'fin-FI','Finnish', 'fre-CA','French (Canada)', 'fre-FR','Français', 'ger-DE','German (Germany)', 'hun-HU','Hungarian', 'ita-IT','Italian', 'nno-NO','Norwegian (Nynorsk)', 'nor-NO','Norwegian (Bokmal)', 'pol-PL','Polish', 'por-BR','Portuguese (Brasil)', 'por-MZ','Portuguese (Mozambique)', 'por-PT','Portuguese (Portugal)', 'rus-RU','Russian', 'swe-SE','Swedish')

all_translations=$node.object.current.translation_list}
    {section show=$all_translations|count|gt(0)}
    <div class="translations">
	    {section var=translation loop=$node.object.current.translation_list}
                <a href={concat($node.url_alias,'/(language)/',$translation.item.language_code)|ezurl}>{$languages[$translation.item.language_code]}</a> | 
            {/section}
    </div>
    {/section}
{/let}

Kjell Knudsen
http://www.icbl.org

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.