Be sure to checkout our newest add-on Reading Time Pro!

EE4 compatibility updates:

  • Publisher is EE4 and EE5 compatible, but it does not currently support the Fluid field (it's in the works).
  • Reel is EE4 and EE5 compatible, but it does not currently support the Fluid field.

Ticket: Redirect to a specific (no default) language when browser has a non defined language

Status Resolved
Add-on / Version Publisher 2.10.8
Severity
EE Version 5.2.1

Werner Gusset

Apr 09, 2019

Doing research for a future project

If we “Get language from browser” and the browser has none of the website languages we would like to show a language which is not the default language.

A bit more clear: if we have default ‘de’ and second language ‘en’ and the visitor has a browser language of ‘dk’ we want to show the ‘en’ version (which is not the default language). And we always want to show ‘en’ if the browser language doesn’t match an installed language. Is there a way we could do that?

#1

BoldMinded (Brian)

Apr 09, 2019

Hi, Werner. What you’re describing sounds a bit unique, and in that case I would recommend taking a look at the hooks available in Publisher (search it’s code for “active_hook”) and making a custom extension. It sounds like you would need the “publisher_set_language” hook.

#2

Werner Gusset

Apr 09, 2019

Thank you, Brian

I am not able to write an extension myself. Do you have any recommendation for a programmer who could do that for us? Or where would you suggest to ask for someone?

#3

BoldMinded (Brian)

Apr 09, 2019

You can try the eecms Slack channel to see if anyone is available to write it. I would take a look at it, but I just got finished with a small contract project and need to focus on other things right now so I can’t take on additional contract work. You _might_ also be able to achieve this with JavaScript too. It would be a client side redirect, but you can get the browser’s language with JS and do a redirect based on whatever logic you need.

var getBrowserLocale = function () {
        if ('object' === typeof navigator) {
            return navigator.language || navigator.userLanguage;
        }

        return false;
    };
#4

Werner Gusset

Apr 09, 2019

Thank you Brian for your answer.

Login to reply

Contact

For add-on support, please use the Support section. General inquries and pre-sale questions can be sent to support@boldminded.com.