+
+ function make_headers($translation) {
+ $headers = array();
+ // sometimes \ns are used instead of real new lines
+ $translation = str_replace('\n', "\n", $translation);
+ $lines = explode("\n", $translation);
+ foreach($lines as $line) {
+ $parts = explode(':', $line, 2);
+ if (!isset($parts[1])) continue;
+ $headers[trim($parts[0])] = trim($parts[1]);
+ }
+ return $headers;
+ }
+
+ function set_header($header, $value) {
+ parent::set_header($header, $value);
+ if ('Plural-Forms' == $header) {
+ list( $nplurals, $expression ) = $this->nplurals_and_expression_from_header($this->get_header('Plural-Forms'));
+ $this->_nplurals = $nplurals;
+ $this->_gettext_select_plural_form = $this->make_plural_form_function($nplurals, $expression);
+ }
+ }
+}
+endif;
+
+if ( !class_exists( 'NOOP_Translations' ) ):
+/**
+ * Provides the same interface as Translations, but doesn't do anything
+ */
+class NOOP_Translations {
+ var $entries = array();
+ var $headers = array();
+
+ function add_entry($entry) {
+ return true;
+ }
+
+ function set_header($header, $value) {
+ }
+
+ function set_headers(&$headers) {
+ }
+
+ function get_header($header) {
+ return false;
+ }
+
+ function translate_entry(&$entry) {
+ return false;
+ }
+
+ function translate($singular, $context=null) {
+ return $singular;
+ }
+
+ function select_plural_form($count) {
+ return 1 == $count? 0 : 1;
+ }
+
+ function get_plural_forms_count() {
+ return 2;
+ }
+
+ function translate_plural($singular, $plural, $count, $context = null) {
+ return 1 == $count? $singular : $plural;
+ }