diff --git a/tests/translations/translate_all_languages_array_to_po.php b/tests/translations/translate_all_languages_array_to_po.php new file mode 100644 index 0000000000..114e75c114 --- /dev/null +++ b/tests/translations/translate_all_languages_array_to_po.php @@ -0,0 +1,79 @@ +isDir()) { + $langPath = $folder->getPathname(); + + if ($folder->getBasename() != 'spanish') { + //continue; + } + + $langIterator = new FilesystemIterator($langPath); + $filter = new RegexIterator($langIterator, '/\.(php)$/'); + foreach ($filter as $phpFile) { + $phpFilePath = $phpFile->getPathname(); + $po = file($phpFilePath); + $translations = array(); + $englishFile = $englishDir.'/'.$phpFile->getBasename(); + foreach ($po as $line) { + $pos = strpos($line, '='); + if ($pos) { + $variable = (substr($line, 1, $pos-1)); + $variable = trim($variable); + + require $englishFile; + $my_variable_in_english = $variable; + + require $phpFilePath; + $my_variable = $$variable; + $translations[] = array('msgid' => $my_variable_in_english, 'msgstr' =>$my_variable); + } + } + + + $code = api_get_language_isocode($folder->getBasename()); + //LC_MESSAGES + $new_po_file = $save_path.$folder->getBasename().'/'.$phpFile->getBasename('.php').'.po'; + + if (!is_dir($save_path.$folder->getBasename())) { + mkdir($save_path.$folder->getBasename()); + } + $fp = fopen($new_po_file, 'w'); + foreach ($translations as $item) { + $line = 'msgid "'.addslashes($item['msgid']).'"'."\n"; + $line .= 'msgstr "'.addslashes($item['msgstr']).'"'."\n\n"; + fwrite($fp, $line); + } + fclose($fp); + } + if ($folder->getBasename() == 'bosnian') { + //exit; + } + } +} \ No newline at end of file diff --git a/tests/translations/translate_array_to_po.php b/tests/translations/translate_array_to_po.php new file mode 100644 index 0000000000..45ad86ae5c --- /dev/null +++ b/tests/translations/translate_array_to_po.php @@ -0,0 +1,75 @@ +"; + + $translations = array(); + $filename = $dir.'/'.$file; + $po = file($filename); + if (!file_exists($filename) || !file_exists($to_dir.'/'.$file)) { + continue; + } + + foreach ($po as $line) { + $pos = strpos($line, '='); + if ($pos) { + $variable = (substr($line, 1, $pos-1)); + $variable = trim($variable); + require $filename; + $my_variable_in_english = $$variable; + require $to_dir.'/'.$file; + $my_variable = $$variable; + $translations[] = array('msgid' =>$my_variable_in_english, 'msgstr' =>$my_variable); + } + } + //var_dump($translations); + $info['filename'] = explode('.', $info['filename']); + $info['filename'] = $info['filename'][0]; + $new_po_file = $save_dir_path.'/LC_MESSAGES/'.$info['filename'].'.po'; + var_dump($new_po_file); + $fp = fopen($new_po_file, 'w'); + var_dump($fp); + foreach ($translations as $item) { + $line = 'msgid "'.addslashes($item['msgid']).'"'."\n"; + $line .= 'msgstr "'.addslashes($item['msgstr']).'"'."\n\n"; + fwrite($fp, $line); + } + fclose($fp); + } + closedir($dh); + } +} \ No newline at end of file