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

Jenkins::i18n - functions for the jtt CLI

SYNOPSIS

  use Jenkins::i18n qw(remove_unused find_files load_properties load_jelly find_langs);

DESCRIPTION

jtt is a CLI program used to help translating the Jenkins properties file.

This module implements some of the functions used by the CLI.

EXPORT

None by default.

FUNCTIONS

remove_unused

Remove unused keys from a properties file.

Each translation in every language depends on the original properties files that are written in English.

This function gets a set of keys and compare with those that are stored in the translation file: anything that exists outside the original set in English is considered deprecated and so removed.

Expects as positional parameters:

  1. file: the complete path to the translation file to be checked.

  2. keys: a Set::Tiny instance of the keys from the original English properties file.

  3. license: a scalar reference with a license to include the header of the translated properties file.

  4. backup: a boolean (0 or 1) if a backup file should be created in the same path of the file parameter. Optional.

Returns the number of keys removed (as an integer).

find_files

Find all Jelly and Java Properties files that could be translated from English, i.e., files that do not have a ISO 639-1 standard language based code as a filename prefix (before the file extension).

Expects as parameter a complete path to a directory that might contain such files.

Returns an sorted array reference with the complete path to those files.

find_langs

Finds all ISO 639-1 standard language based codes available in the Jenkins repository based on the filenames sufix (before the file extension) of the translated files.

This is basically the opposite of find_files does.

It expect as parameters the complete path to a directory to search for the files.

Returns a instance of the Set::Tiny class containing all the language codes that were identified.

load_properties

Loads the content of a Java Properties file into a hash.

Expects as position parameters:

  1. The complete path to a Java Properties file.

  2. True (1) or false (0) if a warn should be printed to STDERR in case the file is missing.

Returns an hash reference with the file content. If the file doesn't exist, returns an empty hash reference.

load_jelly

Fill a hash with key/1 pairs from a .jelly file.

Expects as parameter the path to a Jelly file.

Returns a hash reference.

SEE ALSO

AUTHOR

Alceu Rodrigues de Freitas Junior, <arfreitas@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2022 of Alceu Rodrigues de Freitas Junior, <arfreitas@cpan.org>

This file is part of Jenkins Translation Tool project.

Jenkins Translation Tool is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Jenkins Translation Tool is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Jenkins Translation Tool. If not, see (http://www.gnu.org/licenses/).

The original translation-tool.pl script was licensed through the MIT License, copyright (c) 2004-, Kohsuke Kawaguchi, Sun Microsystems, Inc., and a number of other of contributors. Translations files generated by the Jenkins Translation Tool CLI are distributed with the same MIT License.