raulferras / Php Po Parser
Licence: other
Parse Gettext *.PO files with PHP
Stars: ✭ 121
Projects that are alternatives of or similar to Php Po Parser
Luqum
A lucene query parser generating ElasticSearch queries and more !
Stars: ✭ 118 (-2.48%)
Mutual labels: parser
Pq
a command-line Protobuf parser with Kafka support and JSON output
Stars: ✭ 120 (-0.83%)
Mutual labels: parser
Surelog
SystemVerilog 2017 Pre-processor, Parser, Elaborator, UHDM Compiler. Provides IEEE Design/TB C/C++ VPI and Python AST API.
Stars: ✭ 116 (-4.13%)
Mutual labels: parser
Gettext Parser
Parse and compile gettext po and mo files, nothing more, nothing less
Stars: ✭ 118 (-2.48%)
Mutual labels: gettext
Nmonvisualizer
A Java GUI tool for analyzing NMON system files
Stars: ✭ 114 (-5.79%)
Mutual labels: parser
Instagram Parser
Парсер аккаунтов подписчиков и подписок в Instagram
Stars: ✭ 118 (-2.48%)
Mutual labels: parser
Lua Gumbo
Moved to https://gitlab.com/craigbarnes/lua-gumbo
Stars: ✭ 116 (-4.13%)
Mutual labels: parser
Commonmark Java
Java library for parsing and rendering CommonMark (Markdown)
Stars: ✭ 1,675 (+1284.3%)
Mutual labels: parser
Oletools
oletools - python tools to analyze MS OLE2 files (Structured Storage, Compound File Binary Format) and MS Office documents, for malware analysis, forensics and debugging.
Stars: ✭ 1,848 (+1427.27%)
Mutual labels: parser
Crass
A Ruby CSS parser that's fully compliant with the CSS Syntax Level 3 specification.
Stars: ✭ 118 (-2.48%)
Mutual labels: parser
PoParser
PoParser is a personal project to fulfill a need I got: parse Gettext Portable files (*.po files) and edit its content using PHP.
PoParser requires PHP >= 5.4, but may work in 5.3 too.
Changelog
Features
It supports following parsing features:
- header section.
- msgid, both single and multiline.
- msgstr, both single and multiline.
- msgctxt (Message context).
- msgid_plural (plurals forms).
- #, keys (flags).
- # keys (translator comments).
- #. keys (Comments extracted from source code).
- #: keys (references).
- #| keys (previous strings), both single and multiline.
- #~ keys (old entries), both single and multiline.
Installation
composer require sepia/po-parser
Usage
<?php
// 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'));
Save Changes back to a file
Use PoCompiler
together with FileSystem
to save a catalog back to a file:
$fileHandler = new Sepia\PoParser\SourceHandler\FileSystem('en.po');
$compiler = new Sepia\PoParser\PoCompiler();
$fileHandler->save($compiler->compile($catalog));
Documentation
Testing
Tests are done using PHPUnit. To execute tests, from command line type:
php vendor/bin/phpunit
TODO
- Add compatibility with older disambiguating contexts formats.
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].