[Back to main] [Printable version] [Search] [Leave a comment] Comments

pophorator - Tool for localizing PHP, HTML and Javascript statically [Leave a comment]

Copyright 2004, 2005 by Jarno Elonen <elonen@iki.fi>

Pophorator is a gettext (.po) compatible L10N tool for statically translating strings in mixed PHP, HTML and Javascript files -- sort of "gettext for HTML" with PHP support. It is a command line program written in PHP. Contributions (preferably patch files) are welcome.

Download

  • pophorator (the program, about 23 KB)
  • license (GNU GPL v. 2). Please note that the GPL covers only the program itself, not the content made with it. Hence, your website/PHP application does not have to be GPL'd even if you use Pophorator.

...or read the source code.

Instructions

This is what the program outputs with --help:

pophorator 0.51 - Tool for localizing PHP, HTML and Javascript statically

Usage: pophorator -g <INFILE> [INFILE ...]
       pophorator -p <INFILE>

  -g               Get strings from INFILE(s) and write a .pot into STDOUT
  -p               Apply .po strings from STDIN to INFILE and write to STDOUT
  -h,  --help      Show this help

INFILEs are never modified, -p mode outputs the
changed version into STDOUT. The character encoding of INFILEs
is currently assumed to be in ISO-8859-1 whereas the output is in UTF-8.

HTML tags are abbreviated in the 'get' phase by removing all atributes
from them, e.g. '<a href="...">link</a>' becomes '<a>link</a>'. The
'put' phase puts them back.

Marking localizable strings:

  PHP and Javascript:

    Enclose strings into _() and mark comments with /**/. Example:
    _( "End" /* Verb, end session */  )

  HTML text:

    Enclose text into <loc comment="..."></loc>. Example:
    <a href="..."><loc comment="Verb, end session">End</loc></a>

  HTML tag attributes:

    List the localizable attributes in new attribute 'locattr',
    separated by space, comma or semicolon. Put comments into
    'loccomment' (currently shared between all the attributes). Example:
    <a href=".." title="End" locattr="title" loccomment="Verb, end session">

Copyright (C) 2004, 2005 by Jarno Elonen
Released under the GNU General Public License version 2.

blog comments powered by Disqus