CaiWuXiTong/app/Traits/Translations.php
WuYongJie 9595267ee7
Some checks failed
Tests / PHP 8.1 (push) Has been cancelled
Tests / PHP 8.2 (push) Has been cancelled
Tests / PHP 8.3 (push) Has been cancelled
chore: 导入 Akaunting 初始源码与团队协作规则
2026-07-20 18:20:25 +08:00

42 lines
826 B
PHP

<?php
namespace App\Traits;
use Throwable;
use Illuminate\Support\Arr;
trait Translations
{
public function findTranslation($keys, $number = 2)
{
if (is_callable($keys)) {
return $keys();
}
$keys = Arr::wrap($keys);
try {
foreach ($keys as $key) {
if (is_array($key)) {
$tmp = $key;
$key = $tmp[0];
$number = $tmp[1];
}
if ($key != trans_choice($key, $number)) {
return trans_choice($key, $number);
}
if ($key != trans($key)) {
return trans($key);
}
}
} catch (Throwable $e) {
return '';
}
return '';
}
}