$values) { if (is_array($values)) { foreach ($values as $key => $value) { $data[$section][$key] = preg_replace('/\\R/', "\n", trim($value)); } } else if ('LANG_DIR' === $section) { $data[$section] = $values; } } return str_replace(' ', "\t", json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)); } if ('POST' === $_SERVER['REQUEST_METHOD']) { try { $file = tempnam(sys_get_temp_dir(), ''); $zip = new ZipArchive(); if (!$zip->open($file, ZIPARCHIVE::CREATE)) { exit("Failed to create zip"); } if (!$lang) { $lang = (empty($_POST['lang']) || !preg_match('/^[a-z]{2}(-[A-Z]{2})?$/D',$_POST['lang'])) ? 'new' : $_POST['lang']; } $zip->addFromString("{$lang}/admin.json", toJSON($_POST['admin'])); $zip->addFromString("{$lang}/user.json", toJSON($_POST['user'])); $zip->close(); header('Content-Type: application/zip'); header('Content-disposition: attachment; filename="snappymail-'.$lang.'.zip"'); header('Content-Length: ' . filesize($file)); readfile($file); } catch (\Throwable $e) { echo $e->getMessage(); } unlink($file); exit; } // /home/rainloop/public_html/snappymail/v/0.0.0/static/js $_ENV['SNAPPYMAIL_INCLUDE_AS_API'] = true; require 'demo/index.php'; $root = APP_VERSION_ROOT_PATH . 'app/localization'; $en = [ 'user' => '', 'admin' => '', // 'static' => '', ]; foreach ($en as $name => $data) { $en[$name] = json_decode(file_get_contents("{$root}/en/{$name}.json"), true); } $languages = ['']; foreach (glob("{$root}/*", GLOB_ONLYDIR) as $dir) { $name = basename($dir); if ('en' !== $name) { $languages[$name] = ""; } } ksort($languages); $lang_names = json_decode(file_get_contents("{$root}/langs.json"), true)['LANGS_NAMES_EN']; $other_langs = []; foreach ($lang_names as $key => $name) { if ('en' !== $key && !isset($languages[$key])) { $other_langs[$key] = ""; } } //print_r($languages); echo ' Translate

Translate:

Show untranslated only '; foreach ($en as $name => $sections) { echo ''; $data = $sections; if ($lang && is_readable("{$root}/{$lang}/{$name}.json")) { $data = json_decode(file_get_contents("{$root}/{$lang}/{$name}.json"), true); } foreach ($sections as $section => $values) { if (is_array($values)) { echo ''; foreach ($values as $key => $value) { echo ''; // echo ''; echo ''; echo ''; echo ''; } } else if ('LANG_DIR' === $section) { echo ''; echo ''; echo ''; echo ''; } } echo ''; } echo '
en '.($lang ? "{$lang_names[$lang]} ({$lang})" : '').'
'.$name.'
'.$section.'
'.$section.'/'.$key.''.htmlspecialchars($value).'
Text direction
'; echo '
'; /*