This commit is contained in:
你的名字
2025-07-14 10:22:40 +08:00
commit 0483b4b364
1388 changed files with 219353 additions and 0 deletions

26
application/common.php Normal file
View File

@ -0,0 +1,26 @@
<?php
if (!function_exists('json_lang')) {
/**
* 从 JSON 文件中加载语言包
*
* @param string $key 语言包的键
* @param string $lang 语言类型,默认为当前语言
* @return mixed 返回对应的语言值
*/
function json_lang($key, $lang = '') {
$lang = \think\facade\Lang::detect();
// 拼接文件路径
$filePath = '../application/lang' . DIRECTORY_SEPARATOR . $lang . '.json';
// 判断文件是否存在
if (file_exists($filePath)) {
// 读取 JSON 文件并解析为数组
$data = json_decode(file_get_contents($filePath), true);
if (isset($data[$key])) {
return $data[$key];
}
}
// 如果没有找到对应的键,则返回原始键
return $key;
}
}