Ver código fonte

translate fix

Andrew 2 meses atrás
pai
commit
e0ea5c6ab2
1 arquivos alterados com 4 adições e 16 exclusões
  1. 4
    16
      app/Service/DeepLService.php

+ 4
- 16
app/Service/DeepLService.php Ver arquivo

@@ -46,28 +46,16 @@ class DeepLService {
46 46
         return Action::make("translate{$actionName}")
47 47
             ->label("翻譯")
48 48
             ->visible(fn ($arguments) => $arguments['locale'] != 'zh_TW')
49
-            ->action(function ($set, $get, $arguments, $component) use ($fieldNames) {
50
-
49
+            ->action(function ($set, $get, $arguments) use ($fieldNames) {
51 50
                 $locale = $arguments['locale'] ?? null;
52 51
                 if (!$locale) {
53 52
                     return;
54 53
                 }
55
-
56
-                // Get the current repeater item’s state path (e.g., "spaceInfos.1")
57
-                $itemPath = $component->getContainer()->getStatePath();
58
-
59
-                foreach ($fieldNames as $fieldName) {
60
-
61
-                    // Get value inside the specific repeater item
62
-                    $source = $get("{$itemPath}.{$fieldName}.zh_TW");
63
-
64
-                    $translated = $this->translateWordings($source, $locale);
65
-
66
-                    // Set translated value back into this repeater item
67
-                    $set("{$itemPath}.{$fieldName}.{$locale}", $translated);
54
+                foreach($fieldNames as $fieldName){
55
+                    $translateText = $this->translateWordings($get("{$fieldName}.zh_TW"), $locale);
56
+                    $set("{$fieldName}.{$locale}", $translateText);
68 57
                 }
69 58
             });
70
-
71 59
     }
72 60
 
73 61
     public function buildGlossary($glossaryName, $glossaryLocaleFrom, $glossaryLocaleTo, $glossaryItems){