Locale::File::PO::Header - Utils to build/extract the PO header
$Id: Utils.pm 602 2011-11-13 13:49:23Z steffenw $
$HeadURL: https://dbd-po.svn.sourceforge.net/svnroot/dbd-po/Locale-File-PO-Header/trunk/lib/Locale/PO/Utils.pm $
0.004
require Locale::PO::Utils; $obj = Locale::PO::Utils->new;
Utils to build or extract the PO header
The header of a PO file is quite complex. This module helps to build the header and extract.
$msgstr = $obj->msgstr;
If nothing was set before it returns a minimal header:
MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit
$obj->msgstr(<<'EOT'); Content-Type: text/plain; charset=UTF-8 EOT
If nothing else was set before the msgstr is:
MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit
This sub returns all header keys you can set or get.
@all_keys = $obj->all_keys;
The returned array is:
qw( Project-Id-Version Report-Msgid-Bugs-To_name Report-Msgid-Bugs-To_address POT-Creation-Date PO-Revision-Date Last-Translator_name Last-Translator_address Language-Team_name Language-Team_address MIME-Version Content-Type charset Content-Transfer-Encoding Plural-Forms extended )
$obj->data({ Project-Id-Version => 'Example', Report-Msgid-Bugs-To_address => 'bug@example.com', extended => { X-Example => 'This is an example', }, });
Project-Id-Version: Example Report-Msgid-Bugs-To: bug@example.com MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Example: This is an example
An example to write all keys:
$obj->data({ 'Project-Id-Version' => 'Testproject', 'Report-Msgid-Bugs-To_name' => 'Bug Reporter', 'Report-Msgid-Bugs-To_address' => 'bug@example.org', 'POT-Creation-Date' => 'no POT creation date', 'PO-Revision-Date' => 'no PO revision date', 'Last-Translator_name' => 'Steffen Winkler', 'Last-Translator_address' => 'steffenw@example.org', 'Language-Team_name' => 'MyTeam', 'Language-Team_address' => 'cpan@example.org', 'MIME-Version' => '1.0', 'Content-Type' => 'text/plain', 'charset' => 'utf-8', 'Content-Transfer-Encoding' => '8bit', 'extended' => [ 'X-Poedit-Language' => 'German', 'X-Poedit-Country' => 'GERMANY', 'X-Poedit-SourceCharset' => 'utf-8', ], });
The msgstr is:
Project-Id-Version: Testproject Report-Msgid-Bugs-To: Bug Reporter <bug@example.org> POT-Creation-Date: no POT creation date PO-Revision-Date: no PO revision date Last-Translator: Steffen Winkler <steffenw@example.org> Language-Team: MyTeam <cpan@example.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Poedit-Language: German X-Poedit-Country: GERMANY X-Poedit-SourceCharset: utf-8
$obj->item( 'Project-Id-Version' => 'Example' );
$value = $obj->item('Project-Id-Version');
@values = $obj->items( @keys ); @values = $obj->items( qw(Project-Id-Version charset) );
Inside of this distribution is a directory named example. Run the *.pl files.
none
Moose
MooseX::StrictConstructor
namespace::autoclean;
syntax
Clone
not known
http://en.wikipedia.org/wiki/Gettext
Steffen Winkler
Copyright (c) 2011 - 2017, Steffen Winkler <steffenw at cpan.org>. All rights reserved.
<steffenw at cpan.org>
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Locale::File::PO::Header, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Locale::File::PO::Header
CPAN shell
perl -MCPAN -e shell install Locale::File::PO::Header
For more information on module installation, please visit the detailed CPAN module installation guide.