Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Langswitcher update language name

Started by Muut Archive 10 years ago · 3 replies · 535 views
10 years ago

Hello

Updating langswitcher plugin made language name variable {{ native_name(key)}} output as 1 or 2 instead of Engish or 日本語.
There's an issue https://github.com/getgrav/grav-plugin-langswitcher/issues/10 but no solution.
here the code of langswitcher.html.twig

TWIG
<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 }}">{{  native_name(key)|capitalize }}</a></li>
{% endfor %}
</ul>
--- 
Here is output:

<li>
<a href="/1" class=" external"></a>
</li>
<li>
<a href="/2" class=" external"></a>
</li>

TXT
I have also tried to see the API by myself, but was not able to find out.

As I wonder if it's not related to settings in `system.yaml` and I am not really able to understand them, please find them below for more complete information: 

languages:
supported:

  • fr
  • ja
  • en
    session_store_active: true # Store active language in session
    http_accept_language: true # Attempt to set the language based on http_accept_language header in the browser
    override_locale: true # Override the default or system locale with language specific one
    TXT
    
    

Thanks in advance for help

10 years ago

What version of Grav are you on? I'm not having this problem with latest Grav 1.1

10 years ago

1.1.1. (thank you) (in the issue linked above, Flavio is not able to recreate the problem either...)

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1368 9 years ago
Archive · by Muut Archive, 9 years ago
2 940 9 years ago
Archive · by Muut Archive, 9 years ago
2 4069 9 years ago
Archive · by Muut Archive, 9 years ago
1 2960 9 years ago
Archive · by Muut Archive, 9 years ago
3 1125 9 years ago