Skip to content

Commit a58032d

Browse files
committed
fix
1 parent 0685234 commit a58032d

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

src/Services/Grammar/OpenAiService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function fixAll(array $texts): array
3838
$content = $response->choices[0]->message->content;
3939
$translations = json_decode($content, true);
4040

41-
return collect($translations)->dot();
41+
return $translations;
4242
})
4343
->toArray();
4444
}

src/Services/Translate/OpenAiService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function translateAll(array $texts, string $targetLocale): array
3838
$content = $response->choices[0]->message->content;
3939
$translations = json_decode($content, true);
4040

41-
return collect($translations)->dot();
41+
return $translations;
4242
})
4343
->toArray();
4444
}

src/Translator.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public function translateTranslations(
127127
): Translations {
128128
$service = $service ?? $this->translateService;
129129

130-
if (! $service) {
130+
if (!$service) {
131131
throw TranslatorServiceException::missingTranslateService();
132132
}
133133

@@ -143,9 +143,10 @@ function (Translations $translations) use ($referenceLocale, $targetLocale, $nam
143143
$referenceTranslations = $this->getTranslations($referenceLocale, $namespace);
144144

145145
$referenceValues = $referenceTranslations
146+
->toBase()
146147
->dot()
147148
->only($keys)
148-
->filter(fn ($value) => ! blank($value))
149+
->filter(fn ($value) => !blank($value))
149150
->toArray();
150151

151152
$translatedValues = $service->translateAll(
@@ -170,16 +171,18 @@ public function fixGrammarTranslations(
170171
): Translations {
171172
$service = $service ?? $this->grammarService;
172173

173-
if (! $service) {
174+
if (!$service) {
174175
throw TranslatorServiceException::missingGrammarService();
175176
}
176177

177178
return $this->transformTranslations($locale, $namespace, function (Translations $translations) use ($service, $keys) {
178179

179180
$fixedTranslations = $service->fixAll(
180-
texts: $translations->dot()
181+
texts: $translations
182+
->toBase()
183+
->dot()
181184
->only($keys)
182-
->filter(fn ($value) => ! blank($value))
185+
->filter(fn ($value) => !blank($value))
183186
->toArray()
184187
);
185188

0 commit comments

Comments
 (0)