Translation_Entry example


        public function Dmake_entry( $original$translation ) {
            $entry = new Translation_Entry();
            // Look for context, separated by \4.             $parts = explode( "\4", $original );
            if ( isset( $parts[1] ) ) {
                $original       = $parts[1];
                $entry->context = $parts[0];
            }
            // Look for plural original.             $parts           = explode( "\0", $original );
            $entry->singular = $parts[0];
            if ( isset( $parts[1] ) ) {
                $entry->is_plural = true;
                

        protected static function is_final( $context ) {
            return ( 'msgstr' === $context ) || ( 'msgstr_plural' === $context );
        }

        /** * @param resource $f * @param int $lineno * @return null|false|array */
        public function read_entry( $f$lineno = 0 ) {
            $entry = new Translation_Entry();
            // Where were we in the last step.             // Can be: comment, msgctxt, msgid, msgid_plural, msgstr, msgstr_plural.             $context      = '';
            $msgstr_index = 0;
            while ( true ) {
                $lineno++;
                $line = PO::read_line( $f );
                if ( ! $line ) {
                    if ( feof( $f ) ) {
                        if ( self::is_final( $context ) ) {
                            break;
                        }
public $entries = array();
        public $headers = array();

        /** * Add entry to the PO structure * * @param array|Translation_Entry $entry * @return bool true on success, false if the entry doesn't have a key */
        public function add_entry( $entry ) {
            if ( is_array( $entry ) ) {
                $entry = new Translation_Entry( $entry );
            }
            $key = $entry->key();
            if ( false === $key ) {
                return false;
            }
            $this->entries[ $key ] = &$entry;
            return true;
        }

        /** * @param array|Translation_Entry $entry * @return bool */
Home | Imprint | This part of the site doesn't use cookies.