From: Sylvie G. <sgr...@gm...> - 2009-02-08 20:00:20
|
The language mapping is in lang/langmapping.php. So I do not think you need to duplicate the information??? My 2 cents On Sun, 2009-02-08 at 19:30 +0000, jon...@us... wrote: > Revision: 16614 > http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=16614&view=rev > Author: jonnybradley > Date: 2009-02-08 19:30:43 +0000 (Sun, 08 Feb 2009) > > Log Message: > ----------- > [NEW] Adding mode=flags to mod-switch_lang to show little flags for languages where available. > Retains previous behaviour (optional mode=menu) > New lang/flagmapping.php table with initial default flags where obvious - hope they don't cause any international incidents! Please update where necessary ;) > Minor mod to renderlib to expose previously calculated $trads var (translations of current page) to PHP for effieciency. > New CSS class (.unavailable) for languages not available for exising object (with defaults in 2.0to3.0.css) > > Modified Paths: > -------------- > trunk/lib/wiki/renderlib.php > trunk/modules/mod-switch_lang.php > trunk/styles/transitions/2.0to3.0.css > trunk/templates/modules/mod-switch_lang.tpl > > Added Paths: > ----------- > trunk/lang/flagmapping.php > > Property Changed: > ---------------- > trunk/temp/cache/ > > Added: trunk/lang/flagmapping.php > =================================================================== > --- trunk/lang/flagmapping.php (rev 0) > +++ trunk/lang/flagmapping.php 2009-02-08 19:30:43 UTC (rev 16614) > @@ -0,0 +1,50 @@ > +<?php // -*- coding:utf-8 -*- > +/** \brief This table associates language country (flag name) and language name in the current language > +* PLEASE : Translators, update this file with your flag for your own language (if applicable) > +**/ > + > +//this script may only be included - so its better to die if called directly. > +if (strpos($_SERVER["SCRIPT_NAME"],basename(__FILE__)) !== false) { > + header("location: index.php"); > + exit; > +} > + > +$flagmapping = array( > + 'ar' => array( ''), > + 'ca' => array( 'Spain'), > + 'cn' => array( 'Cina'), > + 'zh' => array( 'China'), > + 'cs' => array( 'Czech_Republic'), > + 'da' => array( 'Denmark'), > + 'de' => array( 'Germany'), > + 'en' => array( 'United_States'), > + 'en-uk' => array( 'United_Kingdom'), > + 'es' => array( 'Spain'), > + 'el' => array( 'Greece'), > + 'fa' => array( ''), > + 'fi' => array( 'Finland'), > + 'fj' => array( 'Fiji'), > + 'fr' => array( 'France'), > + 'gl' => array( ''), > + 'he' => array( 'Israel'), > + 'hr' => array( 'Croatia'), > + 'it' => array( 'Italy'), > + 'ja' => array( 'Japan'), > + 'ko' => array( 'Korea'), > + 'hu' => array( 'Hungary'), > + 'nl' => array( 'Netherlands'), > + 'no' => array( 'Norway'), > + 'pl' => array( 'Poland'), > + 'pt' => array( 'Portugal'), > + 'pt-br' => array( 'Brazil'), > + 'ru' => array( 'Russian_Federation'), > + 'sb' => array( 'Solomon_Islands'), > + 'sk' => array( 'Slovakia'), > + 'sr' => array( 'Serbia'), > + 'sr-latn' => array('Serbia'), > + 'sv' => array( 'Sweden'), > + 'tv' => array( 'Tuvalu'), > + 'tw' => array( 'Taiwan'), > + 'uk' => array( 'Ukrain') > +); > +?> > \ No newline at end of file > > Modified: trunk/lib/wiki/renderlib.php > =================================================================== > --- trunk/lib/wiki/renderlib.php 2009-02-08 19:10:21 UTC (rev 16613) > +++ trunk/lib/wiki/renderlib.php 2009-02-08 19:30:43 UTC (rev 16614) > @@ -35,6 +35,7 @@ > > public $canView = false; > public $canUndo = null; > + public $trads = null; // translated pages > > function __construct( $info, $user ) > { > @@ -197,8 +198,8 @@ > include_once('lib/multilingual/multilinguallib.php'); > > if( $this->info['lang'] && $this->info['lang'] != 'NULL') { //NULL is a temporary patch > - $trads = $multilinguallib->getTranslations('wiki page', $this->info['page_id'], $this->page, $this->info['lang']); > - $this->smartyassign('trads', $trads); > + $this->trads = $multilinguallib->getTranslations('wiki page', $this->info['page_id'], $this->page, $this->info['lang']); > + $this->smartyassign('trads', $this->trads); > $pageLang = $this->info['lang']; > $this->smartyassign('pageLang', $pageLang); > } > > Modified: trunk/modules/mod-switch_lang.php > =================================================================== > --- trunk/modules/mod-switch_lang.php 2009-02-08 19:10:21 UTC (rev 16613) > +++ trunk/modules/mod-switch_lang.php 2009-02-08 19:30:43 UTC (rev 16614) > @@ -10,5 +10,30 @@ > //Create a list of languages > $languages = array(); > $languages = $tikilib->list_languages(false, 'y'); > +if (isset($module_params["mode"]) && $module_params["mode"] == 'flags') { > + include('lang/flagmapping.php'); > + global $pageRenderer; > + //$trads = $multilinguallib->getTranslations('wiki page', $page_id, $page, $prefs['language']); > + > + for ($i = 0; $i < count($languages); $i++) { > + if (isset($flagmapping[$languages[$i]['value']])) { > + $languages[$i]['flag'] = $flagmapping[$languages[$i]['value']][0]; > + } > + if (count($pageRenderer->trads) > 0) { > + $languages[$i]['class'] = ' unavailable'; > + for ($t = 0; $t < count($pageRenderer->trads); $t++) { > + if ($pageRenderer->trads[$t]['lang'] == $languages[$i]['value']) { > + $languages[$i]['class'] = ' available'; > + } > + } > + } else { > + $languages[$i]['class'] = ''; > + } > + if ($languages[$i]['value'] == $prefs['language']) { > + $languages[$i]['class'] .= ' highlight'; > + } > + } > + //sort($languages); > +} > $smarty->assign_by_ref('languages', $languages); > > > Modified: trunk/styles/transitions/2.0to3.0.css > =================================================================== > --- trunk/styles/transitions/2.0to3.0.css 2009-02-08 19:10:21 UTC (rev 16613) > +++ trunk/styles/transitions/2.0to3.0.css 2009-02-08 19:30:43 UTC (rev 16614) > @@ -508,3 +508,27 @@ > margin-top: 2em; > font-size: 0.9em; > } > + > +/* flag languages */ > + > +.box-switch_lang .box-data img { > + padding: .2em; > + vertical-align: middle; > +} > + > +.box-switch_lang .box-data img.highlight { > + padding: .1em; > + border: .1em solid #f00 !important; /* too many !importants about! */ > +} > + > +.box-switch_lang .box-data span.highlight { > + border: .1em solid #f00 !important; > +} > + > +.box-switch_lang .box-data img.unavailable, > +.box-switch_lang .box-data span.unavailable { > + opacity: .3; > +} > + > + > + > > > Property changes on: trunk/temp/cache > ___________________________________________________________________ > Modified: svn:ignore > - ???????????????????????????????? > wikiplugin_* > profile???????????????????????????????? > menu_* > fgals_perms_* > wiki-* > fgals_* > > + ???????????????????????????????? > wikiplugin_* > profile???????????????????????????????? > menu_* > fgals_perms_* > wiki-* > fgals_* > thumbnail_* > > > Modified: trunk/templates/modules/mod-switch_lang.tpl > =================================================================== > --- trunk/templates/modules/mod-switch_lang.tpl 2009-02-08 19:10:21 UTC (rev 16613) > +++ trunk/templates/modules/mod-switch_lang.tpl 2009-02-08 19:30:43 UTC (rev 16614) > @@ -1,23 +1,55 @@ > {* $Id$ *} > - > -{if !isset($tpl_module_title)}{assign var=tpl_module_title value="{tr}Site Language:{/tr} `$prefs.language`"}{/if} > +{strip} > +{* params: > + mode: 'menu' or 'flags' (default=menu) > + prefix: Module title prefix text (default='Site Language:') > +*} > +{if !isset($tpl_module_title)} > + {if isset($module_params.prefix)} > + {assign var='prefix' value="{tr}`$module_params.prefix`{/tr}} {* TODO fix tr *} > + {else} > + {assign var='prefix' value="{tr}Site Language:{/tr}"} > + {/if} > + {section name=ix loop=$languages} > + {if $languages[ix].value eq $prefs.language and isset($languages[ix].name)} > + {assign var='name' value=$languages[ix].name|escape} > + {assign var=tpl_module_title value="$prefix $name"} > + {/if} > + {/section} > + {if !isset($tpl_module_title)} > + {assign var=tpl_module_title value="$prefix `$prefs.language`"} > + {/if} > +{/if} > {tikimodule error=$module_params.error title=$tpl_module_title name="switch_lang" flip=$module_params.flip decorations=$module_params.decorations nobox=$module_params.nobox notitle=$module_params.notitle} > {if $prefs.feature_multilingual ne 'y'} > -{tr}This feature is disabled{/tr} > + {tr}This feature is disabled{/tr} > {elseif $prefs.change_language ne 'n' or $user eq ''} > +{if !$module_params.mode or $module_params.mode eq 'menu'} > <form method="get" action="tiki-switch_lang.php" target="_self"> > <select name="language" size="1" onchange="this.form.submit();"> > {section name=ix loop=$languages} > - {if count($prefs.available_languages) == 0 || in_array($languages[ix].value, $prefs.available_languages)} > <option value="{$languages[ix].value|escape}" > {if $prefs.language eq $languages[ix].value}selected="selected"{/if}> > {$languages[ix].name} > </option> > - {/if} > {/section} > </select> > </form> > +{elseif $module_params.mode eq 'flags'} > + {section name=ix loop=$languages} > + {assign var='val' value=$languages[ix].value|escape} > + {assign var='name' value=$languages[ix].name|escape} > + {assign var='flag' value=$languages[ix].flag|escape} > + {assign var='class' value=$languages[ix].class|escape} > + {if $flag neq ''} > + {icon href="tiki-switch_lang.php?language=$val" alt="$name" title="$name" _id="img/flags/$flag.gif" _type="absolute_uri" height=11 class="icon $class" } > + {else} > + {button _text="$name" href="tiki-switch_lang.php?language=$val" _title="$name" _class="$class" } > + {/if} > + {/section} > +{/if} > {else} > -{tr}Permission denied{/tr} > + {tr}Permission denied{/tr} > {/if} > {/tikimodule} > +{/strip} > \ No newline at end of file > > > This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. > > ------------------------------------------------------------------------------ > Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM) > software. With Adobe AIR, Ajax developers can use existing skills and code to > build responsive, highly engaging applications that combine the power of local > resources and data with the reach of the web. Download the Adobe AIR SDK and > Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com > _______________________________________________ > Tikiwiki-cvs mailing list > Tik...@li... > https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs |