Loco Translate - Version 2.0.6

Version Description

  • PO wrapping bugfix
  • Downgraded source code bugfix
  • Tolerating headerless POT files
  • Core bundle metadata tweaks
Download this release

Release Info

Developer timwhitlock
Plugin Icon 128x128 Loco Translate
Version 2.0.6
Comparing to
See all releases

Code changes from version 2.0.5 to 2.0.6

lib/compiled/gettext.php CHANGED
@@ -8,19 +8,19 @@
8
  ', $entry['#'][':'])) { if ($refs = loco_parse_reference_id($refs, $_id)) { $asset['refs'] = $refs; } if ($_id) { $asset['_id'] = $_id; } } } if (isset($entry['#'][','])) { foreach ($entry['#'][','] as $flag) { if (preg_match('/((?:no-)?\\w+)-format/', $flag, $r)) { $parse_printf = false; if ('no-' === substr($r[1], 0, 3)) { $asset['format'] = false; } else { $asset['format'] = $r[1]; } } else { if ($flag = loco_po_parse_flag($flag)) { $asset['flag'] = $flag; break; } } } } if ($parse_printf) { if ($asset['source'] && loco_sniff_printf($asset['source'])) { $asset['format'] = 'c'; $parse_printf = false; } } $pidx = count($assets); $assets[] = $asset; if (isset($entry['id_plural']) || isset($entry['str'][1])) { $idx = 0; $num = max(2, count($entry['str'])); while (++$idx < $num) { $plural = array('id' => null, 'source' => '', 'target' => isset($entry['str'][$idx]) ? implode('', $entry['str'][$idx]) : '', 'plural' => $idx, 'parent' => $pidx); if (1 === $idx) { $plural['source'] = isset($entry['id_plural'][0]) ? implode('', $entry['id_plural'][0]) : ''; } if ($parse_printf) { if ($plural['source'] && loco_sniff_printf($plural['source'])) { $assets[$pidx]['format'] = 'c'; $parse_printf = false; } } $assets[] = $plural; } } } if (isset($assets[0]) && '' === $assets[0]['source']) { $headers = loco_parse_po_headers($assets[0]['target']); $indexed = $headers['X-Loco-Lookup']; if ($indexed && 'text' !== $indexed) { foreach ($assets as $i => $asset) { if (isset($asset['notes'])) { $notes = $texts = array(); foreach (explode('
9
  ', $asset['notes']) as $line) { 0 === strpos($line, 'Source text: ') ? $texts[] = substr($line, 13) : ($notes[] = $line); } $assets[$i]['notes'] = implode('
10
  ', $notes); $assets[$i]['id'] = $asset['source']; $assets[$i]['source'] = implode('
11
- ', $texts); } } } } return $assets; } function loco_po_parse_flag($text) { static $map; $flag = 0; foreach (explode(',', $text) as $needle) { if ($needle = trim($needle)) { if (!isset($map)) { $map = unserialize('a:1:{i:4;s:8:"#, fuzzy";}'); } foreach ($map as $loco_flag => $haystack) { if (false !== stripos($haystack, $needle)) { $flag = $loco_flag; break 2; } } } } return $flag; } function loco_parse_po_headers($str) { return LocoPoHeaders::fromMsgstr($str); } class LocoMoParser { private $bin; private $be; private $n; private $o; private $t; private $v; private $cs; public function __construct($bin) { $this->bin = $bin; } public function getAt($idx) { $offset = $this->targetOffset(); $offset += $idx * 8; $len = $this->integerAt($offset); $idx = $this->integerAt($offset + 4); $txt = $this->bytes($idx, $len); if (false === strpos($txt, '