PHP code example of sepia / po-parser

1. Go to this page and download the library: Download sepia/po-parser library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sepia / po-parser example snippets


 
// Parse a po file
$fileHandler = new Sepia\PoParser\SourceHandler\FileSystem('es.po');

$poParser = new Sepia\PoParser\Parser($fileHandler);
$catalog  = $poParser->parse();

// Get an entry
$entry = $catalog->getEntry('welcome.user');

// Update entry
$entry = new Entry('welcome.user', 'Welcome User!');
$catalog->setEntry($entry);

// You can also modify other entry attributes as translator comments, code comments, flags...
$entry->setTranslatorComments(array('This is shown whenever a new user registers in the website'));
$entry->setFlags(array('fuzzy', 'php-code'));

$fileHandler = new Sepia\PoParser\SourceHandler\FileSystem('en.po');
$compiler = new Sepia\PoParser\PoCompiler();
$fileHandler->save($compiler->compile($catalog));

php vendor/bin/phpunit