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

jtt - CLI to help internationalization for Jenkins

USAGE

  jtt --lang=xx

  options:
    --dir=directory    -> source folder for searching files, optional
    --help             -> print this help message and exits
    --man              -> provides this CLI manpage and exits
    --version          -> prints the CLI version and exits
    --all              -> prints all identified language codes and their respective
                          percentage of translation
    --lang=xx          -> language code to use
    --add              -> optional, generate new files and add new keys to existing
                          files if present
    --remove           -> optional, remove unused key/value pair for existing files
                          if present
    --counter          -> optional, to each translated key, unique value is added
                          to easily identify match missing translation with value
                          in source code if present
    --target=directory -> optional, target directory for writing files
    --search=regex     -> optional, search for a given regular expression in the
                          translation content
    --debug            -> optional, print debugging messages to STDOUT when they
                          are available

OPTIONS

--lang is mandatory (except for --all) and it has to be different to English. If it is the only option provided, all files in the provided language code will be analyzed and a report will be provided at the end of it, without modifying a single translation file.

--dir and --target are optional and the default values for each one is the current directory. This probably the best configuration if you're going to use a Git repository to support the changes.

Some examples:

  • Look for Spanish files with incomplete keys in the current directory:

      jtt --lang=es
  • Remove all orphaned keys from German files which are in the current directory:

      jtt --lang=de --remove .

DESCRIPTION

Reporting overall status

The --all option will run through all translation files to:

  1. Load all the original English messages.

  2. Identify all available translation, extracting the related language code.

  3. For each language, prints it's code and the respective translation percentage.

Any other command line options are ignored if used with --all.

Translation changing helpers

To generate missing translation keys and missing properties files and to remove unused keys, the CLI uses this process:

  1. It recursively looks for files in a folder, and analyzes them to extract the keys being used in the application. In order to do that, the option --lang is required and the value must be different of english.

  2. If --add is in use, it generates the appropriate file for the desired language and adds these keys to it, adding the English text as a reference. If the properties file already exists the CLI updates it with the new keys.

  3. When --remove is in use and there are unused keys in our file, the CLI removes them.

  4. The --search option can be used instead of the two describe above in order to just search for a particular value in all files and print to STDOUT their location. No changes are made to any file.

The --counter can be used with both options, as well --debug.

The --dir and --target options can also be used, but you probably just want to move inside to the path where the Jenkins Git repository is and run from there instead. These options are kept for compatibility with the original tool and might be removed in the future.

REFERENCES

Make sure to also check the proposed translation workflow documentation.

AUTHOR

  • Original translation-tool.pl: Manuel Carrasco.

  • Fork to jtt: Alceu Rodrigues de Freitas Junior.

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.