PageRenderTime 47ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/sugarcrm/SugarCE-Full-5.0.0/translate_m.php

http://twpug.googlecode.com/
PHP | 222 lines | 182 code | 2 blank | 38 comment | 39 complexity | c9df8899067fe8a6c4b1fb70d61662f0 MD5 | raw file
Possible License(s): AGPL-1.0
  1. <?php
  2. // Configuration area start
  3. // Please config the following settings before translation besides Traditional Chinese :)
  4. // Notice :
  5. // 1. Give rights to web server for writing all language files if you are not use M$ OS
  6. // ex. /language/ and /modules/*/language/
  7. // 2. Please put this script to the root path of your vtigerCRM installation
  8. define('sugarEntry', 'test');
  9. class sugarEntry {
  10. function sugarEntry() {
  11. return 1;
  12. }
  13. }
  14. function remove_slashes($string) {
  15. $string = str_replace('\\\\', '\\', $string);
  16. return str_replace('\\"', '"', $string);
  17. }
  18. $bk = chr(10); // The sign of line break
  19. $qo = ' '; // The sign for quote
  20. $lang = 'zh-tw'; // Your language code in ISO-XXX
  21. $encode = 'UTF-8'; // The encode you want to use
  22. // Configuration area end
  23. ?>
  24. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="<?php echo $lang; ?>">
  25. <head>
  26. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $encode; ?>" />
  27. <style type="text/css">
  28. body{
  29. font-size: 10pt;
  30. }
  31. input{
  32. height: 17pt;
  33. border: 1px solid black;
  34. background-color: #A5A5A5;
  35. color: #FFFFFF;
  36. }
  37. div{
  38. line-height: 20pt;
  39. }
  40. </style>
  41. </head>
  42. <body>
  43. <form method="get">
  44. Modules :<select name="kfolder">
  45. <?php
  46. $dir = "modules";
  47. if ($dh = opendir($dir)) {
  48. while (($folder = readdir($dh)) !== false) {
  49. if (is_dir($dir . '/' . $folder) && $folder != '..' && $folder != '.' && file_exists($dir . '/' . $folder . '/language/en_us.lang.php')) {
  50. echo '<option';
  51. if ($folder == $_GET['kfolder']) echo ' selected';
  52. echo '>' . $folder . '</option>';
  53. }
  54. }
  55. closedir($dh);
  56. }
  57. ?>
  58. </select><input type="submit"></form>
  59. <br>
  60. <?php
  61. if ($_GET['kfolder']) {
  62. echo '<form method="post">';
  63. if ($_POST['go']) {
  64. $string = '';
  65. @unlink('modules/' . $_GET['kfolder'] . '/language/' . $lang . '.lang.php_old');
  66. @copy('modules/' . $_GET['kfolder'] . '/language/' . $lang . '.lang.php', 'modules/' . $_GET['kfolder'] . '/language/' . $lang . '.lang.php_old');
  67. $fd = fopen('modules/' . $_GET['kfolder'] . '/language/' . $lang . '.lang.php', 'w');
  68. fwrite($fd, '<?php' . $bk);
  69. fwrite($fd, 'if(!defined(\'sugarEntry\') || !sugarEntry) die(\'Not A Valid Entry Point\');' . $bk);
  70. fwrite($fd, '$mod_strings = array (' . $bk);
  71. //$string .= 'app_list_strings = array ('.$bk;
  72. foreach($_POST['mod_strings'] as $key1 => $arr) {
  73. if (is_array($arr)) {
  74. $string.= $qo . '\'' . $key1 . '\' =>' . $bk . $qo . 'array (' . $bk;
  75. foreach($arr as $key2 => $arr2) {
  76. if (is_array($arr2)) {
  77. $string.= $qo . '\'' . $key2 . '\' =>' . $bk . $qo . $qo . 'array (' . $bk;
  78. foreach($arr2 as $key3 => $arr3) {
  79. $string.= $qo . $qo . $qo . '\'' . $key3 . '\' => \'' . remove_slashes($arr3) . '\',' . $bk;
  80. }
  81. $string.= $qo . $qo . '),' . $bk;
  82. } else {
  83. $string.= $qo . $qo . '\'' . $key2 . '\' => \'' . remove_slashes($arr2) . '\',' . $bk;
  84. }
  85. }
  86. $string.= $qo . '),' . $bk;
  87. } else {
  88. $string.= $qo . '\'' . $key1 . '\' => \'' . remove_slashes($arr) . '\',' . $bk;
  89. }
  90. }
  91. fwrite($fd, $string);
  92. $string = '';
  93. if (sizeof($_POST['mod_list_strings']) > 0) {
  94. fwrite($fd, $bk . ');' . $bk . '$mod_list_strings = array (' . $bk);
  95. foreach($_POST['mod_list_strings'] as $key1 => $arr) {
  96. if (is_array($arr)) {
  97. $string.= $qo . '\'' . $key1 . '\' =>' . $bk . $qo . 'array (' . $bk;
  98. foreach($arr as $key2 => $string1) {
  99. $string.= $qo . $qo . '\'' . $key2 . '\' => \'' . remove_slashes($string1) . '\',' . $bk;
  100. }
  101. $string.= $qo . '),' . $bk;
  102. } else {
  103. $string.= $qo . '\'' . $key1 . '\' => \'' . remove_slashes($arr) . '\',' . $bk;
  104. }
  105. }
  106. fwrite($fd, $string);
  107. }
  108. fwrite($fd, $bk . ');' . $bk . '?>');
  109. }
  110. include 'modules/' . $_GET['kfolder'] . '/language/en_us.lang.php';
  111. $en_mod_strings = $mod_strings;
  112. $en_mod_strings2 = $en_mod_strings;
  113. $en_mod_list_strings = $mod_list_strings;
  114. $en_mod_list_strings2 = $en_mod_list_strings;
  115. if (file_exists('modules/' . $_GET['kfolder'] . '/language/' . $lang . '.lang.php')) include 'modules/' . $_GET['kfolder'] . '/language/' . $lang . '.lang.php';
  116. $result1 = array_merge($en_mod_strings, $mod_strings);
  117. if (is_array($en_mod_list_strings)) {
  118. $result2 = array_merge($en_mod_list_strings, $mod_list_strings);
  119. }
  120. /*
  121. foreach($en_mod_strings AS $key => $arr) {
  122. if (array_key_exists($key, $result1)) {
  123. if (is_array($arr)) {
  124. foreach($arr as $key2 => $arr2) {
  125. if (!array_key_exists($key2, $result1[$key])) {
  126. $result1[$key][$key2] = $en_mod_strings[$key][$key2];
  127. }
  128. }
  129. }
  130. } else {
  131. $result1[$key] = $en_mod_strings[$key];
  132. }
  133. }
  134. if (is_array($en_mod_list_strings)) {
  135. foreach($en_mod_list_strings AS $key => $arr) {
  136. if (array_key_exists($key, $result2)) {
  137. if (is_array($arr)) {
  138. foreach($arr as $key2 => $string) {
  139. if (!array_key_exists($key2, $result2[$key])) {
  140. $result2[$key][$key2] = $en_mod_list_strings[$key][$key2];
  141. }
  142. }
  143. }
  144. } else {
  145. $result2[$key] = $en_mod_list_strings[$key];
  146. }
  147. }
  148. }
  149. */
  150. $cidx = 0;
  151. function div_color($idx) {
  152. if ($idx%2 == 0) return '#C0C0C0';
  153. else return '#848484';
  154. }
  155. foreach($result1 as $key => $arr) {
  156. if (array_key_exists($key, $en_mod_strings)) {
  157. if (is_array($arr)) {
  158. foreach($arr as $key2 => $arr2) {
  159. if (is_array($arr2)) {
  160. foreach($arr2 as $key3 => $arr3) {
  161. if (array_key_exists($key3, $en_mod_strings[$key][$key2])) {
  162. $arr3 = htmlentities($arr3, ENT_QUOTES, $encode);
  163. echo '<div style="background-color:' . div_color($cidx) . '">&nbsp;&nbsp;<input type="text" name="mod_strings[' . $key . '][' . $key2 . '][' . $key3 . ']" value="' . $arr3 . '" size="80">';
  164. echo $en_mod_strings2[$key][$key2][$key3];
  165. echo '</div>';
  166. $cidx++;
  167. }
  168. }
  169. } else {
  170. if (array_key_exists($key2, $en_mod_strings[$key])) {
  171. $arr2 = htmlentities($arr2, ENT_QUOTES, $encode);
  172. echo '<div style="background-color:' . div_color($cidx) . '">&nbsp;&nbsp;<input type="text" name="mod_strings[' . $key . '][' . $key2 . ']" value="' . $arr2 . '" size="80">';
  173. echo $en_mod_strings2[$key][$key2];
  174. echo '</div>';
  175. $cidx++;
  176. }
  177. }
  178. }
  179. } else {
  180. $arr = htmlentities($arr, ENT_QUOTES, $encode);
  181. echo '<div style="background-color:' . div_color($cidx) . '">&nbsp;&nbsp;<input type="text" name="mod_strings[' . $key . ']" value="' . $arr . '" size="80">';
  182. echo $en_mod_strings2[$key];
  183. echo '</div>';
  184. $cidx++;
  185. }
  186. }
  187. }
  188. if ($result2) {
  189. foreach($result2 as $key => $arr) {
  190. if (array_key_exists($key, $en_mod_list_strings)) {
  191. if (is_array($arr)) {
  192. foreach($arr as $key2 => $string) {
  193. if (array_key_exists($key2, $en_mod_list_strings[$key])) {
  194. $string = htmlentities($string, ENT_QUOTES, $encode);
  195. echo '<div style="background-color:' . div_color($cidx) . '">&nbsp;&nbsp;<input type="text" name="mod_list_strings[' . $key . '][' . $key2 . ']" value="' . $string . '" size="80">';
  196. echo $en_mod_list_strings2[$key][$key2];
  197. echo '</div>';
  198. }
  199. }
  200. } else {
  201. $arr = htmlentities($arr, ENT_QUOTES, $encode);
  202. echo '<div style="background-color:' . div_color($cidx) . '">&nbsp;&nbsp;<input type="text" name="mod_list_strings[' . $key . ']" value="' . $arr . '" size="80"><br>';
  203. echo $en_mod_list_strings2[$key];
  204. echo '</div>';
  205. }
  206. }
  207. }
  208. }
  209. echo '<input type="submit" name="go" value="go">';
  210. echo '</form>';
  211. } else if ($_GET['mfile']) {
  212. if ($_POST['mgo']) {
  213. }
  214. echo '<form method="post">';
  215. echo '<input type="submit" name="mgo" value="go">';
  216. echo '</form>';
  217. }
  218. ?>
  219. </body>
  220. </html>