The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Locale::POFileManager - Helpers for keeping a set of related .po files in sync

VERSION

version 0.02

SYNOPSIS

  use Locale::POFileManager;

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

  my %missing = $manager->find_missing;
  $manager->add_stubs;
  $manager->add_language('de');

DESCRIPTION

This module contains helpers for managing a set of gettext translation files, including tools to keep the translation files in sync, adding new translation files, and manipulating the translations contained in the files. It is based on the Locale::PO parser library.

METHODS

new

Accepts a hash of arguments:

base_dir

The directory that contains the .po files. Required.

canonical_language

The language for the file that contains the canonical set of msgids. Required.

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, lang, and canonical_msgstr (the msgstr value from the canonical_language. Optional.

base_dir

Returns a Path::Class::Dir object corresponding to the base_dir passed to the constructor.

files

Returns a list of Locale::POFileManager::File objects corresponding to the .po files that were found in the base_dir.

canonical_language

Returns the canonical language id passed to the constructor.

stub_msgstr

Returns the string passed to the constructor as stub_msgstr if it was a string, or a coderef wrapped to supply the canonical_msgstr option if it was a coderef.

has_language

Returns true if a language file exists for the given language in the base_dir, false otherwise.

add_language

Creates a new language file for the language passed in as an argument. Creates a header for that file copied over from the header in the canonical_language language file, and saves the newly created file in the base_dir.

language_file

Returns the Locale::POFileManager object corresponding to the given language.

canonical_language_file

Returns the Locale::POFileManager object corresponding to the canonical_language.

find_missing

Searches through all of the files in the base_dir, and returns a hash mapping language names to an arrayref of msgids that were found in the canonical_language file but not in the file for that language.

add_stubs

Adds stub msgid (and possibly msgstr, if the stub_msgstr option was given) entries to each language file for each msgid found in the canonical_language file but not in the language file.

BUGS

No known bugs.

Please report any bugs through RT: email bug-locale-pofilemanager at rt.cpan.org, or browse to http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Locale-POFileManager.

SEE ALSO

Locale::PO

Locale::Maketext

SUPPORT

You can find this documentation for this module with the perldoc command.

    perldoc Locale::POFileManager

You can also look for information at:

AUTHOR

  Jesse Luehrs <doy at tozt dot net>

COPYRIGHT AND LICENSE

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

This is free software; you can redistribute it and/or modify it under the same terms as perl itself.