Publisher does not support the Fluid field type. Please do not contact asking when support will be available.

If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.

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)

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

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)

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

Thank you Brian for your answer.

Login to reply