Esempio n. 1
0
        if ($pot_path = $package->get_pot($domain)) {
            $exp = LocoAdmin::parse_po($pot_path);
            if (!$exp || 1 === count($exp) && '' === $exp[0]['source']) {
                // throw new Exception( Loco::__('POT file is empty').' - '.basename($pot_path) );
                // fall through to try source code
            } else {
                $pot = basename($pot_path);
                break;
            }
        }
    }
    // Extract from sources by default
    if (!$package->has_source_dirs()) {
        throw new Exception(Loco::__('No source directories in this package, cannot sync from source code'));
    }
    if ($exp = LocoAdmin::xgettext($package, dirname($path))) {
        $pot = '';
        break;
    }
    throw new Exception(Loco::__('No strings could be extracted from source files'));
}
// sync selected headers
$headers = array();
if ('' === $exp[0]['source']) {
    $keep = array('Project-Id-Version', 'Language-Team', 'POT-Creation-Date', 'POT-Revision-Date');
    $head = loco_parse_po_headers($exp[0]['target']);
    $headers = array_intersect_key($head->to_array(), array_flip($keep));
    /*/ add prefixed header keys that can't be included above
      foreach( $head as $key => $value ){
          if( 0 === strpos($key, 'X-Poedit-' ) ){
              $headers[$key] = $value;
Esempio n. 2
0
            $exp = LocoAdmin::parse_po($pot_path);
            if (!$exp || 1 === count($exp) && '' === $exp[0]['source']) {
                //throw new Exception( Loco::__('POT file is empty') );
                continue;
            }
            $pot = basename($pot_path);
            break;
        }
    }
    // Extract from sources by default
    if (!$package->get_source_dirs()) {
        throw new Exception(Loco::__('No source files in this package, nothing to sync'));
    }
    $relative_to = dirname($path);
    //$relative_to = $pot_path ? dirname($pot_path) : $package->get_root();
    if ($exp = LocoAdmin::xgettext($package, $relative_to)) {
        $pot = '';
        break;
    }
    throw new Exception(Loco::__('No strings could be extracted from source files'));
}
// sync selected headers
$headers = array();
if ('' === $exp[0]['source']) {
    $keep = array('Project-Id-Version', 'Language-Team', 'POT-Creation-Date', 'POT-Revision-Date');
    $head = loco_parse_po_headers($exp[0]['target']);
    $headers = array_intersect_key($head->to_array(), array_flip($keep));
    /*/ add prefixed header keys that can't be included above
      foreach( $head as $key => $value ){
          if( 0 === strpos($key, 'X-Poedit-' ) ){
              $headers[$key] = $value;