PageRenderTime 25ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/sugarcrm/SugarOS-Full-4.5.1d/translate_i.php

http://twpug.googlecode.com/
PHP | 130 lines | 106 code | 8 blank | 16 comment | 14 complexity | 050ba1707f123c72dc8bc2440adf3215 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. {
  11. function sugarEntry()
  12. {
  13. return 1;
  14. }
  15. }
  16. $bk = chr(10); // The sign of line break
  17. $qo = ' '; // The sign for quote
  18. $lang = 'zh-tw'; // Your language code in ISO-XXX
  19. $encode = 'UTF-8'; // The encode you want to use
  20. // Configuration area end
  21. ?>
  22. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="<?php echo $lang; ?>">
  23. <head>
  24. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $encode; ?>" />
  25. <style type="text/css">
  26. body{
  27. font-size: 10pt;
  28. }
  29. input{
  30. height: 17pt;
  31. border: 1px solid black;
  32. background-color: #A5A5A5;
  33. color: #FFFFFF;
  34. }
  35. div{
  36. line-height: 20pt;
  37. }
  38. </style>
  39. </head>
  40. <body>
  41. <form method="post">
  42. <?php
  43. $string = '';
  44. if($_POST['go']){
  45. copy('install/language/'.$lang.'.lang.php', 'install/language/'.$lang.'.lang.php.bk');
  46. $fd = fopen('install/language/'.$lang.'.lang.php', 'w');
  47. fwrite($fd, '<?php'.$bk);
  48. fwrite($fd, 'if(!defined(\'sugarEntry\') || !sugarEntry) die(\'Not A Valid Entry Point\');'.$bk);
  49. fwrite($fd, '$mod_strings = array ('.$bk);
  50. //$string .= 'mod_strings = array ('.$bk;
  51. foreach($_POST['mod_strings'] as $key1 => $arr){
  52. if(is_array($arr)){
  53. $string .= $qo.'\''.$key1.'\' =>'.$bk.$qo.'array ('.$bk;
  54. foreach($arr as $key2 => $string1){
  55. $string .= $qo.$qo.'\''.$key2.'\' => \''.$string1.'\','.$bk;
  56. }
  57. $string .= $qo.'),'.$bk;
  58. } else {
  59. $string .= $qo.'\''.$key1.'\' => \''.$arr.'\','.$bk;
  60. }
  61. }
  62. fwrite($fd, $string);
  63. fwrite($fd, $bk.');'.$bk.'?>');
  64. }
  65. ?> </pre><?php
  66. include 'install/language/en_us.lang.php';
  67. $en_mod_strings = $mod_strings;
  68. //@copy('../vtiger423/install/language/zh_tw.lang.php', 'install/language/'.$lang.'.lang.php');
  69. include 'install/language/'.$lang.'.lang.php';
  70. $result1 = array_merge($en_mod_strings, $mod_strings);
  71. foreach($en_mod_strings AS $key => $arr) {
  72. if(array_key_exists($key, $result1)) {
  73. if(is_array($arr)) {
  74. foreach($arr as $key2 => $string){
  75. if(!array_key_exists($key2, $result1[$key])) {
  76. $result1[$key][$key2] = $en_mod_strings[$key][$key2];
  77. }
  78. }
  79. }
  80. } else {
  81. $result1[$key] = $en_mod_strings[$key];
  82. }
  83. }
  84. /*
  85. echo '<pre>';
  86. print_r($result2);
  87. echo '</pre>';
  88. exit();
  89. */
  90. function div_color($idx){
  91. if($idx % 2 == 0) return '#C0C0C0';
  92. else return '#848484';
  93. }
  94. $cidx = 0;
  95. foreach($result1 as $key => $arr){
  96. if(array_key_exists($key, $en_mod_strings))
  97. {
  98. if(is_array($arr)){
  99. //echo $key.'<p>';
  100. foreach($arr as $key2 => $string){
  101. if(array_key_exists($key2, $en_mod_strings[$key])) {
  102. $string = htmlentities($string, ENT_QUOTES, $encode);
  103. echo '<div style="background-color:'.div_color($cidx).'">&nbsp;&nbsp;<input type="text" name="mod_strings['.$key.']['.$key2.']" value="'.$string.'" size="80">';
  104. echo $en_mod_strings[$key][$key2];
  105. echo '</div>';
  106. $cidx++;
  107. }
  108. }
  109. } else {
  110. $arr = htmlentities($arr, ENT_QUOTES, $encode);
  111. echo '<div style="background-color:'.div_color($cidx).'">&nbsp;&nbsp;<input type="text" name="mod_strings['.$key.']" value="'.$arr.'" size="80">';
  112. echo $en_mod_strings[$key];
  113. echo '</div>';
  114. $cidx++;
  115. }
  116. }
  117. }
  118. ?>
  119. <input type="submit" name="go" value="go">
  120. </form>
  121. </body>
  122. </html>