ozzyczech / potrans Goto Github PK
View Code? Open in Web Editor NEWCommand line tool for translate Gettext with Google Translator API or DeepL API
License: MIT License
Command line tool for translate Gettext with Google Translator API or DeepL API
License: MIT License
Hello,
I followed all needed steps to set up POTRANS but when I run it like this :
php bin/potrans -k 1234567890 -i fr_FR.po -o fr_FR_trans.po -f en -t fr
Translating : 1512 entries from en to fr
It dumps this error:
Error "Server Error #403: "
What does it mean and how to fix this?
I tried the 'sleep(1)' hint from another thread but this does not help at all.
Thanks for your precious help
Hacen
The endpoint used for DeepL Pro is different from the one used for free accounts.
i.e. instead of
https://api.deepl.com/v2/translate
Currently, trying to use the free endpoint with an authentication key for a pro account results in an error (which unfortunately causes potrans to fail silently and generate all translations in the from
language).
There should be a flag to choose which endpoint to use, or even have potrans automatically change endpoints if one of them fails.
I dont like to check in my apikey to me repo in order to automate the translations using deepl
could there be an option to read the apikey from either env or a file?
Hi, thanks for this tool! Unfortunately, trying to run it for separate languages without disabling the cache doesn't work. This is because it reuses the previous language's cache, even though the --to=
option was changed to something else.
ERROR: Gettext\Translation::translate(): Argument #1 ($translation) must be of type string, null given, called in vendor\om\potrans\src\commands\DeepLTranslatorCommand.php on line 121 on vendor\gettext\gettext\src\Translation.php at 173
if you run a command like:
php vendor/bin/potrans deepl --apikey=XXX --from=en-us --to=sv test.po out
I accidentally wrote en-us
in the from
Currently I'm working on very similar project to this project.
I have recommendations if you didn't already made:
Hello OzzyCzech
I get the following:
$potrans -k -i ~/Downloads/health_inpatient.pot -o health_inpatient-id.pot -f en -t id
Translating : 345 entries from en to id
Error "Server Error #403:
Arch linux is now on php version 7
php -v
PHP 7.0.5 (cli) (built: Mar 29 2016 18:07:10) ( NTS )
But I also have:
$ php56 -v
PHP 5.6.20 (cli) (built: Apr 23 2016 11:45:06)
I followed the instructions for both php and php56 but in both cases the error is the same.
Changing the install slightly, I then changed 'composer install' to php56 composer.phar install.
Still the error was the same
Thanks for the app by the way.
Best wishes
ERROR: SSL certificate problem: unable to get local issuer certificate on C:\********\vendor\deeplcom\deepl-php\src\HttpClientWrapper.php at 336
How to fix this?
Hi I enabled Cloud Translation API and created an API key to try but I'm getting Error "Server Error #400: "
When I try to run potrans, it doesn't get the credentials :
javier@jm:~/proyectos/utilitarios/traducciones/potrans$ php bin/potrans google newsletter-es_AR.po /tmp/translated --cedentials=fast-flight-404720-e573841b9844.json --from=en --to=es -vvv
In ArgvInput.php line 223:
[Symfony\Component\Console\Exception\RuntimeException]
The "--cedentials" option does not exist.
Exception trace:
at /home/javier/proyectos/utilitarios/traducciones/potrans/vendor/symfony/console/Input/ArgvInput.php:223
Symfony\Component\Console\Input\ArgvInput->addLongOption() at /home/javier/proyectos/utilitarios/traducciones/potrans/vendor/symfony/console/Input/ArgvInput.php:150
Symfony\Component\Console\Input\ArgvInput->parseLongOption() at /home/javier/proyectos/utilitarios/traducciones/potrans/vendor/symfony/console/Input/ArgvInput.php:85
Symfony\Component\Console\Input\ArgvInput->parseToken() at /home/javier/proyectos/utilitarios/traducciones/potrans/vendor/symfony/console/Input/ArgvInput.php:74
Symfony\Component\Console\Input\ArgvInput->parse() at /home/javier/proyectos/utilitarios/traducciones/potrans/vendor/symfony/console/Input/Input.php:56
Symfony\Component\Console\Input\Input->bind() at /home/javier/proyectos/utilitarios/traducciones/potrans/vendor/symfony/console/Command/Command.php:285
Symfony\Component\Console\Command\Command->run() at /home/javier/proyectos/utilitarios/traducciones/potrans/vendor/symfony/console/Application.php:1078
Symfony\Component\Console\Application->doRunCommand() at /home/javier/proyectos/utilitarios/traducciones/potrans/vendor/symfony/console/Application.php:324
Symfony\Component\Console\Application->doRun() at /home/javier/proyectos/utilitarios/traducciones/potrans/vendor/symfony/console/Application.php:175
Symfony\Component\Console\Application->run() at /home/javier/proyectos/utilitarios/traducciones/potrans/src/commands/index.php:22
require() at /home/javier/proyectos/utilitarios/traducciones/potrans/bin/potrans:3
google [--from FROM] [--to TO] [--force] [--wait WAIT] [--credentials CREDENTIALS] [--project PROJECT] [--location LOCATION] [--translator [TRANSLATOR]] [--cache|--no-cache] [--] []
javier@jm:~/proyectos/utilitarios/traducciones/potrans$
Any clue to help me find a solution will be appreciated. Thanks.
Original string:
"I have $number$ apples in my $recipient$"
Desired translated string:
"Tengo $number$ manzanas en mi $recipient$"
Actual translated string:
"Tengo $número$ manzanas en mi $recipiente$"
The issue is the DeepL is also translating the $number$
and $recipient$
, which I would like to specify as ignored (for example with the regex \$[^$]+\$
)
Under the hood, you would search for the specified regex, add opening/closing XML tags around matching substrings with preg_replace
(such as <keep></keep>
), and specify those tags when doing the API call: https://www.deepl.com/docs-api/xml/ignored-tags/ And then remove the tags after receiving the translated string.
On line 12 of potranscli.php it references this:
require_once __DIR__ . '/../vendor/autoload.php';
But that has no reference, there is no autoloader.php file inside of the root of the project. Unless I'm missing something, either you need to add one or use the default one with composer.
The vendor root is at least three levels above this one, (vendor/om/src/potranscli.php), so the correct path should be:
require_once __DIR__ . '/../../../autoload.php';
Encountered that error:
Allowed memory size of 134217728 bytes exhausted (tried to allocate 72 bytes) in /Users/vendor/sepia/po-parser/src/Sepia/PoParser.php on line 115
/Users/pierreslam/Desktop/phpa/bin/potrans -k AIzaSyA1AoJH_kigEavzw7DECCwf0jhW7_QAeTQ -i django.po -o django-gt.po -t zh
There is an issue with join()
function https://www.php.net/manual/en/function.join.php
Waiting for merge PR: wp-cli/php-cli-tools#142
vendor/bin/potrans --apikey "123456" --input ./tests/example-cs_CZ.po --verbose --output ./tests/out.po
Fatal error: Uncaught TypeError: join(): Argument #2 ($array) must be of type ?array, string given in /Volumes/Work/test/vendor/wp-cli/php-cli-tools/lib/cli/Arguments.php:485
Stack trace:
#0 /Volumes/Work/test/vendor/wp-cli/php-cli-tools/lib/cli/Arguments.php(485): join(Array, ' ')
#1 /Volumes/Work/test/vendor/wp-cli/php-cli-tools/lib/cli/Arguments.php(401): cli\Arguments->_parseOption(Object(cli\arguments\Argument))
#2 /Volumes/Work/test/vendor/om/potrans/src/potrans.php(44): cli\Arguments->parse()
#3 /Volumes/Work/test/vendor/om/potrans/bin/potrans(3): require('/Volumes/Work/t...')
#4 {main}
thrown in /Volumes/Work/test/vendor/wp-cli/php-cli-tools/lib/cli/Arguments.php on line 485
PS: can be temporary fixed by swapping args in vendor/wp-cli/php-cli-tools/lib/cli/Arguments.php
on line 485
I've installed potrans with composer require --dev om/potrans:dev-master
, and it installed to my project's vendor directory at ./lib/vendor/om/potrans/
. When I run ./lib/vendor/om/potrans/bin/potrans
it throws the following errors because it is unable to find the autoload.php script:
Warning: require_once(/Users/me/src/lda-prenotare/lib/vendor/om/potrans/src/../vendor/autoload.php): failed to open stream: No such file or directory in /Users/q/src/lda-prenotare/lib/vendor/om/potrans/src/potranscli.php on line 12
Fatal error: require_once(): Failed opening required '/Users/me/src/lda-prenotare/lib/vendor/om/potrans/src/../vendor/autoload.php' (include_path='.') in /Users/me/src/lda-prenotare/lib/vendor/om/potrans/src/potranscli.php on line 12
The path to my composer autoload.php file is ./lib/vendor/autoload.php
.
The fix would be to change line 12 in om/potrans/src/potranscli.php
from:
require_once __DIR__ . '/../vendor/autoload.php';
to:
require_once __DIR__ . '/../../../autoload.php';
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.