This trick will teach you how to modify the texts that display on the toolbar. Maybe because you want to change the wording or translate it into your language.
Installing the JavaScript The installation is rather simple as only a single script is needed. Go to Administration Panel > Modules > JavaScript codes management and create a new script.
Title : Toolbar Text Placement : In all the pages - Code:
$(function() { var toolbar_alias = { Share : 'Share', Login : 'Login', Register : 'Register', Welcome : 'Welcome', Notifications : 'Notifications', See_my_profile : 'View profile', Edit_profile : 'Edit profile', All_Topics : 'My topics', All_Messages : 'My posts', js_topics_followed : 'Watched topics', Admin_panel : 'Administration Panel', Logout : 'Log out', Notif_see_all : 'See all the notifications', Notif_priv_msg : 'You have received a <a href="/privmsg?folder=inbox&nid=%(nid)s">private message</a> from <a href="/u%(id)d">%(name)s</a>', Notif_report : '<a href="/u%(id)d">%(name)s</a> has created a <a href="/report?nid=%(nid)s">message report</a>', Notif_friend_req : 'You have received a <a href="/profile?mode=editprofile&nid=%(nid)s&page_profil=friendsfoes">friend request</a> from <a href="/u%(id)d">%(name)s</a>', Notif_group_req : '<a href="/u%(id)d">%(name)s</a> has made a request to join the group <a href="/g%(group_id)d-%(group_url_name)s?nid=%(nid)s">%(group_name)s</a>', Notif_friend_con : '<a href="/u%(id)d">%(name)s</a> has connected', Notif_wall_msg : '<a href="/u%(id)d">%(name)s</a> has just written a message on <a href="/u%(self)dwall?nid=%(nid)s">your wall</a>', Notif_abuse : '<a href="/admin/index.forum?mode=active&nid=%(nid)s&part=misc&sub=support">An abuse</a> was reported', Notif_topic_watch : '<a href="/u%(id)d">%(name)s</a> wrote a message <a href="/t%(topic_id)d-%(topic_name)s?nid=%(nid)s#%(post_id)d">in a watched topic</a>', Notif_topic_watch_p : '<a href="/u%(id)d">%(name)s</a> wrote a message <a href="/t%(topic_id)dp%(start)d-%(topic_name)s?nid=%(nid)s#%(post_id)d">in a watched topic</a>', Notif_topic_watch_guest : 'A guest wrote a message in <a href="/t%(topic_id)d-%(topic_name)s?nid=%(nid)s#%(post_id)d">a topic you watch</a>', Notif_topic_watch_p_guest : 'A guest wrote a message in <a href="/t%(topic_id)dp%(start)d-%(topic_name)s?nid=%(nid)s#%(post_id)d">a topic you watch</a>', Notif_mention : '<a href="/u%(id)d">%(name)s</a> tagged you in <a href="/t%(topic_id)dp%(start)d-%(topic_name)s?nid=%(nid)s#%(post_id)d">a topic</a>', Notif_hashtag : 'The keyword <a href="/tags/%(tag)s">#%(tag)s</a> has been tagged in <a href="/t%(topic_id)dp%(start)d-%(topic_name)s?nid=%(nid)s#%(post_id)d">a topic</a>.', All_PMs : 'My private messages', No_assigned_rank : 'No special rank assigned', Posts : 'Posts', PMs : 'PMs', Reputation : 'Reputation' },i; if (window._lang) for (i in toolbar_alias) window._lang[i] = toolbar_alias[i]; }); The script in its current state only contains the original English translation. Please read the next section to learn how to change these texts.
Modifying the texts To change the current text in the script you will need to modify the properties of the toolbar_alias object. In there you will see phrases such as : - Code:
Share : 'Share', Login : 'Login', Register : 'Register', Welcome : 'Welcome', Notifications : 'Notifications', To the left of the colon is the alias, this SHOULD NOT be modified. The content which you should modify is to the right of the colon, between the single quotes. ( This is known as a "Text String" )
So if I wanted to change "Welcome" to "Logged in as" all I need to do is change the texts in the welcome string like so : - Code:
Welcome : 'Logged in as', Then just save the script and the texts should be changed on the welcome menu.
Escaping special characters Also, one important thing to note is the usage of similar quotes inside a text string. Since we're using single quotes to define a string, it's imperative that you escape any single quotes you use with the special escape character : \
Here's a quick example to demonstrate escaping a quote. - Code:
No_assigned_rank : 'You don\'t have a rank', As you can see in the example above I wrote don\'t. We have to escape this single quote, because if we don't it will end the string early and break the script. Now that you have this in mind you should have no problems changing the texts.
Notification variables Lastly, one important thing to note is that you can change the structure of the notification texts as well. This is useful, but you should also be careful when editing as there are important variables ! You may see something similar to this in the notifications : %(name)s
That is a variable that's replaced with the user's name, it should not be edited unless you know what you're doing. You can move them around of course, but just be careful when editing them. For reference, I'll leave a list of the variables below.
Variable | Description | %(id)d | The id of the user who sent the notification. | %(self)d | Your user id. | %(name)s | The name of the user who sent the notification. | %(post_id)d | The post id of a referenced topic. | %(start)d | The page id of a referenced topic. | %(topic_id)d | The id of a referenced topic. | %(topic_name)s | The name of a referenced topic. | %(group_id)d | The id of a referenced group. | %(group_url_name)s | The slugified URL of a referenced group. | %(group_name)s | The name of a referenced group. | %(tag)s | The hashtag that was tagged in a topic. | %(nid)s | The ID of the notification. |
With all this in mind, you should now be able to change any of the texts that you want on the toolbar. Of course if you need any help you're free to ask on the support.
|