From c005d704a8e083d34327475e5abb35ab6d4844c0 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 19 Feb 2010 15:51:43 -0600 Subject: stub out docs --- lib/Locale/POFileManager.pm | 67 +++++++++++++++++++++++++++++- lib/Locale/POFileManager/File.pm | 88 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 153 insertions(+), 2 deletions(-) diff --git a/lib/Locale/POFileManager.pm b/lib/Locale/POFileManager.pm index 811105f..2ce4357 100644 --- a/lib/Locale/POFileManager.pm +++ b/lib/Locale/POFileManager.pm @@ -5,13 +5,37 @@ use Scalar::Util qw(reftype weaken); =head1 NAME -Locale::POFileManager - +Locale::POFileManager - Helpers for keeping a set of related .po files in sync =head1 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'); =head1 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 L parser library. + +=cut + +=head1 METHODS + +=head2 new + +=cut + +=head2 base_dir =cut @@ -22,6 +46,10 @@ has base_dir => ( coerce => 1, ); +=head2 files + +=cut + has files => ( traits => [qw(Array)], isa => 'ArrayRef[Locale::POFileManager::File]', @@ -55,6 +83,10 @@ sub _build_files { return \@files; } +=head2 canonical_language + +=cut + has canonical_language => ( is => 'ro', isa => 'Str', @@ -74,6 +106,10 @@ sub BUILD { unless $self->has_language($self->canonical_language); } +=head2 stub_msgstr + +=cut + sub stub_msgstr { my $self = shift; my $msgstr = $self->_stub_msgstr; @@ -95,6 +131,10 @@ sub stub_msgstr { } } +=head2 has_language + +=cut + sub has_language { my $self = shift; my ($lang) = @_; @@ -106,6 +146,10 @@ sub has_language { return; } +=head2 add_language + +=cut + sub add_language { my $self = shift; my ($lang) = @_; @@ -127,6 +171,10 @@ sub add_language { $self->_add_file($pofile); } +=head2 language_file + +=cut + sub language_file { my $self = shift; my ($lang) = @_; @@ -136,11 +184,19 @@ sub language_file { }); } +=head2 canonical_language_file + +=cut + sub canonical_language_file { my $self = shift; return $self->language_file($self->canonical_language); } +=head2 find_missing + +=cut + sub find_missing { my $self = shift; my $canon_file = $self->canonical_language_file; @@ -153,6 +209,10 @@ sub find_missing { return %ret; } +=head2 add_stubs + +=cut + sub add_stubs { my $self = shift; my $canon_file = $self->canonical_language_file; @@ -175,6 +235,9 @@ L. =head1 SEE ALSO +L + +L =head1 SUPPORT @@ -210,7 +273,7 @@ L =head1 COPYRIGHT AND LICENSE -This software is copyright (c) 2009 by Jesse Luehrs. +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. diff --git a/lib/Locale/POFileManager/File.pm b/lib/Locale/POFileManager/File.pm index 368025b..e5e8267 100644 --- a/lib/Locale/POFileManager/File.pm +++ b/lib/Locale/POFileManager/File.pm @@ -7,6 +7,45 @@ use List::Util qw(first); use Locale::PO; use Scalar::Util qw(reftype); +=head1 NAME + +Locale::POFileManager::File - A single .po file + +=head1 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; + +=head1 DESCRIPTION + +This module represents a single translation file, providing methods for +manipulating the translation entries in it. + +=cut + +=head1 METHODS + +=head2 new + +=cut + +=head2 file + +=cut + has file => ( is => 'ro', isa => File, @@ -14,11 +53,27 @@ has file => ( required => 1, ); +=head2 stub_msgstr + +=cut + has stub_msgstr => ( is => 'ro', isa => 'Str|CodeRef', ); +=head2 entries + +=cut + +=head2 add_entry + +=cut + +=head2 msgids + +=cut + has entries => ( traits => [qw(Array)], isa => 'ArrayRef[Locale::PO]', @@ -52,18 +107,30 @@ sub add_entry { } } +=head2 entry_for + +=cut + sub entry_for { my $self = shift; my ($msgid) = @_; return first { $_->msgid eq '"' . $msgid . '"' } $self->entries; } +=head2 save + +=cut + sub save { my $self = shift; Locale::PO->save_file_fromarray($self->file->stringify, [$self->entries]); } +=head2 language + +=cut + sub language { my $self = shift; my $language = $self->file->basename; @@ -71,6 +138,10 @@ sub language { return $language; } +=head2 find_missing_from + +=cut + sub find_missing_from { my $self = shift; my ($other) = @_; @@ -85,6 +156,10 @@ sub find_missing_from { return @ret; } +=head2 add_stubs_from + +=cut + sub add_stubs_from { my $self = shift; my ($other) = @_; @@ -106,4 +181,17 @@ sub add_stubs_from { __PACKAGE__->meta->make_immutable; no Moose; +=head1 AUTHOR + + Jesse Luehrs + +=head1 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. + +=cut + 1; -- cgit v1.2.3