The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Need help with language change in navbar

3 posters

Go down

Solved Need help with language change in navbar

Post by sivastar January 24th 2023, 7:50 pm

Code:

$(function(){ /* Wait for the page to load */

var a_memblist=$("a.mainmenu[href="/memberlist"]"); /* The memberlist link */
if(a_memblist){ /* If the memberlist link exists */
a_memblist.text("உறுப்பினர்கள்"); /* Change the text to users */
};
var a_memblist=$("a.mainmenu[href="/profile?mode=editprofile"]"); /* The memberlist link */
if(a_memblist){ /* If the memberlist link exists */
a_memblist.text("பயனர் தகவலறை"); /* Change the text to profile */
}
var a_memblist=$("a.mainmenu[href="/privmsg?folder=inbox"]"); /* The memberlist link */
if(a_memblist){ /* If the memberlist link exists */
a_memblist.text("தனிமடல்"); /* Change the text to privmsg */
};
var a_memblist=$("a.mainmenu[href="/search"]"); /* The memberlist link */
if(a_memblist){ /* If the memberlist link exists */
a_memblist.text("தேடுக"); /* Change the text to search */
};
var a_memblist=$("a.mainmenu[href="/login"]"); /* The memberlist link */
if(a_memblist){ /* If the memberlist link exists */
a_memblist.text("உள்நுழை"); /* Change the text to login */
};
var a_memblist=$("a.mainmenu[href="/register"]"); /* The memberlist link */
if(a_memblist){ /* If the memberlist link exists */
a_memblist.text("பதிவு செய்"); /* Change the text to register*/
};
var a_memblist=$("a.mainmenu[href="/images"]"); /* The memberlist link */
if(a_memblist){ /* If the memberlist link exists */
a_memblist.text("சமீபத்திய படங்கள்"); /* Change the text to Images*/
};
var a_memblist=$("a.mainmenu[href="/publi"]"); /* The memberlist link */
if(a_memblist){ /* If the memberlist link exists */
a_memblist.text("வலைப்பூ"); /* Change the text to Publications*/
};
var a_memblist=$("a.mainmenu[href="/calendar"]"); /* The memberlist link */
if(a_memblist){ /* If the memberlist link exists */
a_memblist.text("நாட்காட்டி"); /* Change the text to calendar*/
};
var a_memblist=$("a.mainmenu[href="/faq"]"); /* The memberlist link */
if(a_memblist){ /* If the memberlist link exists */
a_memblist.text("கேள்வி பதில்"); /* Change the text to faq*/
};
var a_memblist=$("a.mainmenu[href="/groups"]"); /* The memberlist link */
if(a_memblist){ /* If the memberlist link exists */
a_memblist.text("ஈகரை குழு"); /* Change the text to groups*/
};
var a_memblist=$("a.mainmenu[href="/gallery/index.htm"]"); /* The memberlist link */
if(a_memblist){ /* If the memberlist link exists */
a_memblist.text("கேலரி"); /* Change the text to gallery*/
};
if(/faq/.test(location.pathname)){ /* If the user visit the faq */
location.pathname="/forum"; /* Redirect to the forum */
};
})

unable to change the language of the following in the above script.

Home, Logout, New message

Thanks in advance to those who help


Last edited by sivastar on January 25th 2023, 5:16 pm; edited 1 time in total
sivastar
sivastar
Forumember

Male Posts : 152
Reputation : 16
Language : Tamil
Location : Malaysia

http://www.eegarai.net

Back to top Go down

Solved Re: Need help with language change in navbar

Post by Razor12345 January 25th 2023, 9:21 am

Good afternoon!

AP - Display - Templates - General - overall_header

At the end of the template, insert:

Code:
<script>
document.querySelector('a.mainmenu[href="/"]').innerText=document.querySelector('a.mainmenu[href="/"]').innerText.replace("Home","Lalala");
document.querySelector('span.new-message').innerText=document.querySelector('span.new-message').innerText.replace("You have","Lalala");
document.querySelector('span.new-message').innerText=document.querySelector('span.new-message').innerText.replace("new message","Lalala");
document.querySelector('span.new-message').innerText=document.querySelector('span.new-message').innerText.replace("new messages","Lalala");
document.querySelector('#logout').innerText=document.querySelector('#logout').innerText.replace("Log out","Lalala");
</script>

Lalala - replace with your own text

Save - Publish

Result:

Need help with language change in navbar  Ouo82

Note that the "You have ___ new message" button has three codes to keep the number of new messages and that the code replaces the button not only when there is 1 message, but also when there are more

Razor12345
Razor12345
Support Moderator
Support Moderator

Male Posts : 1583
Reputation : 268
Language : Ukr, Rus, Eng
Location : Ukraine

