All Projects → raulferras → Php Po Parser

raulferras / Php Po Parser

Licence: other
Parse Gettext *.PO files with PHP

Projects that are alternatives of or similar to Php Po Parser

Cmd Parser
一个非常简单好用的命令解析器,占用资源极少极少,采用哈希算法超快匹配命令!
Stars: ✭ 115 (-4.96%)
Mutual labels:  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
Chirp
A modern low-level programming language
Stars: ✭ 116 (-4.13%)
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
Spectre.cli
An extremely opinionated command-line parser.
Stars: ✭ 121 (+0%)
Mutual labels:  parser
Instagram Parser
Парсер аккаунтов подписчиков и подписок в Instagram
Stars: ✭ 118 (-2.48%)
Mutual labels:  parser
Rust hdl
Stars: ✭ 120 (-0.83%)
Mutual labels:  parser
Lua Gumbo
Moved to https://gitlab.com/craigbarnes/lua-gumbo
Stars: ✭ 116 (-4.13%)
Mutual labels:  parser
Vte
Parser for virtual terminal emulators
Stars: ✭ 117 (-3.31%)
Mutual labels:  parser
Java Petitparser
Dynamic parser combinators in Java.
Stars: ✭ 118 (-2.48%)
Mutual labels:  parser
Alembic
⚗️ Functional JSON Parser - Linux Ready 🐧
Stars: ✭ 115 (-4.96%)
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
Webrtc Sdp
Rust SDP parser for WebRTC
Stars: ✭ 121 (+0%)
Mutual labels:  parser
Go Wasm
WebAssembly binary file parser written in go
Stars: ✭ 121 (+0%)
Mutual labels:  parser
Html2pug
Converts HTML to Pug 🐶
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

Latest Stable Version Total Downloads License Build Status Code Coverage Scrutinizer Quality Score

Gitter

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].