*/ declare(strict_types = 1); require_once __DIR__ . "/../functions/functions.php"; /** * Generates the json for a translation file. * * @param string $lang Language. * * @return string */ function generateFieldsIndex(string $lang):string { $fieldsGetter = new CsvxmlAvailableFields($lang); $availableFields = $fieldsGetter->getFields(); return MD_STD::json_encode($availableFields); } /** * Generates the json for a translation file. * * @param string $lang Language. * * @return string */ function generateTranslationFile(string $lang):string { $tlLoader = new MDTlLoader("csvxml_tl_cache", $lang); return MD_STD::json_encode([ 'remarks' => $tlLoader->tl('basis', 'basis', 'remarks'), 'download' => $tlLoader->tl('export', 'export', 'download'), 'upload' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'upload'), 'select_csv_file_for_upload' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'select_csv_file_for_upload'), 'currently_approved_tags' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'currently_approved_tags'), 'download_csv_all' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'download_csv_all'), 'download_csv_by_selection' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'download_csv_by_selection'), 'select_required_fields' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'select_required_fields'), 'select_all_fields' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'select_all_fields'), 'unset_selection' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'unset_selection'), 'file_format' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'file_format'), 'validation_errors' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'validation_errors'), 'errors_parsing' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'errors_parsing'), 'errors_mandatoryTags' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'errors_mandatoryTags'), 'errors_duplicateInvNos' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'errors_duplicateInvNos'), 'errors_dependentColumns' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'errors_dependentColumns'), 'errors_controlledLists' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'errors_controlledLists'), 'errors_mainImageResource' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'errors_mainImageResource'), 'allowed_values' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'allowed_values'), ]); } /** * Generate index.htm. * * @return string */ function generateAppShell():string { return ' CSVXML :: museum-digital

museum-digital:csvxml

'; } const SERVED_ROOT = __DIR__ . '/../public/'; const SERVED_JSON_ROOT = __DIR__ . '/../public/json/'; if (!is_dir(SERVED_JSON_ROOT)) mkdir(SERVED_JSON_ROOT); foreach (ALLOWED_LANGS as $lang) { file_put_contents(SERVED_JSON_ROOT . 'fields.' . $lang . '.json', generateFieldsIndex($lang)); file_put_contents(SERVED_JSON_ROOT . 'tls.' . $lang . '.json', generateTranslationFile($lang)); } file_put_contents(SERVED_ROOT . 'index.htm', generateAppShell());