Slider text with custom JS multilingual

Hi,

I’m using a custom JS code snippet i got from your support way back for my slider text so i can add line break to the text. Now i’ve started working on adding another language to the site and wonder if its possible to make this solution work in a multilangual enviroment.

The code for slider text i currently use is :

jQuery(function($) {

if( $(’.slide-item’).length ){

var slideText1 = 'myrandomtext <br /> myrandomtextline2';
var slideText2 = 'myrandomtext <br />myrandomtextline2<a href="#" class="roll-button more-button">Läs mer</a>';
var slideText3 = 'myrandomtext<br /> myrandomtextline2<a href="#" class="roll-button more-button">Kontakta oss</a>';
var slideText4 = 'Main slide <br /> title';
var slideText5 = 'Main slide <br /> title';

$( '.slide-item:nth-of-type(1) .slide-inner .subtitle' ).html(slideText1);
$( '.slide-item:nth-of-type(2) .slide-inner .subtitle' ).html(slideText2);
$( '.slide-item:nth-of-type(3) .slide-inner .subtitle' ).html(slideText3);
$( '.slide-item:nth-of-type(4) .slide-inner .subtitle' ).html(slideText4);
$( '.slide-item:nth-of-type(5) .slide-inner .subtitle' ).html(slideText5);

}

});


how do i go about adding a second language to this (if at all possible)

site url: https://insolventia.se

BR
Jonas

Hello Jonas,

Check out my reply here in older topic. Let me know if further questions come up.

Regards,
Kharis

Thanks, but sorry i dont understand.

Since i set my text in the Custom JC code plugin thingy it doesnt matter that i translate the strings i set under the customize > header slider thing.

Since it will always be the text i have in the JC code.

Hello there,

Please share your complete JS code privately to my email at kharisblank@gmail.com. Use gist service to host your code and ensure it’s set to private. You just need to share its link. Also please take a screenshot of your language settings, so I could reproduce the translation exactly like what you’re currently having.

Mention the link to this topic in your email body to signal it’s a followup from forum reply.

Regards,
Kharis

Hi Kharis,
I already sent you the email but i think i’ve solved it now.

I used a plugin called “jQuery in Posts, Pages, Custom Post Types”

This way i could still use the code snippet for slider text but set different text on different pages. In this case the home page for swedish and home page for english.

If there is a better way to do this on the top of your head you are more than welcome to answer the e-mail anyway :slight_smile:

Best regards,
Jonas