. /** * Script for converting moodle strings to json. */ // Check we are in CLI. if (isset($_SERVER['REMOTE_ADDR'])) { exit(1); } define('MOODLE_INTERNAL', 1); define('LANGPACKSFOLDER', '../../moodle-langpacks'); define('ASSETSPATH', '../src/assets/lang/'); define('CONFIG', '../moodle.config.json'); define('OVERRIDE_LANG_SUFIX', false); global $strings; require_once('lang_functions.php'); $config = file_get_contents(CONFIG); $config = (array) json_decode($config); $config_langs = array_keys(get_object_vars($config['languages'])); // Set languages to do. If script is called using a language it will be used as unique. if (isset($argv[1]) && !empty($argv[1])) { $forcedetect = false; define('TOTRANSLATE', true); $languages = explode(',', $argv[1]); } else { $forcedetect = true; define('TOTRANSLATE', false); $languages = $config_langs; } $keys = get_langindex_keys(); $added_langs = build_languages($languages, $keys); if ($forcedetect) { $new_langs = detect_languages($languages, $keys); if (!empty($new_langs)) { echo "\n\n\nThe following languages are going to be added\n\n\n"; $added_langs = build_languages($new_langs, $keys, $added_langs); } } add_langs_to_config($added_langs, $config);