LocaleBundle icon indicating copy to clipboard operation
LocaleBundle copied to clipboard

Include Language Icon

Open lunetics opened this issue 13 years ago • 3 comments

See: http://www.languageicon.org/index-icon.php

lunetics avatar Jun 07 '12 16:06 lunetics

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 avatar Jan 27 '14 08:01 goetas

@goetas Imo covering half of the possible use-cases is already a win.

kingcrunch avatar Jan 28 '14 11:01 kingcrunch

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();
});

Mondane avatar Jun 09 '14 08:06 Mondane