|
7 | 7 | use Gettext\Loader\PoLoader; |
8 | 8 | use Gettext\Translation; |
9 | 9 | use Gettext\Translations; |
10 | | -use Google\ApiCore\ValidationException; |
11 | 10 | use Google\Cloud\Translate\V3\TranslationServiceClient; |
12 | | -use potrans\commands\DeepLTranslator; |
13 | | -use potrans\commands\GoogleTranslator; |
14 | | -use potrans\commands\ITranslator; |
15 | 11 | use Symfony\Component\Cache\Adapter\FilesystemAdapter; |
16 | | -use Symfony\Component\Cache\Adapter\NullAdapter; |
17 | 12 | use Symfony\Component\Console\Command\Command; |
18 | 13 | use Symfony\Component\Console\Exception\InvalidOptionException; |
19 | 14 | use Symfony\Component\Console\Exception\RuntimeException; |
20 | 15 | use Symfony\Component\Console\Helper\ProgressBar; |
21 | 16 | use Symfony\Component\Console\Input\InputArgument; |
22 | | -use Symfony\Component\Console\Input\InputDefinition; |
23 | 17 | use Symfony\Component\Console\Input\InputInterface; |
24 | 18 | use Symfony\Component\Console\Input\InputOption; |
25 | 19 | use Symfony\Component\Console\Output\OutputInterface; |
26 | | -use Symfony\Contracts\Cache\CacheInterface; |
27 | | -use Symfony\Contracts\Cache\ItemInterface; |
| 20 | +use Throwable; |
28 | 21 |
|
29 | 22 | class GoogleTranslatorCommand extends Command { |
30 | 23 |
|
@@ -113,7 +106,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int |
113 | 106 | // translated counter |
114 | 107 | $translated++; |
115 | 108 |
|
116 | | - $translation = $cache->getItem(md5($sentence->getOriginal())); |
| 109 | + $key = md5($sentence->getOriginal() . $from . $to); |
| 110 | + $translation = $cache->getItem($key); |
117 | 111 |
|
118 | 112 | if (!$translation->isHit() || !$input->getOption('cache')) { |
119 | 113 |
|
@@ -178,7 +172,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int |
178 | 172 | $poGenerator->generateFile($translations, $poOutputFile); |
179 | 173 |
|
180 | 174 | $output->writeln('<info>DONE!</info>'); |
181 | | - } catch (\Throwable $error) { |
| 175 | + } catch (Throwable $error) { |
182 | 176 | $output->writeln( |
183 | 177 | [ |
184 | 178 | '', |
|
0 commit comments