languages.inc.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <?php
  2. // -------------------------------------------------------------------------------
  3. // | net2ftp: a web based FTP client |
  4. // | Copyright (c) 2003-2013 by David Gartner |
  5. // | |
  6. // | This program is free software; you can redistribute it and/or |
  7. // | modify it under the terms of the GNU General Public License |
  8. // | as published by the Free Software Foundation; either version 2 |
  9. // | of the License, or (at your option) any later version. |
  10. // | |
  11. // -------------------------------------------------------------------------------
  12. // **************************************************************************************
  13. // **************************************************************************************
  14. // ** **
  15. // ** **
  16. function getLanguageArray() {
  17. // --------------
  18. // This function returns an array of languages
  19. // Use the ISO 639 code described here: http://www.w3.org/WAI/ER/IG/ert/iso639.htm
  20. // --------------
  21. $languageArray["ar"]["name"] = "Arabic";
  22. $languageArray["ar"]["file"] = "ar.inc.php";
  23. $languageArray["ar-utf"]["name"] = "Arabic UTF-8";
  24. $languageArray["ar-utf"]["file"] = "ar-utf.inc.php";
  25. $languageArray["zh"]["name"] = "Simplified Chinese";
  26. $languageArray["zh"]["file"] = "zh.inc.php";
  27. $languageArray["tc"]["name"] = "Traditional Chinese";
  28. $languageArray["tc"]["file"] = "tc.inc.php";
  29. $languageArray["cs"]["name"] = "Czech";
  30. $languageArray["cs"]["file"] = "cs.inc.php";
  31. $languageArray["da"]["name"] = "Danish UTF-8";
  32. $languageArray["da"]["file"] = "da-utf.inc.php";
  33. $languageArray["nl"]["name"] = "Dutch";
  34. $languageArray["nl"]["file"] = "nl.inc.php";
  35. $languageArray["en"]["name"] = "English";
  36. $languageArray["en"]["file"] = "en.inc.php";
  37. $languageArray["en-utf"]["name"] = "English UTF-8";
  38. $languageArray["en-utf"]["file"] = "en-utf.inc.php";
  39. $languageArray["fr"]["name"] = "French";
  40. $languageArray["fr"]["file"] = "fr.inc.php";
  41. $languageArray["de"]["name"] = "German";
  42. $languageArray["de"]["file"] = "de.inc.php";
  43. $languageArray["fi"]["name"] = "Finnish";
  44. $languageArray["fi"]["file"] = "fi.inc.php";
  45. $languageArray["he"]["name"] = "Hebrew";
  46. $languageArray["he"]["file"] = "he-utf.inc.php";
  47. $languageArray["hu"]["name"] = "Hungarian";
  48. $languageArray["hu"]["file"] = "hu.inc.php";
  49. $languageArray["hu-utf"]["name"] = "Hungarian UTF-8";
  50. $languageArray["hu-utf"]["file"] = "hu-utf.inc.php";
  51. $languageArray["it"]["name"] = "Italian";
  52. $languageArray["it"]["file"] = "it.inc.php";
  53. $languageArray["ja"]["name"] = "Japanese";
  54. $languageArray["ja"]["file"] = "ja.inc.php";
  55. $languageArray["pl"]["name"] = "Polish";
  56. $languageArray["pl"]["file"] = "pl.inc.php";
  57. $languageArray["pt"]["name"] = "Portugese";
  58. $languageArray["pt"]["file"] = "pt.inc.php";
  59. $languageArray["ru"]["name"] = "Russian";
  60. $languageArray["ru"]["file"] = "ru.inc.php";
  61. $languageArray["es"]["name"] = "Spanish";
  62. $languageArray["es"]["file"] = "es.inc.php";
  63. $languageArray["sv"]["name"] = "Swedish";
  64. $languageArray["sv"]["file"] = "sv.inc.php";
  65. $languageArray["tr"]["name"] = "Turkish";
  66. $languageArray["tr"]["file"] = "tr.inc.php";
  67. $languageArray["ua"]["name"] = "Ukrainian";
  68. $languageArray["ua"]["file"] = "ua.inc.php";
  69. $languageArray["vi"]["name"] = "Vietnamese";
  70. $languageArray["vi"]["file"] = "vi.inc.php";
  71. return $languageArray;
  72. } // End function getLanguageArray
  73. // ** **
  74. // ** **
  75. // **************************************************************************************
  76. // **************************************************************************************
  77. // **************************************************************************************
  78. // **************************************************************************************
  79. // ** **
  80. // ** **
  81. function printLanguageSelect($fieldname, $onchange, $style, $class) {
  82. // --------------
  83. // This function prints a select with the available languages
  84. // Language nr 1 is the default language
  85. // --------------
  86. global $net2ftp_globals;
  87. $languageArray = getLanguageArray();
  88. if ($net2ftp_globals["language"] != "") { $currentlanguage = $net2ftp_globals["language"]; }
  89. else { $currentlanguage = "en"; }
  90. if ($onchange == "") { $onchange_full = ""; }
  91. else { $onchange_full = "onchange=\"$onchange\""; }
  92. if ($style == "") { $style_full = ""; }
  93. else { $style_full = "style=\"$style\""; }
  94. if ($class == "") { $class_full = ""; }
  95. else { $class_full = "class=\"$class\""; }
  96. echo "<select name=\"$fieldname\" id=\"$fieldname\" $onchange_full $style_full $class_full>\n";
  97. foreach ($languageArray as $key => $value) {
  98. // $key loops over "en", "fr", "nl", ...
  99. // $value will be an array like $value["name"] = "English" and $value["file"] = "en.inc.php"
  100. if ($key == $currentlanguage) { $selected = "selected=\"selected\""; }
  101. else { $selected = ""; }
  102. echo "<option value=\"" . $key . "\" $selected>" . $value["name"] . "</option>\n";
  103. } // end while
  104. echo "</select>\n";
  105. } // End function printLanguageSelect
  106. // ** **
  107. // ** **
  108. // **************************************************************************************
  109. // **************************************************************************************
  110. // **************************************************************************************
  111. // **************************************************************************************
  112. // ** **
  113. // ** **
  114. function includeLanguageFile() {
  115. // -------------------------------------------------------------------------
  116. // Global variables
  117. // -------------------------------------------------------------------------
  118. global $net2ftp_globals, $net2ftp_messages;
  119. $languageArray = getLanguageArray();
  120. // If language exists, include the language file
  121. if (array_key_exists($net2ftp_globals["language"], $languageArray) == true) {
  122. $languageFile = glueDirectories($net2ftp_globals["application_languagesdir"], $languageArray[$net2ftp_globals["language"]]["file"]);
  123. require_once($languageFile);
  124. }
  125. // If it does not exist, use the default language nr "en" (English)
  126. else {
  127. $net2ftp_globals["language"] = "en";
  128. $languageFile = glueDirectories($net2ftp_globals["application_languagesdir"], $languageArray[$net2ftp_globals["language"]]["file"]);
  129. require_once($languageFile);
  130. }
  131. } // end function includeLanguageFile
  132. // ** **
  133. // ** **
  134. // **************************************************************************************
  135. // **************************************************************************************
  136. // **************************************************************************************
  137. // **************************************************************************************
  138. // ** **
  139. // ** **
  140. function __() {
  141. // --------------
  142. // This function returns a translated message; the core standard function used is sprintf (see manual)
  143. // Input: - from function argument: message name $args[0] and variable parts in the message $args[1], $args[2],...
  144. // (there is a variable nr of variable parts)
  145. // - from globals: the array of messages $message
  146. // Output: string in the language indicated in $net2ftp_language
  147. // --------------
  148. // -------------------------------------------------------------------------
  149. // Global variables
  150. // -------------------------------------------------------------------------
  151. global $net2ftp_globals, $net2ftp_messages;
  152. // -------------------------------------------------------------------------
  153. // Get the arguments of this function
  154. // $args[0] contains the messagename
  155. // $args[1], $args[2], ... contain the variables in the message
  156. // -------------------------------------------------------------------------
  157. $numargs = func_num_args();
  158. $args = func_get_args();
  159. $messagename = $args[0];
  160. // -------------------------------------------------------------------------
  161. // Create the argument for the sprintf function
  162. // Aim is to have something like: sprintf($string_with_percents, $args[1], $args[2], ...);
  163. // As there is a variable nr of arguments in the function __, there is also a variable
  164. // nr of arguments in sprintf, and this must be constructed with a loop
  165. // -------------------------------------------------------------------------
  166. // Check if the message with that $messagename exists
  167. if (@array_key_exists($messagename, $net2ftp_messages)) { $string_with_percents = $net2ftp_messages[$messagename]; }
  168. else { return "MESSAGE NOT FOUND $messagename"; }
  169. $sprintf_argument = "\$translated_string = sprintf(\$string_with_percents";
  170. for ($i=1; $i<$numargs; $i++) {
  171. $sprintf_argument .= ", @htmlentities(\$args[$i], ENT_QUOTES)";
  172. } // end for
  173. $sprintf_argument .= ");";
  174. // -------------------------------------------------------------------------
  175. // Run the sprintf function
  176. // -------------------------------------------------------------------------
  177. eval($sprintf_argument);
  178. return $translated_string;
  179. } // end function __
  180. // ** **
  181. // ** **
  182. // **************************************************************************************
  183. // **************************************************************************************
  184. ?>