/** * Clean up a languages dir * * @param string $dir Languages dir * * @return void */ public function cleanLanguagesDir($dir) { $dir = rtrim($dir, '/\\'); foreach (scandir($dir) as $entry) { if ($entry[0] === '.') { continue; } if (pathinfo($entry, PATHINFO_EXTENSION) !== 'php') { continue; } $path = "{$dir}/{$entry}"; $code = basename($entry, '.php'); if (!in_array($code, $this->codes)) { $code = Translator::normalizeLanguageCode($code); if (in_array($code, $this->codes)) { // rename file to lowercase rename($path, "{$dir}/{$code}.php"); $this->log[] = "Renamed {$path} to {$code}.php"; continue; } unlink($path); $this->log[] = "Removed {$path}"; } } }