PageRenderTime 66ms CodeModel.GetById 30ms RepoModel.GetById 1ms app.codeStats 0ms

/i18n_v2/setup files/mysql2xml.php

http://flaimo-php.googlecode.com/
PHP | 43 lines | 31 code | 12 blank | 0 comment | 1 complexity | f668c29f4df19fc69971234d5ccff69c MD5 | raw file
  1. <?php
  2. error_reporting(E_ALL);
  3. $lang = 'ru';
  4. $link = mysql_connect("127.0.0.1", "root", "");
  5. mysql_select_db("translator_testdb");
  6. $result = mysql_query ('set character set utf8', $link);
  7. $result = mysql_query ('select namespace, string, `' . $lang . '` from flp_translator order by namespace',$link);
  8. while ($row = mysql_fetch_row ($result)) {
  9. $strings[$row[0]][$row[1]] = $row[2];
  10. } // end while
  11. foreach ($strings as $namespace => $data) {
  12. $str = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' . "\n";
  13. $str .= '<translator>' . "\n";
  14. $str .= ' <locale id="' . $lang . '">' . "\n";
  15. $str .= ' <namespace id="' . $namespace . '">' . "\n";
  16. $str .= ' <meta>' . "\n";
  17. $str .= ' <author mail="flaimo@gmx.net">Flaimo</author>' . "\n";
  18. $str .= ' <created>' . date('Y-m-d H:i:s') . '</created>' . "\n";
  19. $str .= ' <lastchange>' . date('Y-m-d H:i:s') . '</lastchange>' . "\n";
  20. $str .= ' </meta>' . "\n";
  21. $str .= ' <translations>' . "\n";
  22. foreach ($data as $string => $translation) {
  23. $str .= ' <translation string="' . $string . '">' . $translation . '</translation>' . "\n";
  24. } // end foreach
  25. $str .= ' </translations>' . "\n";
  26. $str .= ' </namespace>' . "\n";
  27. $str .= ' </locale>' . "\n";
  28. $str .= '</translator>' . "\n";
  29. file_put_contents ($namespace . '.xml', $str);
  30. } // end foreach
  31. ?>