NAME

Locale::POFileManager::File - A single .po file

VERSION

version 0.05

SYNOPSIS

use Locale::POFileManager;

my $manager = Locale::POFileManager->new(
    base_dir           => '/path/to/app/i18n/po',
    canonical_language => 'en',
);
my $file = $manager->language_file('de');
my $lang = $file->language; # 'de'

$file->add_entry(
    msgid  => 'Hello',
    msgstr => 'Guten Tag'
);

my $translation = $file->msgstr('Hello'); # 'Guten Tag'

DESCRIPTION

This module represents a single translation file, providing methods for manipulating the translation entries in it.

METHODS

new

Accepts a hash of arguments:

file

The name of the file this represents. Required, and must exist.

stub_msgstr

The msgstr to insert when adding stubs to language files. This can be either a literal string, or a coderef which accepts a hash containing the keys msgid and lang. Optional.

file

Returns a Path::Class::File object corresponding to the file passed to the constructor.

stub_msgstr

Returns the stub_msgstr passed to the constructor.

msgids

Returns a list of msgids found in the file.

has_msgid

Returns true if the given msgid is found in the file, and false otherwise.

msgstr

Returns the msgstr that corresponds with the given msgid.

headers

Returns the list of header entries.

Returns the value of the given header entry.

add_entry

Adds an entry to the translation file. Arguments are a hash, with valid keys being msgid and msgstr.

language

Returns the language that this file corresponds to.

find_missing_from

Takes another translation file (either as a filename or as a Locale::POFileManager::File object), and returns a list of msgids that the given file contains that this file doesn't.

add_stubs_from

Takes another translation file (either as a filename or as a Locale::POFileManager::File object), and adds stubs for each msgid that the given file contains that this file doesn't.

AUTHOR

Jesse Luehrs <doy at tozt dot net>

COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by Jesse Luehrs.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.