OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



modified languageToggle plugin

The Plugin Gallery is a venue for users of PKP software to share their plugins.

Moderators: jmacgreg, michael, John

Forum rules
If you post a plugin here, please include information on which versions of which applications it is compatible with. Attach a tarball of the plugin (e.g. tar cvzf myPlugin-0.1.tar.gz plugins/generic/myPlugin). Thanks for contributing!

modified languageToggle plugin

Postby kuzma » Tue Dec 01, 2009 6:30 am

Beginning with OxS localization, I've realised that standard languageToggle plugin is not always useful, because it hides language names, so how somebody can guess box called "Idioma" or "Язык" can switch language to English? Better approach is to show all language links simultaneously (see A below). Another good practice is to use small national flag pictures to switch language (see B below).

A) To make textual language links, modify plugins/blocks/languageToggle/block.tpl as follows:
Code: Select all
{if $enableLanguageToggle}
<div class="block" id="sidebarLanguageToggle">
   {foreach from=$languageToggleLocales key=langkey item=langname}
      {if $langkey == $currentLocale}
         {$langname}
      {else}
         <a href={if $languageToggleNoUser}'{$currentUrl|escape}{if strstr($currentUrl, '?')}&{else}?{/if}setLocale={$langkey}'{else}'{url page="user" op="setLocale" path=$langkey source=$smarty.server.REQUEST_URI escape=false}'{/if}>
            {$langname}
         </a>
      {/if}
   {/foreach}
</div>
{/if}


B) File plugins/blocks/languageToggle/block.tpl needs following modifications to achieve the "flag toggling":
Code: Select all
{if $enableLanguageToggle}
<div class="block" id="sidebarLanguageToggle">
   {foreach from=$languageToggleLocales key=langkey item=langname}
      {if $langkey == $currentLocale}
         <img src="{$baseUrl}/plugins/blocks/LanguageToggle/locale/{$langkey}/flag.png" alt="{$langname}" title="{$langname}" width="24" height="16" />
      {else}
         <a class="icon" href={if $languageToggleNoUser}'{$currentUrl|escape}{if strstr($currentUrl, '?')}&{else}?{/if}setLocale={$langkey}'{else}'{url page="user" op="setLocale" path=$langkey source=$smarty.server.REQUEST_URI escape=false}'{/if}>
            <img src="{$baseUrl}/plugins/blocks/LanguageToggle/locale/{$langkey}/flag.png" alt="{$langname}" title="{$langname}" width="24" height="16" />
         </a>
      {/if}
   {/foreach}
</div>
{/if}

Also picture file flag.png is needed for each locale of languageToggle plugin:
plugins/blocks/LanguageToggle/locale/en_US/flag.png
plugins/blocks/LanguageToggle/locale/ru_RU/flag.png
...
Size of pictures in block.tpl should be adjusted to flag.png size (24x16 assumed in code above).
kuzma
 
Posts: 6
Joined: Tue Dec 01, 2009 5:28 am

Re: modified languageToggle plugin

Postby mendesrocha » Tue Dec 27, 2011 5:01 pm

Kuzma!

Thanks a lot for your code. It was very useful to achieve a Manager request.

Only a little correction: in the plugin address you capitalized the the first letter of plugin name and it is currently lowercase.

So in lines 5 and 9, instead of

Code: Select all
5,9   <img src="{$baseUrl}/plugins/blocks/LanguageToggle/locale/{$langkey}/flag.png" alt="{$langname}" title="{$langname}" width="24" height="16" />


you should write

Code: Select all
5,9   <img src="{$baseUrl}/plugins/blocks/languageToggle/locale/{$langkey}/flag.png" alt="{$langname}" title="{$langname}" width="24" height="16" />
mendesrocha
 
Posts: 176
Joined: Mon Nov 05, 2007 11:10 am
Location: Brazil

Re: modified languageToggle plugin

Postby clairemarcade » Wed May 07, 2014 4:05 am

Hello,

Thank you for your explication.
I succeed to put the flags to choose the language.
But my problem is only the flag of my primary locale who have link is work. I Click on the same flag to change between the 2 languages. The other Flag's link doesn't work..
Do you have some ideas of this origin problem ?


Claire
http://alpha.portaildupatrimoineoral.org
clairemarcade
 
Posts: 11
Joined: Thu Mar 27, 2014 9:42 am


Return to Plugin Gallery

Who is online

Users browsing this forum: No registered users and 0 guests