仓库多语言编辑

This commit is contained in:
2025-05-13 15:29:56 +08:00
parent 21b19109d0
commit 302acbc5ab
6 changed files with 236 additions and 97 deletions
+4 -4
View File
@@ -14,11 +14,11 @@ class TranslatorService
$this->xunfei = new Xunfei();
}
public function vehicle($vehicle, string $targetLang = 'en') {
public function vehicle($vehicle, string $targetLang = 'en', string $fromLang = 'cn') {
$fields = ['brand', 'model', 'purchase_location', 'procedure_location', 'fbo_destination'];
foreach ($vehicle as $k => $var) {
if (in_array($k, $fields)) {
$rst_dst = $this->xunfei->fanyi($var, 'cn', $targetLang);
$rst_dst = $this->xunfei->fanyi($var, $fromLang, $targetLang);
if ($rst_dst) {
$vehicle[$k] = $rst_dst["trans_result"]["dst"];
}
@@ -27,11 +27,11 @@ class TranslatorService
return $vehicle;
}
public function location($location, string $targetLang = 'en') {
public function location($location, string $targetLang = 'en', string $fromLang = 'cn') {
$fields = ['name'];
foreach ($location as $k => $var) {
if (in_array($k, $fields)) {
$rst_dst = $this->xunfei->fanyi($var, 'cn', $targetLang);
$rst_dst = $this->xunfei->fanyi($var, $fromLang, $targetLang);
if ($rst_dst) {
$location[$k] = $rst_dst["trans_result"]["dst"];
}