Languages overrides?

Hi! I’m testing a multi-language environment - English, Italian, Brazilian Portugues - and I have some questions in regards. I’m used to have “br” as my Brazilian Português lang code, but in Grav is hardcode to Breton. Is it possible to override it or I have to use “pt”?

Another question is much technical. I tested also Kirby which, although too pricy for my budget, it’s very well conceived and easy to tweak. In Kirby I already have created a snippet - in php - which create a flags menu for my language selector. I’m not used to Twig, so I need to ask some help in regard. Is it possible to achieve it in Grav? I’m pretty sure it is, but I haven’t found any topic in this regard in Grav forum…

Many thanks,
Andrea Screen Shot 2015-07-29 at 3

According to the ISO 639-1 language codes, pt is appropriate code.

However, you can use whatever you like although you will be on your own with any first or 3rd party provided translations. Also you might have to provide your own custom langswitcher plugin as this is displaying the language based on the ISO codes that are defined in Grav.

Grav is even easier to tweak than Kirby :slight_smile: So of course you can use a flag switcher for language, and it would be similar to the langswitcher plugin, except instead of the language name, you use a flag. However, there is a general sense of agreement that flags are not appropriate for representing languages as you can have many languages under a single flag. All the best practices I read said you should use the text name of the language.

http://flagsarenotlanguages.com/blog/

Well, thanks you so much for your kind reply! While I wait for some reply, I made some tweaks and I got a languages switcher working with flags. In case someone want to use it, here it is what I do:

  1. I copied the languageswitcher.twig.html in my template/partials folder.
  2. I created an assets/flags with some flags .png in it, related to the languages I want.
  3. Replaced the code in languageswitcher.twig.html as following:

ul class=“flags”>
{% for key, language in langswitcher.languages %}
{% if key == langswitcher.current %}


  • {% else %}

  • {% endif %}
    {% endfor %}
    1. Created some css rules to display the flags.

    Hee is my first screenshot. Actually, it’s just a test enviroment… Screen Shot 2015-07-29 at 4


    I understand the for many peoples names are better than flags. IMHO, as a user, I think that flags are quicker to spot on pages than names. I think that both have pros/cons, so I do not like to be constrained by sme decision. I think that the language switcher plugin could have a tweakable configuration which enable or disable flags/languages. Anyway, it’s maybe much simple to create a simple flags plugin which do what I did. I certainly will try to do it.

    Thanks,
    Andrea

    If you wish to provide the option for flags in langswitcher, you can fork the project, make your changes, then create a pull request. All this can be done on GitHub without much effort:

    Thanks! By now I have created a new repo. Here it is: https://github.com/andreaspada/flags

    When I have some better implementation - a switch for the official plugin? - I’ll try to contribute in the official repo with a pull request.

    Many thanks!

    Thanks @rhukster for the flags blog post. Of course, I was already using flags in my site :laugh: …

    BTW @andrea, if you want to add your plugin to the GPM repo, just follow the requirements

    Well, I’m try to figure out by myself but I got many problems. I simply hate Twig…

    I need to understand how to refer to an image. When I display the homepage, my plugin correctly display the flags. Then, when I enter a subpage, it display nothing, as the base url of the page change (it append the lang code). If I enter a sub-sub-page, it append the lang code and the path. So, I cannot use a url created with {{base_url == ‘’ ? ‘/’ : base_url }}/some/path/to/my/flag.
    Anybody knows how can refer to a image? Or, better, how can I instruct my plugin to populate the asset with the images I need and refer to such images?
    Thanks!

    Don’t hate on Twig :slight_smile: It’s awesome when you get used to it. You just need something like this:

    <img src="{{ url('plugin://flag_plugin/images/flag-en.png') }}" />
    

    This will ensure you don’t have to worry about any baseurl stuff at alll

    Btw, this uses a combination of PHP streams to get the correct path to the plugin’s image file, and then the Grav custom url() function to turn that path into a URL. handy right!

    Also works for themes: theme://images/my-image.png

    Ohhhh… YES!!! Now I’m beginning to understand something. Awesome!!! Thanks you so much! You are helping me a lot!!! KUDOS