App-Greple-xlate

 view release on metacpan or  search on metacpan

script/xlate  view on Meta::CPAN

    -n, --dryrun      dry-run (make -n)

  Docker options:
    -D, --docker *    run xlate on the container with the same parameters
    -C, --command *   execute following command on the container, or run shell
    -L, --live *      use the live container
    N.B. These options terminate option handling

    -W, --mount-cwd    mount current working directory
    -H, --mount-home   mount home directory
    -V, --volume=#     specify mount directory
    -U, --unmount      do not mount
    -R, --mount-ro     mount read-only
    -B, --batch        run container in batch mode
    -N, --name=#       specify the name of live container
    -K, --kill         kill and remove live container
    -E, --env=#        specify an environment variable to be inherited
    -I, --image=#      docker image or version (default: tecolicom/xlate:version)
    -P, --port=#       port mapping
    -O, --other=#      additional docker option

  Control Files:
    *.LANG    translation languages
    *.FORMAT  translation format (xtxt, cm, ifdef, colon, space)
    *.ENGINE  translation engine (gpt5, deepl, ...)
    *.ANONYMIZE  anonymization dictionary for the file

=head1 VERSION

    Version 2.01

=head1 INCOMPATIBLE CHANGES IN 2.0

=over 2

=item *

The default translation engine changed from C<deepl> to C<gpt5>.
Cache file names include the engine name
(F<FILE.xlate-gpt5-LANG.json>), so running without C<-e deepl>
creates a new cache for existing DeepL-translated documents.

=item *

API translation is now the default.  The clipboard-based manual
translation mode requires B<--no-api> (the former default);
B<-a>/B<--api> remains valid as an explicit default.

=back

=cut

[[ $pod =~ Version\ +([0-9.]+) ]] && my_version=${BASH_REMATCH[1]}

##############################################################################
# Utility functions
##############################################################################

dist_dir() {
    local mod=$1
    perl -M$mod -MFile::Share=:all -E "say dist_dir '${mod//::/-}'"
}

warn() {
    [[ ${quiet:-} ]] && return
    echo "$@" >&2
}

die() {
    echo "$myname: $*" >&2
    exit 1
}

# Check bash version (4.3+ required for getoptlong.sh)
if ((BASH_VERSINFO[0] < 4 || (BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] < 3))); then
    die "bash 4.3+ required (found $BASH_VERSION)"
fi

git_topdir() {
    [[ $(git rev-parse --is-inside-work-tree 2>/dev/null) == true ]] || return
    local dir="$(git rev-parse --show-superproject-working-tree)"
    [[ $dir ]] || dir="$(git rev-parse --show-toplevel)"
    echo "$dir"
}

##############################################################################
# Setup
##############################################################################

# Get share directory
share=$(dist_dir App::Greple::xlate 2>/dev/null) || share=
basedir="${0%/*/*}"
if [[ ! $share && -d $basedir/share ]]; then
    share="$basedir/share"
fi

# Find dozo command
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
DOZO="${SCRIPT_DIR}/dozo"
[[ -x "$DOZO" ]] || DOZO="dozo"

topdir=$(git_topdir) || topdir=
pwd=$(pwd)

# Docker related variables
declare -a dozo_opts=()
version=
image=

# Option arrays (initialized for set -u)
declare -a pattern=()
declare -a file=()
declare -a env=()
declare -a volume=()
declare -a port=()
declare -a other=()

set_default_image() {
    [[ ${image:-} ]] && return
    repository=tecolicom/$myname
    [[ ! ${version:-} && $my_version =~ ^[0-9]+\.[0-9_]+$ ]] && version=$my_version



( run in 3.098 seconds using v1.01-cache-2.11-cpan-6736b670a1e )