// Global Const var CMS_Translation_Folder = "/home/httpd/html/js"; // Global Variables var Translation_Languages; /* Array of all found languages */ var Translation_English; var Translation_Other; /********************************************************************************************** * InitTranslation() * * * * Prepare the Translation-Database. Read the english sentences and the other sentences from * * the translation .txt files * * * **********************************************************************************************/ function InitTranslation() { var oRequest = new createXMLHttpRequest(); oRequest.open("GET","/index.cgi?script=cms_cgi&action=GetListOfFiles&TranslationFolder=" + CMS_Translation_Folder,false); oRequest.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); oRequest.send(null); // Error Reading the file if (oRequest.status!=200) { return; } // Parse all Lines response = oRequest.responseText; //alert("response = " + response); lines = response.split('\n'); Translation_Languages = new Array(); Index2 = 0; for (Index = 0; Index < lines.length; Index++) { if (lines[Index].length > 0) { Translation_Languages[Index2++] = lines[Index]; } } for (Index = 0; Index < Translation_Languages.length; Index++) { Translation_Languages[Index] = removeNL(Translation_Languages[Index]); IndexEnd = Translation_Languages[Index].indexOf('.'); Translation_Languages[Index] = Translation_Languages[Index].substring(0, IndexEnd); } //alert("Translation_Languages = " + Translation_Languages); var English = LoadTextFile(CMS_Translation_Folder + "/en.txt"); Translation_English = English.split('\n'); var Other = LoadTextFile(CMS_Translation_Folder + "/" + CMS_Configuration_Language + ".txt"); Translation_Other = Other.split('\n'); Index = 0; while (Index < Translation_English.length) { Translation_English[Index] = removeNL(Translation_English[Index]); Index+=1; } Index = 0; while (Index < Translation_Other.length) { Translation_Other[Index] = removeNL(Translation_Other[Index]); Index+=1; } } /********************************************************************************************** * _T() * * * * Translate from language english to some other language "CMS_Configuration_Language" * * * **********************************************************************************************/ function _T(str) { var Index = 0; while (Index < Translation_English.length) { if (Translation_English[Index] == str) { return(Translation_Other[Index]); } Index+=1; } return null; }