diff options
author | Christian A. Weber | 2021-03-18 16:45:33 +0100 |
---|---|---|
committer | Christian A. Weber | 2021-03-18 16:45:33 +0100 |
commit | 021e5fa60d004f32a1cada8b816478eb6ad76a70 (patch) | |
tree | 76f5e2f0eed1473019c90262c190553c6e7f4d7f | |
parent | 5b961eaa9a3063c557010089d8a674ccc524a1fd (diff) | |
download | itools-021e5fa60d004f32a1cada8b816478eb6ad76a70.tar.gz itools-021e5fa60d004f32a1cada8b816478eb6ad76a70.tar.bz2 itools-021e5fa60d004f32a1cada8b816478eb6ad76a70.zip |
refactor dump_php() to create more stable format using new array syntax without calling convertsyntax.php
-rw-r--r-- | it_text.class | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/it_text.class b/it_text.class index 07b0e7a..5e33395 100644 --- a/it_text.class +++ b/it_text.class @@ -266,16 +266,20 @@ function dump_php() # Special sorting: natural, but _ is the first entry uksort($this->statictext, "strnatcmp"); - $this->statictext = array_merge(array('_' => $this->statictext['_']), $this->statictext); + $this->statictext = array_merge(['_' => $this->statictext['_']], $this->statictext); $oldmask = umask(002); $filename = $this->p['phpfiles'][0]; if ((count($this->p['phpfiles']) == 1)) { - $dump = '<?php return ' . strtr(var_export($this->statictext, true), array("=> \n array (" => "=> array(", "array (\n '_'" => "array(\n'_'", "\n ),\n " => "\n),\n", "\n ),\n" => "\n),\n", "\r" => "")) . ";\n?>\n"; - it::file_put_contents($tmpfile = tempnam('/tmp/', 'texts_'), $dump); - $result = it::system('/www/server/bin/convertsyntax.php -a {tmpfile} >{filename}', ['tmpfile' => $tmpfile, 'filename' => $filename]) == 0; - unlink($tmpfile); + foreach ($this->statictext as $label => $texts) + { + $dump .= var_export($label, true) . " => [\n"; + foreach ($texts as $lang => $text) + $dump .= " " . var_export($lang, true) . " => " . var_export($text, true) . ",\n"; + $dump .= "],\n"; + } + $result = it::file_put_contents($filename, "<?php return [\n$dump];\n"); } umask($oldmask); @@ -283,4 +287,3 @@ function dump_php() } } /* End class it_text */ -?> |