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 Tue 24 Jan 2023 - 19:50

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 Wed 25 Jan 2023 - 17:16; 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 Wed 25 Jan 2023 - 9:21

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 : 1575
Reputation : 266
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 Wed 25 Jan 2023 - 13:13

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 Wed 25 Jan 2023 - 14:44

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 : 1575
Reputation : 266
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 Wed 25 Jan 2023 - 15:08

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 Wed 25 Jan 2023 - 16:42

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 : 1575
Reputation : 266
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 Wed 25 Jan 2023 - 17:09

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 Wed 25 Jan 2023 - 17:18

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

Female Posts : 15322
Reputation : 1705
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