The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

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

VERSION

version 0.02

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');

  $file->add_entry(
      msgid  => 'Hello',
      msgstr => 'Guten Tag'
  );
  my @entries = $file->entries;
  my $entry = $file->entry_for('Hello');
  $file->save;

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.

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.

entries

Returns a list of Locale::PO objects corresponding to translation entries in the file.

add_entry

Adds a new translation entry to the file. This can be provided either as a Locale::PO object directly, or as a hash of options to pass to the Locale::PO constructor (except without the leading dashes).

msgids

Returns a list of msgids found in the file.

entry_for

Returns the Locale::PO object corresponding to the given msgid.

save

Writes the current contents of the file back out to disk.

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) 2010 by Jesse Luehrs.

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