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

Pootle::Client

Client to talk with Pootle API v1 nicely

See. https://pootle.readthedocs.io/en/stable-2.5.1/api/index.html for more information about the API resources/data_structures this Client returns.

Eg. https://pootle.readthedocs.io/en/stable-2.5.1/api/api_project.html#get-a-project maps to Pootle::Resource::Project locally.

REQUIRES

Perl 5.20 or newer with support for subroutine signatures

Caches

See Pootle::Cache, for how the simple caching system works to spare the Pootle-Server from abuse

Logger

See Pootle::Logger, for how to change Pootle::Client chattiness

Synopsis

    my $papi = Pootle::Client->new({
                  baseUrl => 'http://translate.example.com',
                  credentials => 'username:password' || 'credentials.txt'}
    );
    my $languages = $papi->languages();
    my $trnsProjs = $papi->searchTranslationProjects(
                       $languages,
                       Pootle::Filters->new({fullname => qr/^Project name/})
    );

new($params)

Instantiates a new Pootle::Client

 $params HASHRef of parameters {
           baseUrl => 'http://translate.pootle.url',
           credentials => 'usename:password' ||
                          'credentials.file.containing.credentials.txt',
           cacheFile => 'pootle-client.cache',
         }

 @returns Pootle::Client

ACCESSING THE POOTLE API

This Client transparently handles authentication based on the credentials supplied. Use the following methods to make API requests.

language
 @PARAM1  String, API endpoint to get the resource, eg. /api/v1/languages/124/
 @RETURNS L<Pootle::Resource::Language>
languages
 @RETURNS ARRAYRef of L<Pootle::Resource::Language>,
                                           all languages in the Pootle database
 @CACHED  Transiently
findLanguages

Uses the API to find all languages starting with the given country code

 @PARAM1  L<Pootle::Filters>
 @RETURNS ARRAYRef of L<Pootle::Resource::Language>,
          all languages starting with the given code.
 @CACHED  Persistently
translationProject
 @PARAM1  String, API endpoint to get the resource,
          eg. /api/v1/translation-projects/124/
 @RETURNS L<Pootle::Resource::TranslationProject>
translationProjects
 @UNIMPLEMENTED

This endpoint is unimplemented in the Pootle-Client. Maybe some day it becomes enabled. If it does, this should work out-of-box.

It might be better to use searchTranslationProjects() instead, since this API call can be really invasive to the Pootle-server. Really depends on how many translation projects you are after.

 @RETURNS ARRAYRef of L<Pootle::Resource::TranslationProject>,
          all translation projects in the Pootle database
 @CACHED  Transiently
 @THROWS  L<Pootle::Exception::HTTP::MethodNotAllowed>
findTranslationProjects
 @UNIMPLEMENTED

This endpoint is unimplemented in the Pootle-Client. Maybe some day it becomes enabled. If it does, this should work out-of-box.

Uses the API to find all translation projects matching the given search expressions

 @PARAM1  L<Pootle::Filters>, Used to select the desired objects
 @RETURNS ARRAYRef of L<Pootle::Resource::TranslationProject>.
          All matched translation projects.
 @CACHED  Persistently
 @THROWS  L<Pootle::Exception::HTTP::MethodNotAllowed>
searchTranslationProjects
 @PARAM1  L<Pootle::Filters>, Filters to pick desired languages
          or
          ARRAYRef of L<Pootle::Resource::Language>
 @PARAM2  L<Pootle::Filters>, Filters to pick desired projects
          or
          ARRAYRef of L<Pootle::Resource::Project>
 @RETURNS ARRAYRef of L<Pootle::Resource::TranslationProject>,
          matching the given languages and projects
 @CACHED  Persistently
store
 @PARAM1  String, API endpoint to get the resource, eg. /api/v1/stores/77/
 @RETURNS L<Pootle::Resource::Store>
searchStores
 @PARAM1  L<Pootle::Filters>, Filters to pick desired languages
          or
          ARRAYRef of L<Pootle::Resource::Language>
 @PARAM2  L<Pootle::Filters>, Filters to pick desired projects
          or
          ARRAYRef of L<Pootle::Resource::Project>
 @RETURNS ARRAYRef of L<Pootle::Resource::Store>,
          matching the given languages and projects
project
 @PARAM1  String, API endpoint to get the project, eg. /api/v1/projects/124/
 @RETURNS L<Pootle::Resource::Project>
projects
 @RETURNS ARRAYRef of L<Pootle::Resource::Project>,
          all projects in the Pootle database
 @CACHED  Transiently
findProjects

Uses the API to find all projects matching the given search expressions

 @PARAM1  L<Pootle::Filters>, matching criteria for needed objects
 @RETURNS ARRAYRef of L<Pootle::Resource::Project>. All matched projects.
 @CACHED  Persistently
unit
 @PARAM1  String, API endpoint to get the resource, eg. /api/v1/units/77/
 @RETURNS L<Pootle::Resource::Unit>

HELPERS

flushCaches

Flushes all caches

ACCESSORS

a
 @RETURNS L<Pootle::Agent>
c
 @RETURNS L<Pootle::Cache>

5 POD Errors

The following errors were encountered while parsing the POD:

Around line 105:

'=item' outside of any '=over'

Around line 409:

You forgot a '=back' before '=head1'

Around line 411:

'=item' outside of any '=over'

Around line 421:

You forgot a '=back' before '=head1'

Around line 423:

'=item' outside of any '=over'

=over without closing =back