App-Greple-xlate

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

        **gpt-4o**'s interface is unstable and cannot be guaranteed to work
        correctly at the moment.

    - **gpt5**: gpt-5.5

- **--xlate-labor**
- **--xlabor**

    Instead of calling translation engine, you are expected to work for.
    After preparing text to be translated, they are copied to the
    clipboard.  You are expected to paste them to the form, copy the
    result to the clipboard, and hit return.

- **--xlate-to** (Default: `EN-US`)

    Specify the target language.  You can get available languages by
    `deepl languages` command when using **DeepL** engine.

- **--xlate-format**=_format_ (Default: `conflict`)

    Specify the output format for original and translated text.

README.md  view on Meta::CPAN


    - **xtxt**

        If the format is `xtxt` (translated text) or unkown, only translated
        text is printed.

- **--xlate-maxlen**=_chars_ (Default: 0)

    Specify the maximum length of text to be sent to the API at once.
    Default value is set as for free DeepL account service: 128K for the
    API (**--xlate**) and 5000 for the clipboard interface
    (**--xlate-labor**).  You may be able to change these value if you are
    using Pro service.

- **--xlate-maxline**=_n_ (Default: 0)

    Specify the maximum lines of text to be sent to the API at once.

    Set this value to 1 if you want to translate one line at a time.  This
    option takes precedence over the `--xlate-maxlen` option.

docs/src/xlate.deepl-ID.pod  view on Meta::CPAN

Antarmuka B<gpt-4o> tidak stabil dan tidak dapat dijamin untuk bekerja dengan benar saat ini.

=item * B<gpt5>: gpt-5.5

=back

=item B<--xlate-labor>

=item B<--xlabor>

Alih-alih memanggil mesin penerjemah, Anda diharapkan untuk bekerja. Setelah menyiapkan teks yang akan diterjemahkan, teks tersebut disalin ke clipboard. Anda diharapkan untuk menempelkannya ke formulir, menyalin hasilnya ke clipboard, dan menekan re...

=item B<--xlate-to> (Default: C<EN-US>)

Tentukan bahasa target. Anda bisa mendapatkan bahasa yang tersedia dengan perintah C<deepl languages> ketika menggunakan mesin B<DeepL>.

=item B<--xlate-format>=I<format> (Default: C<conflict>)

Tentukan format output untuk teks asli dan terjemahan.

Format berikut ini selain C<xtxt> mengasumsikan bahwa bagian yang akan diterjemahkan adalah kumpulan baris. Pada kenyataannya, dimungkinkan untuk menerjemahkan hanya sebagian dari sebuah baris, tetapi menentukan format selain C<xtxt> tidak akan mengh...

docs/src/xlate.deepl-ID.pod  view on Meta::CPAN

Teks asli dan teks yang dikonversi dicetak dipisahkan oleh satu baris kosong. Untuk C<spasi+>, ini juga menghasilkan baris baru setelah teks yang dikonversi.

=item B<xtxt>

Jika formatnya adalah C<xtxt> (teks terjemahan) atau tidak diketahui, hanya teks terjemahan yang dicetak.

=back

=item B<--xlate-maxlen>=I<chars> (Default: 0)

Tentukan panjang maksimum teks yang akan dikirim ke API sekaligus. Nilai default ditetapkan untuk layanan akun DeepL gratis: 128K untuk API (B<--xlate>) dan 5000 untuk antarmuka clipboard (B<--xlate-labor>). Anda mungkin dapat mengubah nilai ini jika...

=item B<--xlate-maxline>=I<n> (Default: 0)

Tentukan jumlah maksimum baris teks yang akan dikirim ke API sekaligus.

Tetapkan nilai ini ke 1 jika Anda ingin menerjemahkan satu baris dalam satu waktu. Opsi ini lebih diutamakan daripada opsi C<--xlate-maxlen>.

=item B<--xlate-prompt>=I<text>

Tentukan prompt khusus yang akan dikirim ke mesin terjemahan. Opsi ini hanya tersedia saat menggunakan mesin ChatGPT (gpt3, gpt4o, gpt5). Anda dapat menyesuaikan perilaku terjemahan dengan memberikan instruksi spesifik kepada model AI. Jika prompt be...

docs/src/xlate.deepl-RO.pod  view on Meta::CPAN

Interfața lui B<gpt-4o> este instabilă și nu se poate garanta că funcționează corect în acest moment.

=item * B<gpt5>: gpt-5.5

=back

=item B<--xlate-labor>

=item B<--xlabor>

În loc să apelați motorul de traducere, se așteaptă să lucrați pentru. După pregătirea textului care urmează să fie tradus, acestea sunt copiate în clipboard. Se așteaptă să le lipiți în formular, să copiați rezultatul în clipboar...

=item B<--xlate-to> (Default: C<EN-US>)

Specificați limba țintă. Puteți obține limbile disponibile prin comanda C<deepl languages> atunci când se utilizează motorul B<DeepL>.

=item B<--xlate-format>=I<format> (Default: C<conflict>)

Specificați formatul de ieșire pentru textul original și cel tradus.

Următoarele formate, altele decât C<xtxt>, presupun că partea care urmează să fie tradusă este o colecție de linii. De fapt, este posibil să se traducă doar o parte a unei linii, dar specificarea unui alt format decât C<xtxt> nu va produce ...

docs/src/xlate.deepl-RO.pod  view on Meta::CPAN

Textul original și cel convertit sunt tipărite separate de o singură linie albă. Pentru C<space+>, se tipărește și o linie nouă după textul convertit.

=item B<xtxt>

Dacă formatul este C<xtxt> (text tradus) sau necunoscut, se tipărește numai textul tradus.

=back

=item B<--xlate-maxlen>=I<chars> (Default: 0)

Specificați lungimea maximă a textului care urmează să fie trimis la API deodată. Valoarea implicită este setată ca pentru serviciul de cont gratuit DeepL: 128K pentru API (B<--xlate>) și 5000 pentru interfața clipboard (B<--xlate-labor>). E...

=item B<--xlate-maxline>=I<n> (Default: 0)

Specificați numărul maxim de linii de text care urmează să fie trimise simultan către API.

Setați această valoare la 1 dacă doriți să traduceți un rând pe rând. Această opțiune are prioritate față de opțiunea C<--xlate-maxlen>.

=item B<--xlate-prompt>=I<text>

Specificați o solicitare personalizată care să fie trimisă motorului de traducere. Această opțiune este disponibilă numai atunci când se utilizează motoarele ChatGPT (gpt3, gpt4o, gpt5). Puteți personaliza comportamentul traducerii oferind ...

docs/src/xlate.gpt5-RO.pod  view on Meta::CPAN

Interfața lui B<gpt-4o> este instabilă și nu poate fi garantat că va funcționa corect în acest moment.

=item * B<gpt5>: gpt-5.5

=back

=item B<--xlate-labor>

=item B<--xlabor>

În loc să apelați motorul de traducere, se așteaptă să lucrați manual. După pregătirea textului de tradus, acesta este copiat în clipboard. Se așteaptă să îl lipiți în formular, să copiați rezultatul în clipboard și să apăsați ...

=item B<--xlate-to> (Default: C<EN-US>)

Specificați limba țintă. Puteți obține limbile disponibile cu comanda C<deepl languages> când folosiți motorul B<DeepL>.

=item B<--xlate-format>=I<format> (Default: C<conflict>)

Specificați formatul de ieșire pentru textul original și tradus.

Următoarele formate, altele decât C<xtxt>, presupun că partea de tradus este o colecție de linii. De fapt, este posibil să traduceți doar o porțiune a unei linii, dar specificarea unui format diferit de C<xtxt> nu va produce rezultate semnific...

docs/src/xlate.gpt5-RO.pod  view on Meta::CPAN

Textul original și cel convertit sunt tipărite separate de o linie goală. Pentru C<space+>, se afișează și un rând nou după textul convertit.

=item B<xtxt>

Dacă formatul este C<xtxt> (text tradus) sau necunoscut, se tipărește doar textul tradus.

=back

=item B<--xlate-maxlen>=I<chars> (Default: 0)

