示例#1
0
    $path = WP_CONTENT_DIR . '/' . $path;
}
// but package must exist so we can get POT or source
/* @var $package LocoPackage */
loco_require('loco-packages', 'loco-locales');
$package = LocoPackage::get($name, $type);
if (!$package) {
    throw new Exception(sprintf(Loco::__('Package not found called %s'), $name), 404);
}
while (true) {
    // If file we're syncing is POT, we can only sync from sources
    if (!LocoAdmin::is_pot($path)) {
        // if a POT file exists, sync from that
        $domain = LocoAdmin::resolve_file_domain($path) or $domain = $package->get_domain();
        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 = '';