Skip to content

Commit

Permalink
Merge pull request #31 from Laravel-Lang/1.x
Browse files Browse the repository at this point in the history
Corrected the column name to be more obvious (before it's too late 😅)
  • Loading branch information
andrey-helldar authored Jun 28, 2024
2 parents b4a95aa + 3c16ab5 commit 3140063
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions config/public.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,15 @@
'google' => [
'translator' => '\LaravelLang\Translator\Integrations\Google',

'enabled' => (bool) env('TRANSLATION_GOOGLE_ENABLED', true),
'order' => (int) env('TRANSLATION_GOOGLE_ORDER', 1),
'enabled' => (bool) env('TRANSLATION_GOOGLE_ENABLED', true),
'priority' => (int) env('TRANSLATION_GOOGLE_PRIORITY', 1),
],

'deepl' => [
'translator' => '\LaravelLang\Translator\Integrations\Deepl',

'enabled' => (bool) env('TRANSLATION_DEEPL_ENABLED', false),
'order' => (int) env('TRANSLATION_DEEPL_ORDER', 2),
'enabled' => (bool) env('TRANSLATION_DEEPL_ENABLED', false),
'priority' => (int) env('TRANSLATION_DEEPL_PRIORITY', 2),

'credentials' => [
'key' => env('TRANSLATION_DEEPL_KEY'),
Expand All @@ -203,8 +203,8 @@
'yandex' => [
'translator' => '\LaravelLang\Translator\Integrations\Yandex',

'enabled' => (bool) env('TRANSLATION_YANDEX_ENABLED', false),
'order' => (int) env('TRANSLATION_YANDEX_ORDER', 3),
'enabled' => (bool) env('TRANSLATION_YANDEX_ENABLED', false),
'priority' => (int) env('TRANSLATION_YANDEX_PRIORITY', 3),

'credentials' => [
'key' => env('TRANSLATION_YANDEX_KEY'),
Expand Down
2 changes: 1 addition & 1 deletion src/Data/Shared/Translators/TranslatorData.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ public function __construct(
public bool $enabled,
public string $translator,
public array $credentials = [],
public int $order = 0,
public int $priority = 0,
) {}
}
4 changes: 2 additions & 2 deletions src/Services/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ protected function getTranslators(): array
enabled : $item['enabled'] ?? true,
translator : $item['translator'],
credentials: $item['credentials'] ?? [],
order : $item['order'] ?? 0
priority : $item['priority'] ?? 0
)
)->sortBy(fn (TranslatorData $item) => $item->order)->all();
)->sortBy(fn (TranslatorData $item) => $item->priority)->all();
}

protected function value(
Expand Down
12 changes: 6 additions & 6 deletions tests/Unit/SharedWithEnvTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
putenv('LOCALIZATION_SMART_ENABLED=true');

config()->set(Name::Shared() . '.translators.channels.google.enabled', false);
config()->set(Name::Shared() . '.translators.channels.google.order', 5);
config()->set(Name::Shared() . '.translators.channels.google.priority', 5);

config()->set(Name::Shared() . '.translators.channels.deepl.enabled', true);
config()->set(Name::Shared() . '.translators.channels.deepl.order', 6);
config()->set(Name::Shared() . '.translators.channels.deepl.priority', 6);
config()->set(Name::Shared() . '.translators.channels.deepl.credentials.key', 'qwerty123');

config()->set(Name::Shared() . '.translators.channels.yandex.enabled', true);
config()->set(Name::Shared() . '.translators.channels.yandex.order', 7);
config()->set(Name::Shared() . '.translators.channels.yandex.priority', 7);
config()->set(Name::Shared() . '.translators.channels.yandex.credentials.key', 'qwerty456');
config()->set(Name::Shared() . '.translators.channels.yandex.credentials.folder', '123');
});
Expand Down Expand Up @@ -129,14 +129,14 @@
expect(Config::shared()->translators->channels->all['google'])
->toBeInstanceOf(TranslatorData::class)
->enabled->toBeFalse()
->order->toBe(5)
->priority->toBe(5)
->translator->toBe('\LaravelLang\Translator\Integrations\Google')
->credentials->toBeEmpty();

expect(Config::shared()->translators->channels->all['deepl'])
->toBeInstanceOf(TranslatorData::class)
->enabled->toBeTrue()
->order->toBe(6)
->priority->toBe(6)
->translator->toBe('\LaravelLang\Translator\Integrations\Deepl')
->credentials->toBe([
'key' => 'qwerty123',
Expand All @@ -145,7 +145,7 @@
expect(Config::shared()->translators->channels->all['yandex'])
->toBeInstanceOf(TranslatorData::class)
->enabled->toBeTrue()
->order->toBe(7)
->priority->toBe(7)
->translator->toBe('\LaravelLang\Translator\Integrations\Yandex')
->credentials->toBe([
'key' => 'qwerty456',
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/SharedWithoutEnvTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@
expect(Config::shared()->translators->channels->all['google'])
->toBeInstanceOf(TranslatorData::class)
->enabled->toBeTrue()
->order->toBe(1)
->priority->toBe(1)
->translator->toBe('\LaravelLang\Translator\Integrations\Google')
->credentials->toBeEmpty();

expect(Config::shared()->translators->channels->all['deepl'])
->toBeInstanceOf(TranslatorData::class)
->enabled->toBeFalse()
->order->toBe(2)
->priority->toBe(2)
->translator->toBe('\LaravelLang\Translator\Integrations\Deepl')
->credentials->toBe([
'key' => null,
Expand All @@ -133,7 +133,7 @@
expect(Config::shared()->translators->channels->all['yandex'])
->toBeInstanceOf(TranslatorData::class)
->enabled->toBeFalse()
->order->toBe(3)
->priority->toBe(3)
->translator->toBe('\LaravelLang\Translator\Integrations\Yandex')
->credentials->toBe([
'key' => null,
Expand Down

0 comments on commit 3140063

Please sign in to comment.