Specificați lungimea maximă a textului care va fi trimis la API dintr-o singură dată. Valoarea implicită este setată pentru serviciul contului DeepL gratuit: 128K pentru API (B<--xlate>) și 5000 pentru interfața clipboard (B<--xlate-labor>). ...

=item B<--xlate-maxline>=I<n> (Default: 0)

Specificați numărul maxim de linii de text care vor fi trimise la API dintr-o singură dată.

Setați această valoare la 1 dacă doriți să traduceți câte o linie pe rând. Această opțiune are prioritate față de opțiunea C<--xlate-maxlen>.

=item B<--xlate-prompt>=I<text>

Specificați un prompt personalizat care să fie trimis motorului de traducere. Această opțiune este disponibilă numai când se folosesc motoare ChatGPT (gpt3, gpt4o, gpt5). Puteți personaliza comportamentul traducerii furnizând instrucțiuni sp...

docs/src/xlate.pod  view on Meta::CPAN

=item * B<gpt5>: gpt-5.5

=back

=item B<--xlate-labor>

=item B<--xlabor>

Instead of calling translation engine, you are expected to work for.
After preparing text to be translated, they are copied to the
clipboard.  You are expected to paste them to the form, copy the
result to the clipboard, and hit return.

=item B<--xlate-to> (Default: C<EN-US>)

Specify the target language.  You can get available languages by
C<deepl languages> command when using B<DeepL> engine.

=item B<--xlate-format>=I<format> (Default: C<conflict>)

Specify the output format for original and translated text.

docs/src/xlate.pod  view on Meta::CPAN


If the format is C<xtxt> (translated text) or unkown, only translated
text is printed.

=back

=item B<--xlate-maxlen>=I<chars> (Default: 0)

Specify the maximum length of text to be sent to the API at once.
Default value is set as for free DeepL account service: 128K for the
API (B<--xlate>) and 5000 for the clipboard interface
(B<--xlate-labor>).  You may be able to change these value if you are
using Pro service.

=item B<--xlate-maxline>=I<n> (Default: 0)

Specify the maximum lines of text to be sent to the API at once.

Set this value to 1 if you want to translate one line at a time.  This
option takes precedence over the C<--xlate-maxlen> option.

lib/App/Greple/xlate.pm  view on Meta::CPAN

=item * B<gpt5>: gpt-5.5

=back

=item B<--xlate-labor>

=item B<--xlabor>

Instead of calling translation engine, you are expected to work for.
After preparing text to be translated, they are copied to the
clipboard.  You are expected to paste them to the form, copy the
result to the clipboard, and hit return.

=item B<--xlate-to> (Default: C<EN-US>)

Specify the target language.  You can get available languages by
C<deepl languages> command when using B<DeepL> engine.

=item B<--xlate-format>=I<format> (Default: C<conflict>)

Specify the output format for original and translated text.

lib/App/Greple/xlate.pm  view on Meta::CPAN


If the format is C<xtxt> (translated text) or unkown, only translated
text is printed.

=back

=item B<--xlate-maxlen>=I<chars> (Default: 0)

Specify the maximum length of text to be sent to the API at once.
Default value is set as for free DeepL account service: 128K for the
API (B<--xlate>) and 5000 for the clipboard interface
(B<--xlate-labor>).  You may be able to change these value if you are
using Pro service.

=item B<--xlate-maxline>=I<n> (Default: 0)

Specify the maximum lines of text to be sent to the API at once.

Set this value to 1 if you want to translate one line at a time.  This
option takes precedence over the C<--xlate-maxlen> option.

lib/App/Greple/xlate.pm  view on Meta::CPAN


option --xlate-setopt --prologue &__PACKAGE__::set($<shift>)

option --xlate-color \
	--postgrep &__PACKAGE__::postgrep \
	--callback &__PACKAGE__::callback \
	--begin    &__PACKAGE__::begin \
	--end      &__PACKAGE__::end
option --xlate --xlate-color --color=never
option --xlate-fold --xlate --xlate-fold-line
option --xlate-labor --xlate --deepl-method=clipboard
option --xlabor --xlate-labor

option --xlate-mask \
	--begin    &__PACKAGE__::begin \
	--callback &__PACKAGE__::mask_string

option --cache-clear --xlate-cache=clear

