Giter Club home page Giter Club logo

potrans's Issues

Error "Server Error #403: "

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

Allow using non-free DeepL api endpoint [bug]

The endpoint used for DeepL Pro is different from the one used for free accounts.

i.e. instead of

curl_setopt($curl, CURLOPT_URL, 'https://api-free.deepl.com/v2/translate');

it should be
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.

read deepl apikey from file or env

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?

Cache doesn't take into account changed language

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.

Argument #1 ($translation) must be of type string, null given

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

Feature recommendations

Currently I'm working on very similar project to this project.
I have recommendations if you didn't already made:

  • Saving old translations in another file and only translate new words. So this can save money for paid Google service.
  • Not connecting translate API for every string. Making 20-30 string chunks and request 20 string translate at a time. So lowering network request.
  • Making an option for full translate of po file or translating only new words.

Error "Server Error #403: "

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 "Server Error #400: "

Hi I enabled Cloud Translation API and created an API key to try but I'm getting Error "Server Error #400: "

Command "newsletter-es_AR.po" is not defined

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.

Add option for DeepL to ignore certain substrings matched by regex

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.

Correct autoload?

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';

Known Fatal error with join() function

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

Invalid path to autoload.php

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';

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.