Click here to Skip to main content
15,868,066 members
Home / Discussions / JavaScript
   

JavaScript

 
QuestionRe: How to access object literal property's value inside the object literal function? Pin
ZurdoDev9-Jul-20 10:13
professionalZurdoDev9-Jul-20 10:13 
AnswerRe: How to access object literal property's value inside the object literal function? Pin
Andre Oosthuizen9-Jul-20 17:14
mveAndre Oosthuizen9-Jul-20 17:14 
GeneralRe: How to access object literal property's value inside the object literal function? Pin
Member 1395489011-Jul-20 8:34
Member 1395489011-Jul-20 8:34 
AnswerRe: How to access object literal property's value inside the object literal function? Pin
Richard MacCutchan9-Jul-20 23:25
mveRichard MacCutchan9-Jul-20 23:25 
AnswerRe: How to access object literal property's value inside the object literal function? Pin
F-ES Sitecore10-Jul-20 1:49
professionalF-ES Sitecore10-Jul-20 1:49 
QuestionUnable to get the desired result when using arrow function in JavaScript Pin
Member 139548909-Jul-20 9:24
Member 139548909-Jul-20 9:24 
AnswerRe: Unable to get the desired result when using arrow function in JavaScript Pin
ZurdoDev9-Jul-20 10:15
professionalZurdoDev9-Jul-20 10:15 
QuestionJavascript to create Multilingual Footer Pin
Member 148850579-Jul-20 1:09
Member 148850579-Jul-20 1:09 
I am in the process of building a website in Squarespace, I am using Javascript to create a multi-lingual website in English and French. I differentiate between English and French using the URL/Slug

Example

www.websitename.com/en/home

or

www.websitename.com/fr/home

Everything is translating, almost. I am having issues with the footer translating.

Here are some images

https://i.stack.imgur.com/rLjn1.png[^]

https://i.stack.imgur.com/ruE24.png[^]

https://i.stack.imgur.com/Bz1cx.png[^]

<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/2.6.0/css/flag-icon.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
    $(function() {
    /* SETUP MULTI-LANGUAGE */
    var defaultLanguage = 'en';
    var lang = location.pathname.split("/")[1];
    var defaultClass = 'lang-'+defaultLanguage+'';
    var itemParent = "nav [class*='collection'],nav [class*='folder'],nav [class*='index'],nav [class*='group']";
    if (lang == "" || lang.length > 2 ){
      var lang = defaultLanguage;
    }
 
    /* ADD LANGUAGE CLASSES */
    $('a[href="/"]').addClass('lang-'+defaultLanguage+'').parents(itemParent).addClass('lang-'+defaultLanguage+'');
    $('nav a:link:not([href^="http://"]):not([href^="https://"])').each(function () {
      var langType = $(this).attr('href').split("/")[1];
      var multiLanguageClass = 'multilanguage lang-' + langType + '';
      if (undefined !== langType && langType.length <= 2)
        $(this).addClass(multiLanguageClass).parents(itemParent).addClass(multiLanguageClass);
    });
    $('nav button').each(function () {
      var langTypeFolder = $(this).attr('data-controller-folder-toggle').split("/")[0];
      var multiLanguageClass = 'multilanguage lang-' + langTypeFolder + '';
      if (undefined !== langTypeFolder && langTypeFolder.length <= 2)
        $(this).addClass(multiLanguageClass);
    });
 
    /* HOMEPAGE-LOGO LINKS TO PROPER LANGUAGE HOMEPAGE */
    if (lang == "fr") {
      $('a[href="/"]').attr("href", "/fr/home/");
    }
 
    /* ADD EXCLUSION NAV ITEMS */
    $('.exclude-me,.exclude-me a').addClass('exclude');
    $('.sqs-svg-icon--list a,.SocialLinks-link').addClass('exclude');
 
    /* REMOVE OTHER LANGUAGES AND KEEP EXCLUDED ITEMS */
    $('.multilanguage:not(".lang-'+lang+',.exclude")').remove();
 
    /* SETUP LANGUAGE SWITCHER */
    $('body').prepend('<div class="language"><a href="/en/home" class="lang-en"></a> <a href="/fr/home/" class="lang-fr"></a></div>');
 
  });
</script>


[JavaScript] MULTI-LANGUAGE Javscript for Website - Pastebin.com[^]
AnswerRe: Javascript to create Multilingual Footer Pin
ZurdoDev9-Jul-20 10:16
professionalZurdoDev9-Jul-20 10:16 
QuestionAny tips? I am brand new and created a binary translator. I'm open to feedback. Pin
Hany Halim1-Jul-20 9:55
Hany Halim1-Jul-20 9:55 
QuestionRe: Any tips? I am brand new and created a binary translator. I'm open to feedback. Pin
Richard MacCutchan1-Jul-20 22:41
mveRichard MacCutchan1-Jul-20 22:41 
AnswerRe: Any tips? I am brand new and created a binary translator. I'm open to feedback. Pin
ZurdoDev9-Jul-20 10:17
professionalZurdoDev9-Jul-20 10:17 
AnswerRe: Any tips? I am brand new and created a binary translator. I'm open to feedback. Pin
Richard Deeming1-Jul-20 23:45
mveRichard Deeming1-Jul-20 23:45 
AnswerRe: Any tips? I am brand new and created a binary translator. I'm open to feedback. Pin
Member 1489456920-Jul-20 15:46
Member 1489456920-Jul-20 15:46 
QuestionCannot read back correct JSON from excel workbook Pin
kjeeva28-Jun-20 10:57
kjeeva28-Jun-20 10:57 
QuestionI am creating a program with Visual Basic Script files with C++. Pin
c0d3r1/226-Jun-20 7:15
c0d3r1/226-Jun-20 7:15 
AnswerRe: I am creating a program with Visual Basic Script files with C++. Pin
Bohdan Stupak29-Jun-20 4:18
professionalBohdan Stupak29-Jun-20 4:18 
AnswerRe: I am creating a program with Visual Basic Script files with C++. Pin
ZurdoDev29-Jun-20 4:35
professionalZurdoDev29-Jun-20 4:35 
Questionhow to get audio play auto work in mobile browsers andriod & ios Pin
Member 1486961821-Jun-20 20:38
Member 1486961821-Jun-20 20:38 
QuestionNeed javascript code support for below request Pin
mikt201618-Jun-20 0:57
mikt201618-Jun-20 0:57 
AnswerRe: Need javascript code support for below request Pin
ZurdoDev18-Jun-20 2:00
professionalZurdoDev18-Jun-20 2:00 
AnswerRe: Need javascript code support for below request Pin
Richard MacCutchan18-Jun-20 4:43
mveRichard MacCutchan18-Jun-20 4:43 
QuestionAccordion not working properly with dynamic content Pin
mhutch2617-Jun-20 4:09
mhutch2617-Jun-20 4:09 
QuestionData from one page to another with a twist. Pin
and180y14-Jun-20 10:33
and180y14-Jun-20 10:33 
AnswerRe: Data from one page to another with a twist. Pin
Richard Deeming15-Jun-20 0:41
mveRichard Deeming15-Jun-20 0:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.