Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6773333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:39:22+00:00 2026-05-26T15:39:22+00:00

I’m trying to achieve the following though with my intermediate JavaScript skills I’m not

  • 0

I’m trying to achieve the following though with my intermediate JavaScript skills I’m not sure if this is possible.

This is related in part to this question.

Now I have 2 arrays

a) Has the various language in (e.g. “en-GB”, “fr”, “de” etc)
b) Has a suffix of a URL based on the browser language above (e.g. “fr/”,”de/”,”uk/”)

What I am trying to achieve is:

1) User hits a page, browser detects which browser it is using from the array (a)
2) Depending on what the browser is based on (a), it then searches through (b) and if they match, e.g. if the language is “fr” it will use the suffix “fr/” from the array in (b).
3) It will then add this suffix to a top level domain (which is always constant)

Is this even possible to achieve (I’m sure it is)? Can it be done purely via JavaScript (or JQuery)? How would I go about doing this?

Here’s some of the code I have so far:

var IAB_Array = new Array("de-at","nl-be","fr-be","da","de","hu","en-ie","ga","es","fr","it","nl","no","pl","en","en-GB","en-US","en-gb","en-us"); //language array
var IAB_suffix = new Array("at/","be-nl/","be-fr","den/","de/","hu/","ie/","es/","fr/","it/","nl/","nor/","pl/","uk/"); //URL suffix Array
var IAB_lang = "en-GB"; //default language
var IAB_link = "http://www.mysitegoeshere/";

if(navigator.browserLanguage) IAB_lang = navigator.browserLanguage; //change lang if detection supported
if(window.navigator.language) IAB_lang = window.navigator.language; //change lang if detection supported

function IAB_Lang_detect () { //execute search
for (var i=0;i<IAB_Array.length;i++) {
    if(IAB_Array[i]==IAB_lang) {
        document.write(IAB_Array[i]); //output matched array value
        }
}
return false;
}

var IAB_URL = "<a href="+IAB_link+IAB_suffix[1]+">"+IAB_link+IAB_suffix[1]+"</a>"; //this is the resulting URL

document.write(IAB_URL);
IAB_Lang_detect ();

I hope someone can help as I’m a little confused! It’s more so the matching the values from the 2 arrays and then subsequently selecting the correct suffix that I’m having trouble with.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:39:23+00:00Added an answer on May 26, 2026 at 3:39 pm
    (function () {
        "use strict";
        var lang_map = {
            "de-at": "at/",
            "nl-be": "be-nl/",
            "fr-be": "be-fr",
            "da": "den/",
            "de": "de/",
            "hu": "hu/",
            "en-ie": "ie/",
            "ga": "ie/",
            "es": "es/",
            "fr": "fr/",
            "it": "it/",
            "nl": "nl/",
            "no": "nor/",
            "pl": "pl/",
            "en": "uk/",
            "en-GB": "uk/",
            "en-US": "uk/",
            "en-gb": "uk/",
            "en-us": "uk/"
        },
        lang = (navigator && navigator.browserLanguage) || (window.navigator && window.navigator.language) || "en-GB";
        window.location = "http://www.mysitegoeshere/" + lang_map[lang];
    }());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am trying to loop through a bunch of documents I have to put

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.