Skip to content

Commit 74737b8

Browse files
committed
refactor: clean up translator
1 parent 12ea1aa commit 74737b8

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

packages/intl/src/GenericTranslator.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,16 @@ public function __construct(
1919

2020
public function translateForLocale(Locale $locale, string $key, mixed ...$arguments): string
2121
{
22-
$message = $this->catalog->get($locale, $key);
23-
24-
if (! $message) {
25-
$message = $this->catalog->get($this->config->fallbackLocale, $key);
26-
}
27-
28-
if (! $message) {
22+
if (! $this->catalog->has($locale, $key)) {
2923
$this->eventBus?->dispatch(new TranslationMiss(
3024
locale: $locale,
3125
key: $key,
3226
));
27+
}
28+
29+
$message = $this->catalog->get($locale, $key) ?? $this->catalog->get($this->config->fallbackLocale, $key);
3330

31+
if ($message === null) {
3432
return $key;
3533
}
3634

packages/intl/tests/FunctionsTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
66
use PHPUnit\Framework\TestCase;
7-
use Tempest\Intl;
87
use Tempest\Intl\Locale;
98
use Tempest\Intl\Number;
109
use Tempest\Support\Currency;

packages/support/src/Str/functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ function pad_left(string $string, int $totalLength, string $padString = ' '): st
813813
* => 'Yeet'
814814
*
815815
* pad_right('مرحبا', 8, 'ا')
816-
* => 'مرح��اااا'
816+
* => 'مرحباااا'
817817
*
818818
* @param non-empty-string $padString
819819
* @param int<0, max> $totalLength

0 commit comments

Comments
 (0)