/**
 * @param $filename Filename containing the extension i18n
 * @param $arrayname The name of the array in the filename
 * @param $filter Optional, restrict check to a given language code (default; null)
 */
function checkExtensionLanguage($filename, $arrayname, $filter = null)
{
    $extLanguages = new extensionLanguages($filename, $arrayname);
    $langs = $extLanguages->getLanguages();
    if (!$langs) {
        print "ERROR> \${$arrayname} array does not exist.\n";
        return false;
    }
    $nErrors = 0;
    if ($filter) {
        $nErrors += checkLanguage($extLanguages, $filter);
    } else {
        print "Will check " . count($langs) . " languages : " . implode(' ', $langs) . ".\n";
        foreach ($langs as $lang) {
            if ($lang == 'en') {
                #print "Skipped english language\n";
                continue;
            }
            $nErrors += checkLanguage($extLanguages, $lang);
        }
    }
    return $nErrors;
}
/**
 * @param $filename Filename containing the extension i18n
 * @param $arrayname The name of the array in the filename
 * @param $filter Optional, restrict check to a given language code (default; null)
 */
function checkExtensionLanguage($filename, $arrayname, $filter = null)
{
    global $wgGeneralMessages, $wgRequiredMessagesNumber;
    $extLanguages = new extensionLanguages($filename, $arrayname);
    // Stuff needed by the checkLanguage routine (globals)
    $wgGeneralMessages = $extLanguages->getGeneralMessages();
    $wgRequiredMessagesNumber = count($wgGeneralMessages['required']);
    $langs = $extLanguages->getLanguages();
    if (!$langs) {
        print "ERROR> \${$arrayname} array does not exist.\n";
        return false;
    }
    $nErrors = 0;
    if ($filter) {
        $nErrors += checkLanguage($extLanguages, $filter);
    } else {
        print "Will check " . count($langs) . " languages : " . implode(' ', $langs) . ".\n";
        foreach ($langs as $lang) {
            if ($lang == 'en') {
                #print "Skipped english language\n";
                continue;
            }
            $nErrors += checkLanguage($extLanguages, $lang);
        }
    }
    return $nErrors;
}