Example #1
0
 /**
  * construct a core package object from name
  * @return LocoPackage
  */
 private static function get_core($handle)
 {
     static $grouped;
     if (!isset($grouped)) {
         $grouped = array();
         foreach (LocoAdmin::find_grouped(WP_LANG_DIR, '/\\.pot?$/') as $ext => $files) {
             foreach ($files as $path) {
                 $domain = LocoAdmin::resolve_file_domain($path);
                 $grouped[$domain][$ext][] = $path;
             }
         }
     }
     $domain = $handle or $domain = 'default';
     $package = new LocoCorePackage($handle, $domain, '');
     if (isset($grouped[$handle])) {
         // add PO file and POT files for this component
         $package->add_po($grouped[$handle], $domain);
         // get name from po file
         $meta = $package->meta();
         foreach ($meta['po'] as $pmeta) {
             if ($pmeta['projid']) {
                 $package->name = $pmeta['projid'];
             }
         }
         // disable source directories as Core packages cannot be synced
         $package->src = array();
     }
     return $package;
 }
 /**
  * construct a core package object from name
  * @return LocoPackage
  */
 private static function get_core($handle)
 {
     static $grouped;
     if (!isset($grouped)) {
         $grouped = array();
         foreach (LocoAdmin::find_grouped(WP_LANG_DIR . '/*{.po,.pot}', GLOB_NOSORT | GLOB_BRACE) as $ext => $files) {
             foreach ($files as $path) {
                 $domain = LocoAdmin::resolve_file_domain($path);
                 $grouped[$domain][$ext][] = $path;
             }
         }
     }
     $domain = $handle or $domain = 'default';
     $package = new LocoCorePackage($handle, $domain, '');
     if (isset($grouped[$handle])) {
         $package->add_po($grouped[$handle], $domain);
         // get name from po file
         $meta = $package->meta();
         foreach ($meta['po'] as $pmeta) {
             if ($pmeta['projid']) {
                 $package->name = $pmeta['projid'];
             }
         }
     }
     return $package;
 }