Streaming live at 10am (PST)

Detect Browser Language and Redirect


#1

Hello @Webflow Community,

Do anyone have a simple JS code that I can imbed in my CustomCode, so that:
When the visitor comes to the website,
- If Browser Language = English, then do nothing (stay on the www.domain.com)
- If Browser Language = French, then redirect to /french (www.domain.com/french)

Any JS wisdom guru ?

Help much much appreciated !!!


#2
<script type="text/javascript">
    $( document ).ready(function(){
        var userLang = navigator.language || navigator.userLanguage;
        if (userLang == "en") {
            break;
        }
        else {
            window.location.href = "www.google.com"
        }
    });
</script>

This should work for you.Replace google with your own domain.


#3

Hello @steelesong,

This looks great,
I'm definitely saving this code for further needs.

Thank you so much for your time and help !!


#4

Your quite welcome sir. Wrote this in college I've always referred to it for sites that need language support.


#5

You could as well have used localise.js. https://localizejs.com/blog/2014/05/translate-webflow-website-language/


#6

Thanks @topelovely

I've finally used LocalizeJS.com and it's working like a charm !


#7

Hi @steelesong this works for 2 languages one of which is english.
In my case, I've built a 3 languages site (en, es and ca). Could you please update your answer for this case?

Besides this, I'd like to confirm that Localize.js is a tool that automatically translates your english site to other languages, am I right? But the translation is quite... impersonal, I'm afraid. Thanks for your comments on this as well.


#8
$( document ).ready(function(){
    var userLang = navigator.language || navigator.userLanguage;
    if (userLang == "en") {
        break;
    }
    else if(userLang == ''es"){
       window.location.href = "www.facebook.com"
    }
    else if(userLang == ''ca"){
       window.location.href = "www.youtube.com"
    }
    else {
        window.location.href = "www.google.com"
    }
});

This should work.
PLEASE NOTE - its showing inconsistent quotations around es and ca. Dont copy and paste this. I dont know why the forums arent showing the correct single or double quotation..


Language Detection and Redirect URL
#9

Hey @steelesong & @jcawoopa!

Have you tried Localize yet? We handle all of this on your behalf, no coding required. Here's our setup guide for Webflow => https://localizejs.com/docs/integrations/webflow

We make it really easy to translate your Webflow site. Here's why:

-- User-friendly editor to translate or review content.
-- Add collaborators to help with the project
-- Get real-time quotes from professional translation instantly. Place orders in a click.
-- Quick Import/Export of content
-- Automatic translation of all updates and changes.

Easy setup -- be done in minutes.
Great support -- quick response time.
All Languages -- even the rare ones!
Free trial -- zero risk.
Low cost -- affordable for any budget.

Reach out to our support team anytime. We're happy to help guide you through setup! => Support@LocalizeJS.com


#10