36 $this->codes = $codes;
49 if (is_dir(
"{$dir}/install/languages")) {
53 if (is_dir(
"{$dir}/languages")) {
57 $mods = new \DirectoryIterator(
"{$dir}/mod");
59 foreach ($mods as $mod) {
60 if ($mod->isDot() || !$mod->isDir()) {
69 if (is_dir(
"{$mod->getPathname()}/languages")) {
86 $files = new \DirectoryIterator($dir);
87 foreach ($files as $file) {
88 if ($file->isDot() || !$file->isFile()) {
92 if ($file->getExtension() !==
'php') {
96 $code = $file->getBasename(
'.php');
97 if (!in_array(
$code, $this->codes)) {
100 if (in_array(
$code, $this->codes)) {
102 rename($file->getPathname(),
"{$dir}/{$code}.php");
103 $this->
log[] =
"Renamed {$file->getPathname()} to {$code}.php";
105 unlink($file->getPathname());
106 $this->
log[] =
"Removed {$file->getPathname()}";
110 if (
$code !==
'en' && file_exists(
"{$dir}/{$code}.php")) {
132 $english_matches = preg_match_all(
'/%[a-zA-Z]/m',
$value);
133 if (!array_key_exists(
$key, $translation) || $english_matches ===
false) {
137 $translation_matches = preg_match_all(
'/%[a-zA-Z]/m', $translation[
$key]);
138 if ($translation_matches !==
false && $english_matches === $translation_matches) {
142 $file_contents = file_get_contents(
"{$directory}/{$language_code}.php");
144 $pattern =
'/^\s*[\'"]' . $key .
'[\'"] => [\'"]' . preg_quote($translation[$key],
'/') .
'[\'"],{0,1}\R/m';
149 $pattern =
'/^\s*[\'"]' . $key .
'[\'"] => [\'"]' . preg_quote(addslashes($translation[$key]),
'/') .
'[\'"],{0,1}\R/m';
155 file_put_contents(
"{$directory}/{$language_code}.php",
$file_contents);
157 $this->
log[] =
"Unable to repair mismatch in translation argument count in {$directory}/{$language_code}.php for the key '{$key}'";
170 $contents = file_get_contents($translation_file);
175 $pattern =
'/^\s*[\'"].*[\'"] => [\'"]{2},{0,1}\R/m';
181 file_put_contents($translation_file,
$contents);
185 $this->
log[] =
"Cleaned empty translations from {$translation_file}";
187 unlink($translation_file);
189 $this->
log[] =
"Removed empty translation file {$translation_file}";
202 $code = strtolower($code);
203 return preg_replace(
'~[^a-z0-9]~',
'_', $code);
219 if (array_key_exists(
$key, $english)) {
223 $this->
log[] =
"The translation key '{$key}' exists in the '{$language_code}' translation but not in English";
240 if (!array_key_exists(
$key, $english)) {
254 $this->
log[] =
"The translation key '{$key}' in the '{$language_code}' translation is identical to the English translation";
static includeFile($file)
Include a file with as little context as possible.
Removes invalid language files from an installation.
foreach(array_keys($combine_languages) as $language) $translations
detectAdditionalKeys(string $directory, string $language_code)
Detect translation keys that (still) exist in a translation but no longer in the English translation...
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.
detectIdenticalTranslations(string $directory, string $language_code)
Detect identical translations, this could be due to a wrong Transifex import.
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(!$plugin instanceof\ElggPlugin) $file_contents
if(!empty($title)&&!empty($icon_name)) if(!empty($title)) if(!empty($menu)) if(!empty($header)) if(!empty($body)) $contents