Message command line manager: .php <-> .po converter, message extractor and statistics.
The usual command line
protected/yiic message protected/messages/config.php
produces .php files whereas computer-aided translation systems such as Lokalize or PoEdit use gettext files, so I made this converter between .po and .php and added a custum extraction process to fit my needs.
Resources ¶
Documentation ¶
Requirements ¶
Installation ¶
- Extract the release file under
protected/commands
Usage ¶
Retrieving translation strings
protected/yiic emessage message
Convert .php to .po
protected/yiic emessage php
(beware of the header and specially the nplural formula)
Convert .po to .php
protected/yiic emessage po
Finding duplicates
protected/yiic emessage duplicates
Finding duplicates without considering the case
protected/yiic emessage duplicates --caseSensitive=false
Getting translation statistics
protected/yiic emessage statistics
Getting help
protected/yiic emessage
You can specify a configuration file (default: protected/messages/config.php).
The file must be a valid PHP script which returns an array of name-value pairs.
Each name-value pair represents a configuration option. The following options must be specified:
- messagePath: string, root directory containing message translations.
- languages: array, list of language codes that the extracted messages
should be translated to. For example, array('zh_cn', 'en_au').
- autoMerge: boolean, overwrite the .php files with the new extracted
messages. Default: false.
- launchpad: boolean, if the .po files must be stored as
protected/messages/launchpad/template/lang.po or in the same directory
of the converted .php file. Default: false.
- skipUnused: boolean, do not mark unused string with '@@' and skip
them. Default: false.
- fileTypes: array, a list of file extensions (e.g. 'php', 'xml').
Only the files whose extension name can be found in this list
will be processed. If empty, all files will be processed.
- exclude: array, a list of directory and file exclusions. Each
exclusion can be either a name or a path. If a file or directory name
or path matches the exclusion, it will not be copied. For example,
an exclusion of '.svn' will exclude all files and directories whose
name is '.svn'. And an exclusion of '/a/b' will exclude file or
directory 'sourcePath/a/b'.
- translator: the name of the function for translating messages.
Defaults to 'Yii::t'. This is used as a mark to find messages to be translated.
Change Log ¶
May 23, 2009 ¶
May 12, 2010 ¶
- Second release (renamed to EMessage) with 2 more commands: message and statistics
November 10, 2010 ¶
- Third release with more options, among them : creation of the .po files in a launchpad directory.
December 14, 2011 ¶
- Patch on sorting the string by Attila N.
January 4, 2012 ¶
- Add the caseSensitive option to the
duplicates action.
Total 2 comments
I made a mistake, the right command is :
Convert .php to .po
protected/yiic pophp php protected/messages/config.php
should be:
protected/yiic php pophp protected/messages/config.php
if not, why the cmd same to "Convert .po to .php"??
Leave a comment
Please login to leave your comment.