option --match-all       --re '\A(?s).+\z'
option --match-entire    --match-all

lib/App/Greple/xlate/deepl.pm  view on Meta::CPAN

use App::Greple::xlate qw(%opt &opt);
use App::Greple::xlate::Lang qw(%LANGNAME);

our $lang_from //= 'ORIGINAL';
our $lang_to   //= 'JA';
our $auth_key;
our $method //= 'deepl';

my %param = (
    deepl     => { max => 128 * 1024, sub => \&deepl },
    clipboard => { max => 5000,       sub => \&clipboard },
    );

sub deepl {
    state $deepl = Command::Run->new;
    state $command = do {
	my $glossary = $App::Greple::xlate::glossary;
	my   @c = ('deepl', 'text');
	push @c,  ('--to', $lang_to);
	push @c,  ('--from', $lang_from) if $lang_from ne 'ORIGINAL';
	push @c,  ('--auth-key', $auth_key) if $auth_key;
	push @c,  ('--glossary-id', $glossary) if $glossary;
	if (my @contexts = @{$opt{contexts}}) {
	    push @c, '--context' => join "\n", @contexts;
	}
	\@c;
    };
    $deepl->command(@$command, shift)->update->data;
}

sub clipboard {
    require Clipboard and import Clipboard unless state $called++;
    my $from = shift;
    my $length = length $from;
    Clipboard->copy($from);
    STDERR->printflush(
	"$length characters stored in the clipboard.\n",
	"Translate it to \"$lang_to\" and clip again.\n",
	"Then hit enter: ");
    if (open my $fh, "/dev/tty" or die) {
	my $answer = <$fh>;
    }
    my $to = Clipboard->paste;
    $to = decode('utf8', $to) if not utf8::is_utf8($_);
    return $to;
}

lib/App/xlate.pm  view on Meta::CPAN

   xlate -DMa -t EN-US example.docx

2. Translate to multiple languages and formats:

   xlate -M -o 'xtxt ifdef' -t 'EN-US KO ZH' example.docx

3. Run a command in Docker container:

   xlate -C sdif -V --nocdif example.EN-US.cm

4. Translate without using API (via clipboard):

   xlate -t JA README.md

=head1 SEE ALSO

L<App::Greple::xlate>

L<App::dozo> - Generic Docker runner used by xlate for container operations

=head1 AUTHOR

script/xlate  view on Meta::CPAN

fi

declare -a module option

module+=(-Mxlate)
option+=(--xlate-engine="$engine")
option+=(--xlate-to="$to_lang" --xlate-format="$format" --xlate-cache=yes)
option+=(--all)

[[ ${from_lang:-}  ]] && option+=(--xlate-from "$from_lang")
[[ ${api:-}        ]] || use_clipboard=yes
[[ ${check:-}      ]] || option+=(--xlate${use_clipboard:+-labor})
[[ ${wrap:-}       ]] && option+=(--xlate-fold-line --xlate-fold-width=$wrap)
[[ ${trace:-}      ]] && option+=(-dmo)
[[ ${refresh:-}    ]] && option+=(--xlate-cache=clear)
[[ ${update:-}     ]] && option+=(--xlate-update)
[[ ${silent:-}     ]] && option+=(--no-xlate-progress)
[[ ${maxlen:-}     ]] && option+=(--xlate-maxlen="$maxlen")
[[ ${maskfile:-}   ]] && option+=(--xlate-setopt "maskfile=$maskfile")
[[ ${glossary:-}   ]] && option+=(--xlate-glossary "$glossary")

declare -a area

script/xlate  view on Meta::CPAN

   xlate -DMa -t EN-US example.docx

2. Translate to multiple languages and formats:

   xlate -M -o 'xtxt ifdef' -t 'EN-US KO ZH' example.docx

3. Run a command in Docker container:

   xlate -C sdif -V --nocdif example.EN-US.cm

4. Translate without using API (via clipboard):

   xlate -t JA README.md

=head1 SEE ALSO

L<App::Greple::xlate>

L<App::dozo> - Generic Docker runner used by xlate for container operations

=head1 AUTHOR



( run in 1.499 second using v1.01-cache-2.11-cpan-2398b32b56e )