Multisite Language Switcher
Wrong language flag for Estonian language (5 posts)

  1. ragulka
    Posted 2 years ago #

    I have a multisite with 8 different languages.
    One of them is Estonian, which has the locale "et".
    However, the country code for Estonia is actually "ee".
    (The full locale for estonia is et_EE)

    The correct language flag for estonian would be ee.png, but currently it is showing the Ethiopian flag et.png

    I imagine there could be more cases like this for other countries/languages, so I guess the easiest solution would be to create some exceptions in the plugin code to handle these cases.

    Another possible solution would be if there was a way to configure the flag code per site. So if I was looking at the configuration on the estonian site, there could be a field for language code and I could insert the language code manually.


  2. Dennis Ploetner
    Plugin Author

    Posted 2 years ago #

    The problem is that WordPress uses the language-code 'et' an not 'et_EE' for Estonian. I moved the flag ee.png to et.png in my repository. This is not the best solution but for now it is a workaround.

    In the next versions it should be possible to decide which image-file should be used and not just the directory, you're right.

  3. ragulka
    Posted 2 years ago #

    I think renaming the falg is not a good idea. I think it would be best if the plugin knows how to handle these edge cases.

    For example, since we know that 'et' shoudl always map to 'ee', we could do something like this:

         * Get flag url
         * @param string $language
         * @param bool $plugin
         * @return string
        public function get_flag_url( $language ) {
            $url = (
                !is_admin() && $this->has_value( 'image_url' ) ?
                $this->__get( 'image_url' ) :
                $this->get_url( 'flags' )
            if ( 5 == strlen( $language ) )
                $language = strtolower( substr( $language, -2 ) );
            // Add exception for Estonian locale
            if ( $language == 'et' )
                $language = 'ee';
            return sprintf( '%s/%s.png', $url, $language );
  4. Dennis Ploetner
    Plugin Author

    Posted 2 years ago #

    Yes I know this is not really cool but even your solution has it's limitations. Maybe it's better to have an array with all language codes to flags.

  5. ragulka
    Posted 2 years ago #

    Yep, some kind of mapping array would work great. And I just realized it would have to be before we extract the susbtring from the locale, otherwise, it could cause issues.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Multisite Language Switcher
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic