PHP Класс Sepia\PoParser

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. https://github.com/raulferras/PHP-po-parser Class to parse .po file and extract its strings.
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$entries
$headers
$options
$sourceHandle

Открытые методы

Метод Описание
__construct ( sepia\InterfaceHandler $handler = null, $options = [] )
compile ( ) : string Compiles entries into a string
entries ( ) Gets entries.
getEntries ( )
getHeaders ( ) : array Get headers from .po file
getOptions ( )
parse ( sepia\InterfaceHandler $handle = null ) : array. Reads and parses strings of a .po file.
parseFile ( string $filepath, array $options = [] ) : array. Reads and parses a file
parseString ( $string, array $options = [] ) : array. Reads and parses a string
setEntry ( String $msgid, Array $entry, boolean $createNew = true ) Updates an entry.
setEntryContext ( $msgid, $context = false )
setEntryPlural ( $msgid, $plural = false )
setHeaders ( array $newHeaders ) : boolean Set new headers
writeFile ( string $filepath ) : boolean Writes entries to a po file

Защищенные методы

Метод Описание
clean ( string | array $x ) : string | array. Undos cleanExport actions on a string.
cleanExport ( string $string ) : string Prepares a string to be outputed into a file.
getEntryId ( array $entry ) : string Generates the internal key for a msgid.
isHeader ( array $entry ) : boolean Checks if entry is a header by

Описание методов

__construct() публичный Метод

public __construct ( sepia\InterfaceHandler $handler = null, $options = [] )
$handler sepia\InterfaceHandler

clean() защищенный Метод

Undos cleanExport actions on a string.
protected clean ( string | array $x ) : string | array.
$x string | array
Результат string | array.

cleanExport() защищенный Метод

Prepares a string to be outputed into a file.
protected cleanExport ( string $string ) : string
$string string The string to be converted.
Результат string

compile() публичный Метод

Compiles entries into a string
public compile ( ) : string
Результат string

entries() публичный Метод

Gets entries.
public entries ( )

getEntries() публичный Метод

public getEntries ( )

getEntryId() защищенный Метод

Generates the internal key for a msgid.
protected getEntryId ( array $entry ) : string
$entry array
Результат string

getHeaders() публичный Метод

Get headers from .po file
public getHeaders ( ) : array
Результат array

getOptions() публичный Метод

public getOptions ( )

isHeader() защищенный статический Метод

Checks if entry is a header by
protected static isHeader ( array $entry ) : boolean
$entry array
Результат boolean

parse() публичный Метод

Reads and parses strings of a .po file.
public parse ( sepia\InterfaceHandler $handle = null ) : array.
$handle sepia\InterfaceHandler
Результат array.

parseFile() публичный статический Метод

Reads and parses a file
public static parseFile ( string $filepath, array $options = [] ) : array.
$filepath string
$options array
Результат array.

parseString() публичный статический Метод

Reads and parses a string
public static parseString ( $string, array $options = [] ) : array.
$options array
Результат array.

setEntry() публичный Метод

If entry not found returns false. If $createNew is true, a new entry will be created. $entry is an array that can contain following indexes: - msgid: String Array. Required. - msgstr: String Array. Required. - reference: String Array. - msgctxt: String. Disambiguating context. - tcomment: String Array. Translator comments. - ccomment: String Array. Source comments. - msgid_plural: String Array. - flags: Array. List of entry flags. Example: array('fuzzy','php-format') - previous: Array: Contains previous untranslated strings in a sub array with msgid and msgstr.
public setEntry ( String $msgid, Array $entry, boolean $createNew = true )
$msgid String Id of entry. Be aware that some entries have a multiline msgid. In that case \n must be replaced by the value of 'multiline-glue' option (by default "<##EOL##>").
$entry Array Array with all entry data. Fields not setted will be removed.
$createNew boolean If msgid not found, it will create a new entry. By default true. You want to set this to false if need to change the msgid of an entry.

setEntryContext() публичный Метод

public setEntryContext ( $msgid, $context = false )

setEntryPlural() публичный Метод

public setEntryPlural ( $msgid, $plural = false )

setHeaders() публичный Метод

{code} array( '"Project-Id-Version: \n"', '"Report-Msgid-Bugs-To: \n"', '"POT-Creation-Date: \n"', '"PO-Revision-Date: \n"', '"Last-Translator: none\n"', '"Language-Team: \n"', '"MIME-Version: 1.0\n"', '"Content-Type: text/plain; charset=UTF-8\n"', ); {code}
public setHeaders ( array $newHeaders ) : boolean
$newHeaders array
Результат boolean

writeFile() публичный Метод

Writes entries to a po file
public writeFile ( string $filepath ) : boolean
$filepath string
Результат boolean

Описание свойств

$entries защищенное свойство

protected $entries

$headers защищенное свойство

protected $headers

$options защищенное свойство

protected $options

$sourceHandle защищенное свойство

protected $sourceHandle