Skip to content

Commit

Permalink
cascade options
Browse files Browse the repository at this point in the history
  • Loading branch information
datashaman committed Aug 17, 2024
1 parent b1cb539 commit 9f84639
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 4 additions & 2 deletions config/translators.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@
],

'google-v2' => [
'project' => env('TRANSLATORS_GOOGLE_KEY'),
'construct' => [
'keyFilePath' => env('TRANSLATORS_GOOGLE_KEY_FILE', base_path('keys/google.json')),
],
'options' => [
'format' => 'text',
],
],

'google-v3' => [
'project' => env('TRANSLATORS_GOOGLE_PROJECT'),
'project' => env('TRANSLATORS_GOOGLE_PROJECT', env('GOOGLE_CLOUD_PROJECT')),
'options' => [],
],

Expand Down
5 changes: 1 addition & 4 deletions src/LaravelTranslatorsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ public function register(): void
$this->app->singleton(Client::class, fn () => OpenAI::client(config('translators.services.openai.api_key')));
}

$this->app->singleton(TranslateClient::class, fn () => new TranslateClient([
'key' => config('translators.services.google-v2.key'),
]));

$this->app->singleton(TranslateClient::class, fn () => new TranslateClient(config('translators.services.google-v2.construct')))
$this->app->singleton(Translator::class, fn () => new Translator(config('translators.services.deepl.api_key')));
$this->app->singleton('translator-manager', fn ($app) => new TranslatorManager($app));
}
Expand Down
1 change: 1 addition & 0 deletions src/Translators/GoogleV2Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Datashaman\LaravelTranslators\Translators;

use Datashaman\LaravelTranslators\Contracts\TranslatorInterface;
use Google\Cloud\Translate\V2\TranslateClient;

class GoogleV2Translator implements TranslatorInterface
{
Expand Down

0 comments on commit 9f84639

Please sign in to comment.