Hi Folks,
from the search I saw that many people have the same request, like me, to habe a language switch option for the page that displays as buttons or images (maybe these cute little flags as seen on many sites). I modified the dynamic_locale plugin to do this for me, the code is as follows:
`
<?php
// comments removed for better readability
$plugin_description = gettext("Enable <strong>dynamic-locale to allow viewers of your site to select the language translation of their choice.");
$plugin_author = "Stephen Billard (sbillard) mod by chross";
$plugin_version = '1.2.6_mod';
$plugin_URL = "
http://www.zenphoto.org/documentation/plugins/_plugins---dynamic-locale.php.html";
function printLanguageSelector($class='') {
global $_zp_languages;
if (isset($_POST['dynamic-locale'])) {
$locale = sanitize($_POST['dynamic-locale'], 0);
if (getOption('locale') != $locale) {
echo '
';
echo '
'.sprintf(gettext('%s is not available.'),$_zp_languages[$locale]).
' '.sprintf(gettext('The locale %s is not supported on your server.').
''.gettext('See the troubleshooting guide on zenphoto.org for details.'), $locale);
echo '
';
echo '';
}
}
if (!empty($class)) { $class = " class='$class'"; }
echo "\n
\n";
echo ''."\n";
echo '';
echo ''."\n";
echo ''."\n";
echo "\n";
echo "
\n";
}
?>
`
As you can see, the languages are hardcoded as images type buttons (could be done dynamically though, I've seen something similar in the forums).
The one caveat where I need your help is Internet Explorer 8's (and maybe all former versions as well) handling of these buttons: The image buttons submit the language as value for example value="en_US", but the Internet Explorer instead of the value submits the coordinates of the click on the image. This way, language won't change in IE but does well in Firefox.
Any suggestions to circumvent this problem?
Cheers,
chross
Comments
`
.language_button {width: 32px; min-width: 32px; height: 32px; min-height: 32px; overflow: hidden; border: none; font-size: 0px;}
.language_button:focus {outline: none; cursor:pointer; cursor:hand}
.language_button:hover {outline: none; cursor:pointer; cursor:hand}
#dynamic-locale_de { background: transparent url(http://www.website.com/cms/media/flags/de.gif) no-repeat;}
#dynamic-locale_en { background: transparent url(http://www.website.com/cms/media/flags/en.gif) no-repeat;}
`
I'm using this CSS to style regular input buttons. This is very well compatible in IE and FF.
This is the plugin code now:
`
<?php
$plugin_description = gettext("Enable <strong>dynamic-locale to allow viewers of your site to select the language translation of their choice.");
$plugin_author = "Stephen Billard (sbillard) mod by chross";
$plugin_version = '1.2.6_mod';
$plugin_URL = "http://www.zenphoto.org/documentation/plugins/_plugins---dynamic-locale.php.html";
'function printLanguageSelector($class='') {
global $_zp_languages;
if (isset($_POST['dynamic-locale'])) {
$locale = sanitize($_POST['dynamic-locale'], 0);
if (getOption('locale') != $locale) {
echo '
echo '
'.sprintf(gettext('%s is not available.'),$_zp_languages[$locale]).
';' '.sprintf(gettext('The locale %s is not supported on your server.').
''.gettext('See the troubleshooting guide on zenphoto.org for details.'), $locale);
echo '
echo '
}
}
if (!empty($class)) { $class = " class='$class'"; }
echo "\n
echo ''."\n";
echo '';
echo ''."\n";
echo ''."\n";
echo "\n";
echo "
}
?>
`
Thank you.