luci: update translation for transmit and receive rates; add rate conversion function to fix #9

This commit is contained in:
fujr 2024-12-19 15:36:40 +08:00
parent 33f56dbd6f
commit 4e6f78423f
5 changed files with 23 additions and 6 deletions

View File

@ -355,10 +355,10 @@ msgid "Access Maximum Bit Rate for Downlink"
msgstr "下行链路最大比特率"
msgid "Transmit Rate"
msgstr "传输速率"
msgstr "发送速率"
msgid "Receive Rate"
msgstr "发送速率"
msgstr "接收速率"
msgid "Network Mode"

View File

@ -355,10 +355,10 @@ msgid "Access Maximum Bit Rate for Downlink"
msgstr "下行链路最大比特率"
msgid "Transmit Rate"
msgstr "传输速率"
msgstr "发送速率"
msgid "Receive Rate"
msgstr "发送速率"
msgstr "接收速率"
msgid "Network Mode"

View File

@ -565,8 +565,10 @@ network_info()
add_plain_info_entry "CQI DL" "$cqi_dl" "Channel Quality Indicator for Downlink"
add_plain_info_entry "AMBR UL" "$ambr_ul" "Access Maximum Bit Rate for Uplink"
add_plain_info_entry "AMBR DL" "$ambr_dl" "Access Maximum Bit Rate for Downlink"
add_plain_info_entry "Tx Rate" "$tx_rate B/s" "Transmit Rate"
add_plain_info_entry "Rx Rate" "$rx_rate B/s" "Receive Rate"
rx_rate=$(rate_convert $rx_rate)
tx_rate=$(rate_convert $tx_rate)
add_plain_info_entry "Tx Rate" "$tx_rate" "Transmit Rate"
add_plain_info_entry "Rx Rate" "$rx_rate" "Receive Rate"
}
get_lockband(){

View File

@ -347,3 +347,16 @@ get_reboot_caps()
json_close_object
json_dump
}
rate_convert()
{
local rate=$1
rate_units="bps Kbps Mbps Gbps"
for i in $(seq 0 3); do
if [ $rate -lt 1024 ]; then
break
fi
rate=$(($rate / 1024))
done
echo "$rate `echo $rate_units | cut -d ' ' -f $(($i+1))`"
}

View File

@ -486,6 +486,8 @@ network_info()
add_plain_info_entry "CQI DL" "$cqi_dl" "Channel Quality Indicator for Downlink"
add_plain_info_entry "AMBR UL" "$ambr_ul" "Access Maximum Bit Rate for Uplink"
add_plain_info_entry "AMBR DL" "$ambr_dl" "Access Maximum Bit Rate for Downlink"
rx_rate=$(rate_convert $rx_rate)
tx_rate=$(rate_convert $tx_rate)
add_plain_info_entry "Tx Rate" "$tx_rate" "Transmit Rate"
add_plain_info_entry "Rx Rate" "$rx_rate" "Receive Rate"
}