Author Topic: [Code] Translate (Beta 07.21.13)  (Read 860 times)

0 Members and 0 Guests are viewing this topic.

Offline aIURbliS

  • Hero Member
  • *****
  • Posts: 1215
  • Karma: 45
  • Gender: Male
  • Location: U.S.
    • View Profile
[Code] Translate (Beta 07.21.13)
« on: July 22, 2013, 03:29:19 am »
Description: Translates the top section of your forum to any language you want, you must modify the code to add your language.

This code utilizes jQuery, please use the latest version found in this thread: http://support.createaforum.com/5/jquery-v1-8-update/

Footers:
Code: [Select]
<script>
//Translate (Beta 07.21.13)
//Created by aIURblisS/xboi209


//----------------------------------------------------------------
//                       Translate below
//----------------------------------------------------------------
var guesttranslation = new Array(); //DON'T TRANSLATE THIS
guesttranslation[0] = "Welcome";
guesttranslation[1] = "Guest";
guesttranslation[2] = "Please";
guesttranslation[3] = "login";
guesttranslation[4] = "or";
guesttranslation[5] = "register";
guesttranslation[6] = "Did you miss your";
guesttranslation[7] = "activation email";
guesttranslation[8] = "Login with username, password and session length";


var tabtranslation = new Array(); //DON'T TRANSLATE THIS
tabtranslation[0] = "Home";
tabtranslation[1] = "Forum";
tabtranslation[2] = "Search";
tabtranslation[3] = "Admin";
tabtranslation[4] = "Moderate";
tabtranslation[5] = "Profile";
tabtranslation[6] = "My Messages";
tabtranslation[7] = "Calendar";
tabtranslation[8] = "Gallery";
tabtranslation[9] = "Arcade";
tabtranslation[10] = "Members";
tabtranslation[11] = "Chat";
tabtranslation[12] = "Logout";
tabtranslation[13] = "Login";
tabtranslation[14] = "Register";


var tabdropdowntranslation = new Array(); //DON'T TRANSLATE THIS
tabdropdowntranslation[0] = "Features and Options";
tabdropdowntranslation[1] = "Permissions";
tabdropdowntranslation[2] = "Reported Posts";
tabdropdowntranslation[3] = "Summary";
tabdropdowntranslation[4] = "Account Settings";
tabdropdowntranslation[5] = "Forum Profile";
tabdropdowntranslation[6] = "Read your messages";
tabdropdowntranslation[7] = "Send a message";
tabdropdowntranslation[8] = "View Calendar";
tabdropdowntranslation[9] = "Post Event";
tabdropdowntranslation[10] = "View the memberlist";
tabdropdowntranslation[11] = "Search for Members";


var translation = new Array(); //DON'T TRANSLATE THIS
translation[0] = "Hello";
translation[1] = "Show unread posts since last visit.";
translation[2] = "Show new replies to your posts.";
translation[3] = "Search";
translation[4] = "News";
//----------------------------------------------------------------
//                        Stop translating
//----------------------------------------------------------------
var $upper_section = $("#upper_section");
if ($("#guest_form").length == "0") {
    var username = $upper_section.find(".greeting").children("span").text();
    var upper_section_resetli = $upper_section.children(".user").children(".reset").children("li");
    var $search_form = $("#search_form");


    upper_section_resetli.eq(0).html(translation[0] + " " + username);
    upper_section_resetli.eq(1).children("a").html(translation[1]);
    upper_section_resetli.eq(2).children("a").html(translation[2]);
    $search_form.children("input").eq(1).attr("value",translation[3]);
    $search_form.next("h2").html(translation[4] + ": ");
} else {
    var guestlogin = $("#guest_form").children(".info")
    guestlogin.eq(0).html(guesttranslation[0] + ", <strong>" + guesttranslation[1] + "</strong>. " + guesttranslation[2] + " <a href='"+smf_scripturl+"?action=login'>" + guesttranslation[3] + "</a> " + guesttranslation[4] + " <a href='"+smf_scripturl+"?action=register'>" + guesttranslation[5] + "</a>.<br>" + guesttranslation[6] + " <a href='"+smf_scripturl+"?action=activate'>" + guesttranslation[7] + "?");
    guestlogin.eq(1).html(guesttranslation[8]);
}
//----------------------------------------------------------------
function translate_tabs(tabid,translation) {
    var tab= $("#"+tabid).children("a").children("span");
    if (tab.children("img").length == "1") {
        tab.html(tab.children("img").prop("outerHTML") + "  " + translation);
    } else {
        tab.html(translation);
    }
}
function translate_tabsdropdown(tabid,eq,translation) {
    $("#"+tabid).children("ul").children("li").eq(eq).children("a").children("span").html(translation);
}
translate_tabs("button_home", tabtranslation[0]);
translate_tabs("button_forum", tabtranslation[1]);
translate_tabs("button_search", tabtranslation[2]);
translate_tabs("button_admin", tabtranslation[3]);
translate_tabs("button_moderate", tabtranslation[4]);
translate_tabs("button_profile", tabtranslation[5]);
translate_tabs("button_pm", tabtranslation[6]);
translate_tabs("button_calendar", tabtranslation[7]);
translate_tabs("button_gallery", tabtranslation[8]);
translate_tabs("button_arcade", tabtranslation[9]);
translate_tabs("button_mlist", tabtranslation[10]);
translate_tabs("button_chat", tabtranslation[11]);
translate_tabs("button_logout", tabtranslation[12]);
translate_tabs("button_login", tabtranslation[13]);
translate_tabs("button_register", tabtranslation[14]);
translate_tabsdropdown("button_admin","0",tabdropdowntranslation[0]);
translate_tabsdropdown("button_admin","1",tabdropdowntranslation[1]);
translate_tabsdropdown("button_moderate","0",tabdropdowntranslation[2]);
translate_tabsdropdown("button_profile","0",tabdropdowntranslation[3]);
translate_tabsdropdown("button_profile","1",tabdropdowntranslation[4]);
translate_tabsdropdown("button_profile","2",tabdropdowntranslation[5]);
translate_tabsdropdown("button_pm","0",tabdropdowntranslation[6]);
translate_tabsdropdown("button_pm","1",tabdropdowntranslation[7]);
translate_tabsdropdown("button_calendar","0",tabdropdowntranslation[8]);
translate_tabsdropdown("button_calendar","1",tabdropdowntranslation[9]);
translate_tabsdropdown("button_mlist","0",tabdropdowntranslation[10]);
translate_tabsdropdown("button_mlist","1",tabdropdowntranslation[11]);
//----------------------------------------------------------------
</script>
Editing Instructions: The words you need to translate are at the top of the code and are in quotes, you'll see where to start and stop translating.
« Last Edit: July 22, 2013, 03:32:44 am by aIURbliS »
All codes I make are tested on the latest version of Google Chrome and upon request of other browsers.

Share on Facebook Share on Twitter


 

Related Topics

  Subject / Started by Replies Last post
12 Replies
3402 Views
Last post December 02, 2014, 06:57:57 pm
by CyanProductions
1 Replies
820 Views
Last post March 14, 2012, 04:53:55 pm
by aIURbliS
1 Replies
1109 Views
Last post September 30, 2012, 05:23:55 pm
by aIURbliS
22 Replies
3497 Views
Last post December 20, 2014, 02:36:36 pm
by koleradeniz
8 Replies
1119 Views
Last post May 17, 2013, 06:34:37 am
by shell