sivastar and TonnyKamper like this post

Back to top Go down

Solved Re: Need help with language change in navbar

Post by sivastar January 25th 2023, 1:13 pm

Home menu text changed, but logout and new message not working..

Update:

Your script works perfectly only when a new message received.

Otherwise working for the home menu only.
sivastar
sivastar
Forumember

Male Posts : 152
Reputation : 16
Language : Tamil
Location : Malaysia

http://www.eegarai.net

Back to top Go down

Solved Re: Need help with language change in navbar

Post by Razor12345 January 25th 2023, 2:44 pm

Try this

Code:
<script>
document.querySelector('a.mainmenu[href="/"]').innerText=document.querySelector('a.mainmenu[href="/"]').innerText.replace("Home","Lalala");
document.querySelector('#logout').innerText=document.querySelector('#logout').innerText.replace("Log out","Lalala");
document.querySelector('span.toread-message').innerText=document.querySelector('span.toread-message').innerText.replace("unread message","Lalala");
document.querySelector('span.new-message').innerText=document.querySelector('span.new-message').innerText.replace("You have","Lalala");
document.querySelector('span.new-message').innerText=document.querySelector('span.new-message').innerText.replace("new message","Lalala");
document.querySelector('span.new-message').innerText=document.querySelector('span.new-message').innerText.replace("new messages","Lalala");
</script>

The problem was that when 1 unread message, one class is assigned to the button, and when two unread messages, another class is assigned.

Otherwise working for the home menu only.

Where else should the text be changed?
Razor12345
Razor12345
Support Moderator
Support Moderator

Male Posts : 1583
Reputation : 268
Language : Ukr, Rus, Eng
Location : Ukraine

sivastar likes this post

Back to top Go down

Solved Re: Need help with language change in navbar

Post by sivastar January 25th 2023, 3:08 pm

Kindly add the script for "Messages"

The above code working Log out and unread messages, but Home not working

Update:
Something stops working when moving the script up and down
sivastar
sivastar
Forumember

Male Posts : 152
Reputation : 16
Language : Tamil
Location : Malaysia

http://www.eegarai.net

Back to top Go down

Solved Re: Need help with language change in navbar

Post by Razor12345 January 25th 2023, 4:42 pm

I found the problem - you have a second menu that copies the main menu buttons.

Need help with language change in navbar  Screen12

There were also problems with the different display options for the "messages" button

Please, try this code:

Code:
<script>
  let ele = document.querySelector('#navbar');
 
ele.querySelector('a.mainmenu[href="/"]').innerText=ele.querySelector('a.mainmenu[href="/"]').innerText.replace("Home","Lalala");
ele.querySelector('#logout').innerText=ele.querySelector('#logout').innerText.replace("Log out","Lalala");
 
let mes = ele.querySelector('a.mainmenu[href="/privmsg?folder=inbox"]');
let mes1 = ele.querySelector('span.new-message');
let mes2 = ele.querySelector('span.toread-message');
 
 
 
  if ( mes && mes1) {
  ele.querySelector('span.new-message').innerText=ele.querySelector('span.new-message').innerText.replace("You have","Lalala");
ele.querySelector('span.new-message').innerText=ele.querySelector('span.new-message').innerText.replace("new message","Lalala");
  } else if ( mes && mes2) {
  ele.querySelector('span.toread-message').innerText=ele.querySelector('span.toread-message').innerText.replace("unread message","Lalala");
  } else {
    ele.querySelector('a.mainmenu[href="/privmsg?folder=inbox"]').innerText=ele.querySelector('a.mainmenu[href="/privmsg?folder=inbox"]').innerText.replace("Messages","Lalala");
  }
 </script>


Need help with language change in navbar  Screen51
Razor12345
Razor12345
Support Moderator
Support Moderator

Male Posts : 1583
Reputation : 268
Language : Ukr, Rus, Eng
Location : Ukraine

skouliki, sivastar and كونان2000 like this post

Back to top Go down

Solved Re: Need help with language change in navbar

Post by sivastar January 25th 2023, 5:09 pm

wow, fantastic @Razor12345

works great..

Thank you.
sivastar
sivastar
Forumember

Male Posts : 152
Reputation : 16
Language : Tamil
Location : Malaysia

http://www.eegarai.net

Back to top Go down

Solved Re: Need help with language change in navbar

Post by skouliki January 25th 2023, 5:18 pm

Problem solved & topic archived.
Please read our forum rules: ESF General Rules
skouliki
skouliki
Manager
Manager

Female Posts : 15391
Reputation : 1709
Language : English,Greek
Location : Greece

http://iconskouliki.forumgreek.com

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum