PHP Class 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.
Afficher le fichier Open project: raulferras/PHP-po-parser Class Usage Examples

Protected Properties

Свойство Type Description
$entries
$headers
$options
$sourceHandle

Méthodes publiques

Méthode Description
__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

Méthodes protégées

Méthode Description
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

Method Details

__construct() public méthode

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

clean() protected méthode

Undos cleanExport actions on a string.
protected clean ( string | array $x ) : string | array.
$x string | array
Résultat string | array.

cleanExport() protected méthode

Prepares a string to be outputed into a file.
protected cleanExport ( string $string ) : string
$string string The string to be converted.
Résultat string

compile() public méthode

Compiles entries into a string
public compile ( ) : string
Résultat string

entries() public méthode

Gets entries.
public entries ( )

getEntries() public méthode

public getEntries ( )

getEntryId() protected méthode

Generates the internal key for a msgid.
protected getEntryId ( array $entry ) : string
$entry array
Résultat string

getHeaders() public méthode

Get headers from .po file
public getHeaders ( ) : array
Résultat array

getOptions() public méthode

public getOptions ( )

isHeader() protected static méthode

Checks if entry is a header by
protected static isHeader ( array $entry ) : boolean
$entry array
Résultat boolean

parse() public méthode

Reads and parses strings of a .po file.
public parse ( sepia\InterfaceHandler $handle = null ) : array.
$handle sepia\InterfaceHandler
Résultat array.

parseFile() public static méthode

Reads and parses a file
public static parseFile ( string $filepath, array $options = [] ) : array.
$filepath string
$options array
Résultat array.

parseString() public static méthode

Reads and parses a string
public static parseString ( $string, array $options = [] ) : array.
$options array
Résultat array.

setEntry() public méthode

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 méthode

public setEntryContext ( $msgid, $context = false )

setEntryPlural() public méthode

public setEntryPlural ( $msgid, $plural = false )

setHeaders() public méthode

{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
Résultat boolean

writeFile() public méthode

Writes entries to a po file
public writeFile ( string $filepath ) : boolean
$filepath string
Résultat boolean

Property Details

$entries protected_oe property

protected $entries

$headers protected_oe property

protected $headers

$options protected_oe property

protected $options

$sourceHandle protected_oe property

protected $sourceHandle