Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 0

Can't translate header menu button


MelindaMellukas

Question

  • Answers 7
  • Created
  • Last Reply

Top Posters For This Question

7 answers to this question

Recommended Posts

  • 0
On 10/14/2021 at 2:56 AM, MelindaMellukas said:

Site URL: https://cinnamon-chameleon-6wa9.squarespace.com/

Hi, I can't find the right code for the header menu button, I want to translate the call-to-action button. I want it in English to be "Let's talk" and in Estonian version "Küsi pakkumine". 

My page: https://cinnamon-chameleon-6wa9.squarespace.com/

You mean Kontakt button?

Email me if you have need any help (free, of course.). Answer within 24 hours.

How to: Setup password & share url - Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care

Link to comment
  • 0
On 10/15/2021 at 8:25 PM, MelindaMellukas said:

Yes, I changed it to Kontakt right now. English could be then Contact and Estonian (EE) Kontakt. 

Edit this code

 /* HOMEPAGE-LOGO LINKS TO PROPER LANGUAGE HOMEPAGE */
if (lang == "en") {
$('a[href="/"]').attr("href", "/en/home/");
  }

to this

 /* HOMEPAGE-LOGO LINKS TO PROPER LANGUAGE HOMEPAGE */
if (lang == "en") {
$('a[href="/"]').attr("href", "/en/home/");
$('body').addClass("body-en");
  }

then add this to last line in Code Injection > Footer

<script>
$(document).ready(function(){
    $("body.body-en a.btn").html(function() { 
          return $(this).html().replace("Kontakt", "Contact");  
    });
  $("body.body-en a.btn").attr('href','/en/contact');
});
</script>

This code will rename text + change button url on English Pages

Email me if you have need any help (free, of course.). Answer within 24 hours.

How to: Setup password & share url - Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care

Link to comment
  • 0

Hi, Thank you! I got it working but when you click on english version menu, its a bit flashy, going quickly from Kontakt to Contact: https://cinnamon-chameleon-6wa9.squarespace.com

 

My code:

 

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
  $(function() { 
  /* SETUP MULTI-LANGUAGE */
  var defaultLanguage = 'et';
  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 == "et" || 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 == "en") {
$('a[href="/"]').attr("href", "/en/home");
  $('body').addClass("body-en");
}
if (lang == "et") {
$('a[href="/"]').attr("href", "/et/home");
  $('body').addClass("body-et");
}
 /* ADD EXCLUSION NAV ITEMS */
  $('.exclude-me,.exclude-me a').addClass('exclude');
  $('.sqs-svg-icon--list a,.SocialLinks-link').addClass('exclude');
});
    $(document).ready(function(){
    $("body.body-en a.btn").html(function() { 
          return $(this).html().replace("Kontakt", "Contact");  
    });
  $("body.body-en a.btn").attr('href','/en/contact');
        });
</script>

Link to comment
  • 0
On 10/20/2021 at 9:18 PM, MelindaMellukas said:

Hi, Thank you! I got it working but when you click on english version menu, its a bit flashy, going quickly from Kontakt to Contact: https://cinnamon-chameleon-6wa9.squarespace.com

 

My code:

 

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
  $(function() { 
  /* SETUP MULTI-LANGUAGE */
  var defaultLanguage = 'et';
  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 == "et" || 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 == "en") {
$('a[href="/"]').attr("href", "/en/home");
  $('body').addClass("body-en");
}
if (lang == "et") {
$('a[href="/"]').attr("href", "/et/home");
  $('body').addClass("body-et");
}
 /* ADD EXCLUSION NAV ITEMS */
  $('.exclude-me,.exclude-me a').addClass('exclude');
  $('.sqs-svg-icon--list a,.SocialLinks-link').addClass('exclude');
});
    $(document).ready(function(){
    $("body.body-en a.btn").html(function() { 
          return $(this).html().replace("Kontakt", "Contact");  
    });
  $("body.body-en a.btn").attr('href','/en/contact');
        });
</script>

Try adding this to Design > Custom CSS

/* Nav links flash */
.header-nav-list {
  visibility: hidden;
}
.header-nav-list .multilanguage {
  visibility: visible;
}

 

Email me if you have need any help (free, of course.). Answer within 24 hours.

How to: Setup password & share url - Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care

Link to comment
  • 0
2 hours ago, tuanphan said:

Try adding this to Design > Custom CSS

/* Nav links flash */
.header-nav-list {
  visibility: hidden;
}
.header-nav-list .multilanguage {
  visibility: visible;
}

 

I couldnt get it working like this or im missing smth from the code. Problem is its changing visbily Kontakt to Contact in sthe english menu if you navigate between menu items. https://cinnamon-chameleon-6wa9.squarespace.com/

 
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment


×
×
  • Create New...