function translation_editor_write_translation($current_language, $plugin, $translation) { global $CONFIG; $result = false; if (!empty($current_language) && !empty($plugin) && !empty($translation)) { translation_editor_check_file_structure($current_language); $base_dir = $CONFIG->dataroot . "translation_editor" . DIRECTORY_SEPARATOR; $contents = json_encode($translation); if ($bytes = file_put_contents($base_dir . $current_language . DIRECTORY_SEPARATOR . $plugin . ".json", $contents)) { $result = $bytes; } } return $result; }
/** * Write the custom translation for a plugin to disk * * @param string $current_language the language for the translations * @param string $plugin the translated plugin * @param array $translation the translations * * @return false|int */ function translation_editor_write_translation($current_language, $plugin, $translation) { if (empty($current_language) || empty($plugin) || empty($translation)) { return false; } translation_editor_check_file_structure($current_language); $base_dir = elgg_get_data_path() . 'translation_editor' . DIRECTORY_SEPARATOR; $file_name = $base_dir . $current_language . DIRECTORY_SEPARATOR . $plugin . '.json'; $contents = json_encode($translation); $bytes = file_put_contents($file_name, $contents); if (empty($bytes)) { return false; } return $bytes; }