diff --git a/system/Commands/Translation/LocalizationSync.php b/system/Commands/Translation/LocalizationSync.php index 38dc8c424bf6..d8342fa64bc8 100644 --- a/system/Commands/Translation/LocalizationSync.php +++ b/system/Commands/Translation/LocalizationSync.php @@ -15,7 +15,6 @@ use CodeIgniter\CLI\BaseCommand; use CodeIgniter\CLI\CLI; -use CodeIgniter\Helpers\Array\ArrayHelper; use Config\App; use Locale; use RecursiveDirectoryIterator; @@ -134,7 +133,6 @@ private function process(string $originalLocale, string $targetLocale): void } $targetLanguageKeys = $this->mergeLanguageKeys($originalLanguageKeys, $targetLanguageKeys, $originalLanguageFile->getBasename('.php')); - // ksort($targetLanguageKeys); $content = " $value) { $placeholderValue = $prefix !== '' ? $prefix . '.' . $key : $key; @@ -156,21 +156,25 @@ private function mergeLanguageKeys(array $originalLanguageKeys, array $targetLan // Keep the old value // TODO: The value type may not match the original one if (array_key_exists($key, $targetLanguageKeys)) { + $mergedLanguageKeys[$key] = $targetLanguageKeys[$key]; + continue; } // Set new key with placeholder - $targetLanguageKeys[$key] = $placeholderValue; + $mergedLanguageKeys[$key] = $placeholderValue; } else { if (! array_key_exists($key, $targetLanguageKeys)) { - $targetLanguageKeys[$key] = []; + $mergedLanguageKeys[$key] = $this->mergeLanguageKeys($value, [], $placeholderValue); + + continue; } - $targetLanguageKeys[$key] = $this->mergeLanguageKeys($value, $targetLanguageKeys[$key], $placeholderValue); + $mergedLanguageKeys[$key] = $this->mergeLanguageKeys($value, $targetLanguageKeys[$key], $placeholderValue); } } - return ArrayHelper::intersectKeyRecursive($targetLanguageKeys, $originalLanguageKeys); + return $mergedLanguageKeys; } private function isIgnoredFile(SplFileInfo $file): bool