/** * @param $hugearray array * @param $g * @param $ignore bool */ protected function checkAndAdd(&$hugearray, $g, $ignore = false) { if ($g instanceof MessageGroupBase) { $cache = new MessageGroupCache($g); if ($cache->exists()) { $keys = $cache->getKeys(); } else { $keys = array_keys($g->getDefinitions()); } } else { $messages = $g->getDefinitions(); if (!is_array($messages)) { return; } $keys = array_keys($messages); } $id = $g->getId(); STDOUT("{$id} ", 'main'); $namespace = $g->getNamespace(); foreach ($keys as $key) { # Force all keys to lower case, because the case doesn't matter and it is # easier to do comparing when the case of first letter is unknown, because # mediawiki forces it to upper case $key = TranslateUtils::normaliseKey($namespace, $key); if (isset($hugearray[$key])) { if (!$ignore) { $to = implode(', ', (array) $hugearray[$key]); STDERR("Key {$key} already belongs to {$to}, conflict with {$id}"); } if (is_array($hugearray[$key])) { // Hard work is already done, just add a new reference $hugearray[$key][] =& $id; } else { // Store the actual reference, then remove it from array, to not // replace the references value, but to store a array of new // references instead. References are hard! $value =& $hugearray[$key]; unset($hugearray[$key]); $hugearray[$key] = array(&$value, &$id); } } else { $hugearray[$key] =& $id; } } unset($id); // Disconnect the previous references to this $id }