How to select language?

Author Message

Osichr Hayez

Monday 12 June 2006 2:36:07 am

eZ publish 3.6.8:

I enabled 2 languages in my setupwizard during installation. All my articles are on the primary language, but only a few on the secondary language.

I've created a couple of flags with links at my plagelayout.tpl, but I cant make them work as I want. What code do I need to embed to let my users switch between the languages?

Stéphane Bullier

Tuesday 13 June 2006 12:44:24 am

Hello,

You can use for example :

{if eq( $site.http_equiv.Content-language, fr-FR)}	
		<a href="{concat('http://www.exemple.com/en/', $DesignKeys:used.url_alias)}">English version</a>
		{else}			
		<a href="{concat('http://www.exemple.com/fr/', $DesignKeys:used.url_alias)}">Version française</a>
		{/if}

Stéphane

J-A Eberhard

Tuesday 13 June 2006 2:06:15 am

You can also use a loop and a direct link to the same page in another language

<ul>
        {def $locales=fetch( 'content', 'translation_list' )}
  		{foreach $locales as $locale}
  			<li>
<a href={concat("../",$locale.country_code|downcase(),"/",$module_result.content_info.url_alias)|ezurl}  >{$locale.language_name}</a>
                       </li>
  			{/if}
		{/foreach}
	{undef}
</ul>

Open Source Solution Provider
Open-Net Ltd Switzerland
http://www.open-net.ch

Osichr Hayez

Tuesday 13 June 2006 2:31:26 am

Thanks for your replies! I have now got it working using the siteaccess method.

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

eZ debug

Timing: Jan 31 2025 05:33:46
Script start
Timing: Jan 31 2025 05:33:46
Module start 'layout'
Timing: Jan 31 2025 05:33:46
Module start 'content'
Timing: Jan 31 2025 05:33:46
Module end 'content'
Timing: Jan 31 2025 05:33:46
Script end

Main resources:

Total runtime0.0171 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0052 588.1328151.2109
Module start 'layout' 0.00520.0029 739.343836.6484
Module start 'content' 0.00820.0073 775.992290.1563
Module end 'content' 0.01550.0017 866.148433.9922
Script end 0.0171  900.1406 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002413.9744140.0002
Check MTime0.00116.1430140.0001
Mysql Total
Database connection0.00126.754910.0012
Mysqli_queries0.002413.988330.0008
Looping result0.00000.104310.0000
Template Total0.00127.210.0012
Template load0.00105.734110.0010
Template processing0.00021.429710.0002
Override
Cache load0.00063.628510.0006
General
dbfile0.002212.664380.0003
String conversion0.00000.041740.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs