LocaleBundle
LocaleBundle copied to clipboard
Include Language Icon
See: http://www.languageicon.org/index-icon.php
I think that this kind of feature should be an "application" issue. Generic bundles/libs can't satisfy those needs in a "decent" way. Too many ways to represent the same thing.
@goetas Imo covering half of the possible use-cases is already a win.
I've made a version of the template which does as the language icon site advices:
<div id="language">
<form action="/" method="get">
<label for="languages">
<img src="languageicon.png" alt="" />
{{ ("language.switch")|trans }}
</label>
<select id="languages" name="languages">
{% for locale in locales %}
{# The locale is current, if the current_locale starts with it. #}
{% if locale.locale == current_locale|slice(0, locale.locale|length) %}
<option selected="selected" value="{{ locale.link }}">{{ locale.locale_current_language }}</option>
{% else %}
<option value="{{ locale.link }}">{{ locale.locale_target_language }} ({{ locale.locale_current_language }})</option>
{% endif %}
{% endfor %}
</select>
</form>
</div>
You do have to download the icon from http://www.languageicon.org/downloads.php . Also, for the current locale to show up, make sure you add this setting:
lunetics_locale:
switcher:
show_current_locale: true
The select needs an onchange, you can do this with jquery:
function observeLanguageSwitcher()
{
(function($){
$('#languages').change(function() {
window.location.href = this.value;
});
})( jQuery );
}
jQuery(function($){
observeLanguageSwitcher();
});