getgrav / grav-plugin-langswitcher

Grav LangSwitcher Plugin
https://getgrav.org
MIT License
28 stars 26 forks source link

[Suggestion and request] the plugin is poor configuration #38

Closed utherbone closed 2 years ago

utherbone commented 6 years ago

There are no options to use flags;

I have modified the code a bit since the first versions and it seems to work in the last, here it is:

https://github.com/getgrav/grav-plugin-langswitcher/blob/develop/templates/partials/langswitcher.html.twig

<style>
a.active img {
    width: 30px !important;
    height 40px !important;
}
</style>
<ul class="langswitcher">
{% set langobj = grav['language'] %}

{% for key in langswitcher.languages %}

    {% if key == langswitcher.current %}
        {% set lang_url = page.url %}
        {% set active_class = ' active' %}
    {% else %}
        {% set lang_url = base_url_simple ~ langobj.getLanguageURLPrefix(key)~langswitcher.page_route ?: '/' %}
        {% set active_class = '' %}
    {% endif %}

    <li><a href="{{ lang_url ~ uri.params }}" class="external{{ active_class }}">{% if native_name(key) == 'Português (br)' %}{{ '<img width="20px"  src="/images/langswitcher/br-flag.svg" />' }}{% else %}{{ '<img width="20px" src="/images/langswitcher/us-flag.svg" />' }}{% endif %}</a></li>

{% endfor %}
</ul>

I think it would be great to give some settings as a flag option for each language.

rhukster commented 2 years ago

Flags are for countries not languages and are considered bad practice. closing.