function checkExtractedString($text) { $text = solidifySource($text); if (!preg_match('/[a-z]{2}/i', $text)) { //ignore any string that does not have at least two consectuive alphabetical characters in it return ''; } if (preg_match('/^\\s*(mailto:)?[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}\\s*$/i', $text)) { I2CE::raiseError("Ignoring email: {$text}"); //ignore email address return ''; } if (is_numeric($text)) { I2CE::raiseError("Ignoring numeric: {$text}"); return ''; } if (preg_match('/^[a-z]{2,4}:\\/\\/([a-z0-9\\-_\\.]+@)?[a-z0-9\\-_]+(\\.[a-z0-9\\-_])*(\\/[~\'!\\(\\)a-z0-9\\-_%&\\?\\.=]*)?/i', $text)) { I2CE::raiseError("Ignoring URL: {$text}"); return ''; } if (preg_match('/^www(\\.[a-z0-9\\-_]+)+$/', $text)) { I2CE::raiseError("Ignoring web address bt www prefix: {$text}"); return ''; } $tld = 'com|org|net|mil|ac|edu|de|uk|ru|biz|gov|us|asia|aero|nl|fr|ch|info|jobs|tel|name|in|jp|ca|br'; if (preg_match('/^([a-z0-9\\-_]+\\.)+(' . $tld . ')$/', $text)) { I2CE::raiseError("Ignoring web address by TLD: {$text}"); return ''; } return preg_replace('/\\s\\s+/', ' ', $text); }
unset($translations_array[$module]); continue; } } $t_translations_array = array(); foreach ($translations_array as $mod => $trans) { $t_trans = $trans; foreach ($trans as $msg_id => $tran) { if ($msg_id == '') { continue; } $t_msg_id = solidifySource($msg_id); if (array_key_exists($t_msg_id, $trans)) { continue; } $t_trans[$t_msg_id] = solidifySource($tran); } $t_translations_array[$mod] = $t_trans; } $translations_array = $t_translations_array; foreach ($found_modules as $module => $top_module) { if (!array_key_exists($module, $translations_array) || !is_array($translations_array[$module])) { continue; } if (!array_key_exists($module, $configs)) { continue; } $translations = $translations_array[$module]; $file = null; if (!$storage->setIfIsSet($file, "/config/data/{$module}/file")) { I2CE::raiseError("No config file for {$module} -- Skipping");
if (!file_put_contents($pot_file, $pot_contents)) { I2CE::raiseError("Could not write:" . $pot_file, E_USER_ERROR); } I2CE::raiseError("Wrote:" . $pot_file); foreach ($locales as $locale) { $po_file = $template_dir . DIRECTORY_SEPARATOR . $launchpad_name . DIRECTORY_SEPARATOR . $locale . '.po'; if (!is_readable($po_file)) { //I2CE::raiseError($po_file . " is not readable for $module"); continue; } $existing_translations = loadPOT($po_file); if (!is_array($existing_translations) || count($existing_translations) == 0) { continue; } $converted_translations = array(); foreach ($existing_translations as $msg_id => $data) { if ($msg_id != '') { $data['msgstr'] = solidifySource($data['msgstr']); } $converted_translations[solidifySource($msg_id)] = $data; } $po_contents = createPOT($top_module, $module, $vers, $converted_translations, true); if (!is_string($po_contents)) { continue; } if (!file_put_contents($po_file, $po_contents)) { I2CE::raiseError("Could not write:" . $po_file, E_USER_ERROR); } I2CE::raiseError("Wrote:" . $po_file); } }