* @return bool true on success, false if the entry doesn't have a key
*/
function add_entry($entry) {
* @return bool true on success, false if the entry doesn't have a key
*/
function add_entry($entry) {
foreach($headers as $header => $value) {
$this->set_header($header, $value);
}
}
foreach($headers as $header => $value) {
$this->set_header($header, $value);
}
}
function get_header($header) {
return isset($this->headers[$header])? $this->headers[$header] : false;
}
function get_header($header) {
return isset($this->headers[$header])? $this->headers[$header] : false;
}
function translate_entry(&$entry) {
$key = $entry->key();
return isset($this->entries[$key])? $this->entries[$key] : false;
}
function translate_entry(&$entry) {
$key = $entry->key();
return isset($this->entries[$key])? $this->entries[$key] : false;
}
function translate($singular, $context=null) {
$entry = new Translation_Entry(array('singular' => $singular, 'context' => $context));
$translated = $this->translate_entry($entry);
function translate($singular, $context=null) {
$entry = new Translation_Entry(array('singular' => $singular, 'context' => $context));
$translated = $this->translate_entry($entry);
* Here, in the base Translations class, the common logic for English is implemented:
* 0 if there is one element, 1 otherwise
*
* Here, in the base Translations class, the common logic for English is implemented:
* 0 if there is one element, 1 otherwise
*
function translate_plural($singular, $plural, $count, $context = null) {
$entry = new Translation_Entry(array('singular' => $singular, 'plural' => $plural, 'context' => $context));
$translated = $this->translate_entry($entry);
function translate_plural($singular, $plural, $count, $context = null) {
$entry = new Translation_Entry(array('singular' => $singular, 'plural' => $plural, 'context' => $context));
$translated = $this->translate_entry($entry);
function merge_originals_with(&$other) {
foreach( $other->entries as $entry ) {
if ( !isset( $this->entries[$entry->key()] ) )
function merge_originals_with(&$other) {
foreach( $other->entries as $entry ) {
if ( !isset( $this->entries[$entry->key()] ) )
* It lives in this class, because there are more than one descendand, which will use it and
* they can't share it effectively.
*
* It lives in this class, because there are more than one descendand, which will use it and
* they can't share it effectively.
*
*/
function gettext_select_plural_form($count) {
if (!isset($this->_gettext_select_plural_form) || is_null($this->_gettext_select_plural_form)) {
*/
function gettext_select_plural_form($count) {
if (!isset($this->_gettext_select_plural_form) || is_null($this->_gettext_select_plural_form)) {
function nplurals_and_expression_from_header($header) {
if (preg_match('/^\s*nplurals\s*=\s*(\d+)\s*;\s+plural\s*=\s*(.+)$/', $header, $matches)) {
$nplurals = (int)$matches[1];
function nplurals_and_expression_from_header($header) {
if (preg_match('/^\s*nplurals\s*=\s*(\d+)\s*;\s+plural\s*=\s*(.+)$/', $header, $matches)) {
$nplurals = (int)$matches[1];
*/
function make_plural_form_function($nplurals, $expression) {
$expression = str_replace('n', '$n', $expression);
*/
function make_plural_form_function($nplurals, $expression) {
$expression = str_replace('n', '$n', $expression);
* plural expressions, because PHP evaluates ternary oerators from left to right
*
* @param string $expression the expression without parentheses
* plural expressions, because PHP evaluates ternary oerators from left to right
*
* @param string $expression the expression without parentheses
function set_header($header, $value) {
parent::set_header($header, $value);
if ('Plural-Forms' == $header) {
function set_header($header, $value) {
parent::set_header($header, $value);
if ('Plural-Forms' == $header) {
function translate_plural($singular, $plural, $count, $context = null) {
return 1 == $count? $singular : $plural;
}
function translate_plural($singular, $plural, $count, $context = null) {
return 1 == $count? $singular : $plural;
}