35 $this->codes = $codes;
48 if (is_dir(
"{$dir}/install/languages")) {
52 if (is_dir(
"{$dir}/languages")) {
56 $mods = new \DirectoryIterator(
"{$dir}/mod");
58 foreach ($mods as $mod) {
59 if ($mod->isDot() || !$mod->isDir()) {
68 if (is_dir(
"{$mod->getPathname()}/languages")) {
85 $files = new \DirectoryIterator($dir);
86 foreach ($files as $file) {
87 if ($file->isDot() || !$file->isFile()) {
91 if ($file->getExtension() !==
'php') {
95 $code = $file->getBasename(
'.php');
96 if (!in_array(
$code, $this->codes)) {
99 if (in_array(
$code, $this->codes)) {
101 rename($file->getPathname(),
"{$dir}/{$code}.php");
102 $this->
log[] =
"Renamed {$file->getPathname()} to {$code}.php";
104 unlink($file->getPathname());
105 $this->
log[] =
"Removed {$file->getPathname()}";
109 if (
$code !==
'en' && file_exists(
"{$dir}/{$code}.php")) {
129 $english_matches = preg_match_all(
'/%[a-zA-Z]/m',
$value);
130 if (!array_key_exists(
$key, $translation) || $english_matches ===
false) {
134 $translation_matches = preg_match_all(
'/%[a-zA-Z]/m', $translation[
$key]);
135 if ($translation_matches !==
false && $english_matches === $translation_matches) {
139 $file_contents = file_get_contents(
"{$directory}/{$language_code}.php");
141 $pattern =
'/^\s*[\'"]' . $key .
'[\'"] => [\'"]' . preg_quote($translation[$key],
'/') .
'[\'"],{0,1}\R/m';
146 $pattern =
'/^\s*[\'"]' . $key .
'[\'"] => [\'"]' . preg_quote(addslashes($translation[$key]),
'/') .
'[\'"],{0,1}\R/m';
152 file_put_contents(
"{$directory}/{$language_code}.php",
$file_contents);
154 $this->
log[] =
"Unable to repair mismatch in translation argument count in {$directory}/{$language_code}.php for the key '{$key}'";
167 $contents = file_get_contents($translation_file);
172 $pattern =
'/^\s*[\'"].*[\'"] => [\'"]{2},{0,1}\R/m';
178 file_put_contents($translation_file,
$contents);
180 $this->
log[] =
"Cleaned empty translations from {$translation_file}";
192 $code = strtolower($code);
193 $code = preg_replace(
'~[^a-z0-9]~',
'_', $code);
static includeFile($file)
Include a file with as little context as possible.
Removes invalid language files from an installation.
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition plus the scripts used to control compilation and installation of the executable as a special the source code distributed need not include anything that is normally and so on of the operating system on which the executable unless that component itself accompanies the executable If distribution of executable or object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place counts as distribution of the source even though third parties are not compelled to copy the source along with the object code You may not or distribute the Program except as expressly provided under this License Any attempt otherwise to sublicense or distribute the Program is void
cleanupMissingTranslationParameters(string $directory, string $language_code)
Try to cleanup translations with a different argument count than English as this can cause failed tra...
cleanupEmptyTranslations(string $translation_file)
Remove empty translations from a translation file.
cleanLanguagesDir(string $dir)
Clean up a languages dir.
normalizeLanguageCode(string $code)
Normalize a language code (e.g.
__construct(array $codes=[])
Constructor.
if($container instanceof ElggGroup &&$container->guid!=elgg_get_page_owner_guid()) $key
log($level, $message, array $context=[])
Log a message.
cleanInstallation(string $dir)
Clean up within an installation.
if(!$plugin) $file_contents
static sanitize($path, $append_slash=true)
Sanitize file paths ensuring that they begin and end with slashes etc.
_elgg_services()
Get the global service provider.
if(!empty($title)&&!empty($icon_name)) if(!empty($title)) if(!empty($menu)) if(!empty($header)) if(!empty($body)) $contents