Sync POMO with GlotPress
See http://glotpress.trac.wordpress.org/browser/trunk/pomo/ git-svn-id: http://core.svn.wordpress.org/trunk@22349 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
62771d6824
commit
dcc0729a6c
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* Contains Translation_Entry class
|
||||
*
|
||||
* @version $Id: entry.php 621 2011-06-13 12:21:50Z nbachiyski $
|
||||
* @version $Id: entry.php 718 2012-10-31 00:32:02Z nbachiyski $
|
||||
* @package pomo
|
||||
* @subpackage entry
|
||||
*/
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* Class for working with MO files
|
||||
*
|
||||
* @version $Id: mo.php 602 2011-01-30 12:43:29Z nbachiyski $
|
||||
* @version $Id: mo.php 718 2012-10-31 00:32:02Z nbachiyski $
|
||||
* @package pomo
|
||||
* @subpackage mo
|
||||
*/
|
||||
|
@ -43,8 +43,20 @@ class MO extends Gettext_Translations {
|
|||
return stream_get_contents( $tmp_fh );
|
||||
}
|
||||
|
||||
function is_entry_good_for_export( $entry ) {
|
||||
if ( empty( $entry->translations ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( !array_filter( $entry->translations ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function export_to_file_handle($fh) {
|
||||
$entries = array_filter($this->entries, create_function('$e', 'return !empty($e->translations);'));
|
||||
$entries = array_filter( $this->entries, array( $this, 'is_entry_good_for_export' ) );
|
||||
ksort($entries);
|
||||
$magic = 0x950412de;
|
||||
$revision = 0;
|
||||
|
@ -195,8 +207,7 @@ class MO extends Gettext_Translations {
|
|||
$translation = $reader->substr( $strings, $t['pos'], $t['length'] );
|
||||
|
||||
if ('' === $original) {
|
||||
$headers = $this->make_headers($translation);
|
||||
$this->set_headers($headers);
|
||||
$this->set_headers($this->make_headers($translation));
|
||||
} else {
|
||||
$entry = &$this->make_entry($original, $translation);
|
||||
$this->entries[$entry->key()] = &$entry;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* Class for working with PO files
|
||||
*
|
||||
* @version $Id: po.php 589 2010-12-18 01:40:57Z nbachiyski $
|
||||
* @version $Id: po.php 718 2012-10-31 00:32:02Z nbachiyski $
|
||||
* @package pomo
|
||||
* @subpackage po
|
||||
*/
|
||||
|
@ -229,7 +229,13 @@ class PO extends Gettext_Translations {
|
|||
}
|
||||
}
|
||||
PO::read_line($f, 'clear');
|
||||
return $res !== false;
|
||||
if ( false === $res ) {
|
||||
return false;
|
||||
}
|
||||
if ( ! $this->headers && ! $this->entries ) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function read_entry($f, $lineno = 0) {
|
||||
|
@ -349,6 +355,7 @@ class PO extends Gettext_Translations {
|
|||
return true;
|
||||
}
|
||||
$line = $use_last_line? $last_line : fgets($f);
|
||||
$line = gp_endswith( $line, "\r\n" )? rtrim( $line, "\r\n" ) . "\n" : $line;
|
||||
$last_line = $line;
|
||||
$use_last_line = false;
|
||||
return $line;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Classes, which help reading streams of data from files.
|
||||
* Based on the classes from Danilo Segan <danilo@kvota.net>
|
||||
*
|
||||
* @version $Id: streams.php 597 2011-01-16 20:14:36Z nbachiyski $
|
||||
* @version $Id: streams.php 718 2012-10-31 00:32:02Z nbachiyski $
|
||||
* @package pomo
|
||||
* @subpackage streams
|
||||
*/
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* Class for a set of entries for translation and their associated headers
|
||||
*
|
||||
* @version $Id: translations.php 590 2010-12-20 19:58:37Z nbachiyski $
|
||||
* @version $Id: translations.php 718 2012-10-31 00:32:02Z nbachiyski $
|
||||
* @package pomo
|
||||
* @subpackage translations
|
||||
*/
|
||||
|
@ -81,7 +81,7 @@ class Translations {
|
|||
/**
|
||||
* Given the number of items, returns the 0-based index of the plural form to use
|
||||
*
|
||||
* Here, in the base Translations class, the common logic for English is implemented:
|
||||
* Here, in the base Translations class, the common logic for English is implmented:
|
||||
* 0 if there is one element, 1 otherwise
|
||||
*
|
||||
* This function should be overrided by the sub-classes. For example MO/PO can derive the logic
|
||||
|
|
Loading…
Reference in New Issue