Files
2026-01-01 04:27:28 +08:00

33 lines
728 B
Bash

#!/bin/sh
#
# Copyright (C) 2025 sirpdboy herboy2008@gmail.com https://github.com/sirpdboy/luci-app-timecontrol
#
logfile="/var/log/timecontrol.log"
lang=$(uci get luci.main.lang 2>/dev/null)
if [ -z "$lang" ] || [[ "$lang" == "auto" ]]; then
lang=$(echo "${LANG:-${LANGUAGE:-${LC_ALL:-${LC_MESSAGES:-zh_cn}}}}" | awk -F'[ .@]' '{print tolower($1)}' | sed 's/-/_/' 2>/dev/null)
fi
translate() {
# 处理特殊字符
local lua_script=$(cat <<LUA
require "luci.i18n".setlanguage("$lang")
print(require "luci.i18n".translate([==[$1]==]))
LUA
)
lua -e "$lua_script"
}
if [ "$1" == "clear_log" ]; then
# 清空日志
>"${logfile}"
elif [ "$1" == "child" ]; then
shift
command_name=$1
shift
"$command_name" "$@"
fi