From 0e3e0b4147f17b1a18cf608f21c9a9c3989fe3f8 Mon Sep 17 00:00:00 2001 From: coolsnowwolf Date: Sat, 6 Oct 2018 21:30:00 +0800 Subject: [PATCH] re-add default-settings --- include/kernel.mk | 1 + package/lean/default-settings/Makefile | 49 + .../files/zzz-default-settings | 69 ++ .../default-settings/i18n/default.zh-cn.po | 32 + .../lean/default-settings/i18n/more.zh-cn.po | 1037 +++++++++++++++++ .../lean/default-settings/i18n/sqm.zh-cn.po | 203 ++++ .../default-settings/tools/po2lmo/Makefile | 12 + .../default-settings/tools/po2lmo/src/po2lmo | Bin 0 -> 17424 bytes .../tools/po2lmo/src/po2lmo.c | 247 ++++ .../tools/po2lmo/src/template_lmo.c | 328 ++++++ .../tools/po2lmo/src/template_lmo.h | 92 ++ 11 files changed, 2070 insertions(+) create mode 100644 package/lean/default-settings/Makefile create mode 100755 package/lean/default-settings/files/zzz-default-settings create mode 100644 package/lean/default-settings/i18n/default.zh-cn.po create mode 100644 package/lean/default-settings/i18n/more.zh-cn.po create mode 100644 package/lean/default-settings/i18n/sqm.zh-cn.po create mode 100644 package/lean/default-settings/tools/po2lmo/Makefile create mode 100644 package/lean/default-settings/tools/po2lmo/src/po2lmo create mode 100644 package/lean/default-settings/tools/po2lmo/src/po2lmo.c create mode 100644 package/lean/default-settings/tools/po2lmo/src/template_lmo.c create mode 100644 package/lean/default-settings/tools/po2lmo/src/template_lmo.h diff --git a/include/kernel.mk b/include/kernel.mk index c169550f4..ecd69a69e 100644 --- a/include/kernel.mk +++ b/include/kernel.mk @@ -254,6 +254,7 @@ $(call KernelPackage/$(1)/config) $$(eval $$(call BuildPackage,kmod-$(1))) $$(IPKG_kmod-$(1)): $$(wildcard $$(FILES)) + endef version_filter=$(if $(findstring @,$(1)),$(shell $(SCRIPT_DIR)/package-metadata.pl version_filter $(KERNEL_PATCHVER) $(1)),$(1)) diff --git a/package/lean/default-settings/Makefile b/package/lean/default-settings/Makefile new file mode 100644 index 000000000..b425d85f1 --- /dev/null +++ b/package/lean/default-settings/Makefile @@ -0,0 +1,49 @@ +# +# Copyright (C) 2016-2017 GitHub +# +# This is free software, licensed under the GNU General Public License v3. +# See /LICENSE for more information. + +include $(TOPDIR)/rules.mk + +PKG_NAME:=default-settings +PKG_VERSION:=1.0 +PKG_RELEASE:=58 +PKG_LICENSE:=GPLv3 +PKG_LICENSE_FILES:=LICENSE + +PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) + +include $(INCLUDE_DIR)/package.mk + +define Package/default-settings + SECTION:=luci + CATEGORY:=LuCI + TITLE:=LuCI support for Default Settings + PKGARCH:=all + DEPENDS:=+@LUCI_LANG_zh-cn +endef + +define Package/default-settings/description + Language Support Packages. +endef + +define Build/Prepare + $(foreach po,$(wildcard ${CURDIR}/i18n/*.po), \ + po2lmo $(po) $(PKG_BUILD_DIR)/$(patsubst %.po,%.lmo,$(notdir $(po)));) +endef + +define Build/Configure +endef + +define Build/Compile +endef + +define Package/default-settings/install + $(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n + $(INSTALL_DIR) $(1)/etc/uci-defaults + $(INSTALL_DATA) $(PKG_BUILD_DIR)/*.lmo $(1)/usr/lib/lua/luci/i18n/ + $(INSTALL_BIN) ./files/zzz-default-settings $(1)/etc/uci-defaults/99-default-settings +endef + +$(eval $(call BuildPackage,default-settings)) diff --git a/package/lean/default-settings/files/zzz-default-settings b/package/lean/default-settings/files/zzz-default-settings new file mode 100755 index 000000000..744018343 --- /dev/null +++ b/package/lean/default-settings/files/zzz-default-settings @@ -0,0 +1,69 @@ +#!/bin/sh + +uci set luci.main.lang=zh_cn +uci commit luci + +uci set system.@system[0].hostname=OpenWrt +uci set system.@system[0].timezone=CST-8 +uci set system.@system[0].zonename=Asia/Shanghai +uci commit system + +uci set fstab.@global[0].anon_mount=1 +uci commit fstab + +rm -f /usr/lib/lua/luci/view/admin_status/index/mwan.htm +rm -f /usr/lib/lua/luci/view/admin_status/index/upnp.htm +rm -f /usr/lib/lua/luci/view/admin_status/index/ddns.htm +rm -f /usr/lib/lua/luci/view/admin_status/index/minidlna.htm + +sed -i 's/\"services\"/\"nas\"/g' /usr/lib/lua/luci/controller/aria2.lua +sed -i 's/services/nas/g' /usr/lib/lua/luci/view/aria2/overview_status.htm +sed -i 's/\"services\"/\"nas\"/g' /usr/lib/lua/luci/controller/hd_idle.lua +sed -i 's/\"services\"/\"nas\"/g' /usr/lib/lua/luci/controller/samba.lua +sed -i 's/\"services\"/\"nas\"/g' /usr/lib/lua/luci/controller/minidlna.lua +sed -i 's/\"services\"/\"nas\"/g' /usr/lib/lua/luci/controller/transmission.lua +sed -i 's/\"services\"/\"nas\"/g' /usr/lib/lua/luci/controller/mjpg-streamer.lua +sed -i 's/\"services\"/\"nas\"/g' /usr/lib/lua/luci/controller/p910nd.lua +sed -i 's/\"services\"/\"nas\"/g' /usr/lib/lua/luci/controller/usb_printer.lua +sed -i 's/\"services\"/\"nas\"/g' /usr/lib/lua/luci/controller/xunlei.lua + +sed -i 's/services/nas/g' /usr/lib/lua/luci/view/minidlna_status.htm +uci set minidlna.config.enabled=0 +uci commit minidlna +/etc/init.d/minidlna stop + +ln -sf /sbin/ip /usr/bin/ip + +rm -rf /tmp/luci-modulecache/ +rm -f /tmp/luci-indexcache + +sed -i 's/downloads.openwrt.org/openwrt.proxy.ustclug.org/g' /etc/opkg/distfeeds.conf +sed -i 's/root::0:0:99999:7:::/root:$1$V4UetPzk$CYXluq4wUazHjmCDBCqXF.:0:0:99999:7:::/g' /etc/shadow + +sed -i "s/# //g" /etc/opkg/distfeeds.conf + +uci set dhcp.@dnsmasq[0].cachesize='1024' +uci set dhcp.lan.ra='hybrid' +uci set dhcp.lan.dhcpv6='hybrid' +uci set dhcp.lan.ndp='hybrid' +uci commit dhcp + +sed -i '/REDIRECT --to-ports 53/d' /etc/firewall.user +echo "iptables -t nat -A PREROUTING -p udp --dport 53 -j REDIRECT --to-ports 53" >> /etc/firewall.user +echo "iptables -t nat -A PREROUTING -p tcp --dport 53 -j REDIRECT --to-ports 53" >> /etc/firewall.user + +sed -i '/option disabled/d' /etc/config/wireless +sed -i '/set wireless.radio${devidx}.disabled/d' /lib/wifi/mac80211.sh +wifi up + +sed -i '/DISTRIB_REVISION/d' /etc/openwrt_release +echo "DISTRIB_REVISION='R8.1.6 By Lean'" >> /etc/openwrt_release +sed -i '/DISTRIB_DESCRIPTION/d' /etc/openwrt_release +echo "DISTRIB_DESCRIPTION='OpenWrt '" >> /etc/openwrt_release + +sed -i 's/cbi.submit\"] = true/cbi.submit\"] = \"1\"/g' /usr/lib/lua/luci/dispatcher.lua + +exit 0 + + + diff --git a/package/lean/default-settings/i18n/default.zh-cn.po b/package/lean/default-settings/i18n/default.zh-cn.po new file mode 100644 index 000000000..aedabf1ae --- /dev/null +++ b/package/lean/default-settings/i18n/default.zh-cn.po @@ -0,0 +1,32 @@ +msgid "Processor" +msgstr "处理器" + +msgid "Architecture" +msgstr "架构" + +msgid "CPU Temperature" +msgstr "CPU温度" + +msgid "CPU Info" +msgstr "CPU信息" + +msgid "CPU Model" +msgstr "处理器型号" + +msgid "CPU frequency" +msgstr "CPU频率" + +msgid "RAM frequency" +msgstr "RAM频率" + +msgid "Flash Size" +msgstr "闪存大小" + +msgid "Free Memory" +msgstr "释放内存" + +msgid "RUNNING" +msgstr "运行中" + +msgid "NOT RUNNING" +msgstr "未运行" diff --git a/package/lean/default-settings/i18n/more.zh-cn.po b/package/lean/default-settings/i18n/more.zh-cn.po new file mode 100644 index 000000000..c602be14c --- /dev/null +++ b/package/lean/default-settings/i18n/more.zh-cn.po @@ -0,0 +1,1037 @@ +msgid "" +msgstr "" +"Content-Type: text/plain; charset=UTF-8\n" +"Last-Translator: Hsing-Wang Liao \n" + +msgid "%d hour" +msgstr "%d 小时" + +msgid "%d minute" +msgstr "%d 分钟" + +msgid "%d minutes" +msgstr "%d 分钟" + +msgid "%d second" +msgstr "%d 秒" + +msgid "%d seconds" +msgstr "%d 秒" + +msgid "" +"Acceptable values: 1-100. This many Tracking IP addresses must respond for " +"the link to be deemed up" +msgstr "" +"取值范围: 1-100。这个设置项指定了当多少个 IP 地址能够连通时接口会被认为在线" + +msgid "Acceptable values: 1-1000. Defaults to 1 if not set" +msgstr "取值范围: 1-100。如果不填写,默认值为 1" + +msgid "Advanced" +msgstr "高级" + +msgid "Check IP rules" +msgstr "检查 IP 规则" + +msgid "Check routing table" +msgstr "检查路由表" + +msgid "Collecting data..." +msgstr "正在收集数据..." + +msgid "Configuration" +msgstr "配置" + +msgid "Currently Configured Interfaces" +msgstr "当前配置的接口" + +msgid "Currently Configured Members" +msgstr "当前配置的成员" + +msgid "Currently Configured Policies" +msgstr "当前配置的策略" + +msgid "Destination address" +msgstr "目标地址" + +msgid "Destination port" +msgstr "目标端口" + +msgid "Detailed Status" +msgstr "详细状态" + +msgid "Diagnostic Results" +msgstr "诊断结果" + +msgid "Diagnostics" +msgstr "诊断" + +msgid "Disabled" +msgstr "禁用" + +msgid "" +"Downed interface will be deemed up after this many successful ping tests" +msgstr "当 Ping 成功次数达到这个数值后,已经被认为离线的接口将会重新上线" + +msgid "Enabled" +msgstr "启用" + +msgid "Error collecting troubleshooting information" +msgstr "收集故障排除信息时出错" + +msgid "Errors" +msgstr "错误" + +msgid "Failure interval" +msgstr "故障检测间隔" + +msgid "Flush conntrack table" +msgstr "刷新连接跟踪表" + +msgid "Flush global firewall conntrack table on interface events" +msgstr "在接口事件触发时刷新全局防火墙连接跟踪表" + +msgid "Hotplug Script" +msgstr "Hotplug 脚本" + +msgid "Hotplug ifdown" +msgstr "Hotplug ifdown" + +msgid "Hotplug ifup" +msgstr "Hotplug ifup" + +msgid "IPset" +msgstr "IPset" + +msgid "IPv4" +msgstr "IPv4" + +msgid "IPv6" +msgstr "IPv6" + +msgid "Interface" +msgstr "接口" + +msgid "Interface Status" +msgstr "接口状态" + +msgid "Interface down" +msgstr "接口离线" + +msgid "Interface up" +msgstr "接口上线" + +msgid "Interface will be deemed down after this many failed ping tests" +msgstr "当 Ping 失败次数达到这个数值后接口会被认为离线" + +msgid "Interfaces" +msgstr "接口" + +msgid "Internet Protocol" +msgstr "互联网协议" + +msgid "Last 50 MWAN systemlog entries. Newest entries sorted at the top :" +msgstr "最近 50 条 MWAN 系统日志,最新条目排在顶部:" + +msgid "Last resort" +msgstr "备用成员" + +msgid "Load Balancing" +msgstr "负载均衡" + +msgid "Loading" +msgstr "载入中" + +msgid "MWAN Config" +msgstr "MWAN 配置文件" + +msgid "MWAN Detailed Status" +msgstr "MWAN 详细状态" + +msgid "MWAN Interface Configuration" +msgstr "MWAN 接口配置" + +msgid "MWAN Interface Configuration - %s" +msgstr "MWAN 接口配置 - %s" + +msgid "MWAN Interface Diagnostics" +msgstr "MWAN 接口诊断" + +msgid "MWAN Interface Live Status" +msgstr "MWAN 接口实时状态" + +msgid "MWAN Interface Systemlog" +msgstr "MWAN 接口系统日志" + +msgid "MWAN Member Configuration" +msgstr "MWAN 成员配置" + +msgid "MWAN Member Configuration - %s" +msgstr "MWAN 成员配置 - %s" + +msgid "MWAN Policy Configuration" +msgstr "MWAN 策略配置" + +msgid "MWAN Policy Configuration - %s" +msgstr "MWAN 策略配置 - %s" + +msgid "MWAN Rule Configuration" +msgstr "MWAN 规则配置" + +msgid "MWAN Rule Configuration - %s" +msgstr "MWAN 规则配置 - %s" + +msgid "MWAN Service Control" +msgstr "MWAN 服务控制" + +msgid "" +"MWAN supports up to 250 physical and/or logical interfaces
MWAN " +"requires that all interfaces have a unique metric configured in /etc/config/" +"network
Names must match the interface name found in /etc/config/" +"network (see advanced tab)
Names may contain characters A-Z, a-z, 0-9, " +"_ and no spaces
Interfaces may not share the same name as configured " +"members, policies or rules" +msgstr "" +"MWAN 支持最多 250 个物理或逻辑接口。
MWAN 要求所有接口必须在 /etc/" +"config/network 中设定唯一的网关跃点。
名称必须与 /etc/config/network 中" +"的接口名称匹配。(可查看“高级”选项卡)
名称允许包括A-Z、a-z、0-9、_ 但是" +"不能有空格。
接口不应该与成员、策略、规则中的任意一个设置项使用相同的名" +"称" + +msgid "" +"May be entered as a single or multiple port(s) (eg \"22\" or \"80,443\") or " +"as a portrange (eg \"1024:2048\") without quotes" +msgstr "" +"可以输入一个或多个端口(例如 \"22\" 或者 \"80,443\")或者是一个端口范围(例" +"如 \"1024:2048\")不含引号" + +msgid "Member" +msgstr "成员" + +msgid "Member used" +msgstr "使用的成员" + +msgid "Members" +msgstr "成员" + +msgid "" +"Members are profiles attaching a metric and weight to an MWAN interface
Names may contain characters A-Z, a-z, 0-9, _ and no spaces
Members " +"may not share the same name as configured interfaces, policies or rules" +msgstr "" +"“成员”用来设置每一个 MWAN 接口的跃点数(即接口优先级)和所占比重。
名称" +"允许包括 A-Z、 a-、0-9、_ 但是不能有空格。
成员不应该与接口、策略、规则" +"中的任意一个设置项使用相同的名称" + +msgid "Members assigned" +msgstr "分配的成员" + +msgid "Metric" +msgstr "跃点数" + +msgid "" +"Name of IPset rule. Requires IPset rule in /etc/dnsmasq.conf (eg \"ipset=/" +"youtube.com/youtube\")" +msgstr "" +"匹配 IPset 规则列表名称。需要先配置 /etc/dnsmasq.conf 中的 IPset 规则 (例如: " +"\"ipset=/youtube.com/youtube\")" + +msgid "Network Config" +msgstr "网络配置文件" + +msgid "No" +msgstr "否" + +msgid "No MWAN interfaces found" +msgstr "没有找到 MWAN 接口" + +msgid "No MWAN systemlog history found" +msgstr "没有在系统日志中找到 MWAN 历史信息" + +msgid "No detailed status information available" +msgstr "没有状态详细信息可用" + +msgid "No diagnostic results returned" +msgstr "没有返回诊断结果" + +msgid "No protocol specified" +msgstr "未指定协议" + +msgid "Offline" +msgstr "离线" + +msgid "Online (tracking active)" +msgstr "在线(追踪启用中)" + +msgid "Online (tracking off)" +msgstr "在线(追踪已关闭)" + +msgid "Overview" +msgstr "概况" + +msgid "Ping count" +msgstr "Ping 计数" + +msgid "Ping default gateway" +msgstr "Ping 默认网关" + +msgid "Ping interval" +msgstr "Ping 间隔" + +msgid "Ping interval during failure detection" +msgstr "故障检测期间的 Ping 间隔" + +msgid "Ping interval during failure recovering" +msgstr "故障恢复期间的 Ping 间隔" + +msgid "Ping size" +msgstr "Ping 大小" + +msgid "Ping timeout" +msgstr "Ping 超时" + +msgid "Ping tracking IP" +msgstr "Ping 跟踪 IP" + +msgid "Policies" +msgstr "策略" + +msgid "" +"Policies are profiles grouping one or more members controlling how MWAN " +"distributes traffic
Member interfaces with lower metrics are used " +"first. Interfaces with the same metric load-balance
Load-balanced " +"member interfaces distribute more traffic out those with higher weights
Names may contain characters A-Z, a-z, 0-9, _ and no spaces. Names must be " +"15 characters or less
Policies may not share the same name as " +"configured interfaces, members or rules" +msgstr "" +"“策略”把成员进行分组,告诉 MWAN 如何分配“规则”中使用这一策略的流量
拥有" +"较低跃点数的成员将会被优先使用。拥有相同跃点数的成员把流量进行负载均衡。
进行负载均衡的成员之间拥有较高比重的成员将会被分配到更多流量。
名称允许" +"包括A-Z、a-z、0-9、_ 但是不能有空格。名称应该在 15 个字符以内
策略不应该" +"与接口、成员、规则中的任意一个设置项使用相同的名称" + +msgid "Policy" +msgstr "策略" + +msgid "Policy assigned" +msgstr "分配的策略" + +msgid "Protocol" +msgstr "通信协议" + +msgid "Recovery interval" +msgstr "故障恢复间隔" + +msgid "Restart MWAN" +msgstr "重启 MWAN" + +msgid "Restore default hotplug script" +msgstr "恢复默认的 hotplug 脚本" + +msgid "Restore..." +msgstr "恢复..." + +msgid "Rule" +msgstr "规则" + +msgid "Rules" +msgstr "规则" + +msgid "" +"Rules specify which traffic will use a particular MWAN policy based on IP " +"address, port or protocol
Rules are matched from top to bottom. Rules " +"below a matching rule are ignored. Traffic not matching any rule is routed " +"using the main routing table
Traffic destined for known (other than " +"default) networks is handled by the main routing table. Traffic matching a " +"rule, but all WAN interfaces for that policy are down will be blackholed
Names may contain characters A-Z, a-z, 0-9, _ and no spaces
Rules may " +"not share the same name as configured interfaces, members or policies" +msgstr "" +"“规则”基于 IP 地址、协议、端口把流量划分到指定的“策略”中。
规则按照从上" +"到下的顺序进行匹配。除了第一条能够匹配一次通信的规则以外,其它规则将被忽略。" +"不匹配任何规则的通信将会由系统默认路由表进行。
来自已知的网络的转发流量" +"由系统默认路由表接手,然后 MWAN 从中匹配出相应的流量并转移到 MWAN 自己的路由" +"表。但是所有被划分到一个无法使用的策略的流量将会无法正常进行路由。
名称" +"允许包括A-Z、a-z、0-9、_ 但是不能有空格。
规则不应该与接口、成员、策略中" +"的任意一个设置项使用相同的名称" + +msgid "Seconds. Acceptable values: 1-1000000. Defaults to 600 if not set" +msgstr "单位为秒。接受的值: 1-1000000。留空则使用默认值 600 秒" + +msgid "Source address" +msgstr "源地址" + +msgid "Source port" +msgstr "源端口" + +msgid "Start MWAN" +msgstr "启动 MWAN" + +msgid "Sticky" +msgstr "粘滞模式" + +msgid "Sticky timeout" +msgstr "粘滞超时" + +msgid "Stop MWAN" +msgstr "停止 MWAN" + +msgid "Supports CIDR notation (eg \"192.168.100.0/24\") without quotes" +msgstr "支持 CIDR 记法(例如: \"192.168.100.0/24\")不含引号" + +msgid "There are currently %d of 250 supported interfaces configured" +msgstr "当前已配置 %d 个接口,最大支持 250 个" + +msgid "" +"This displays the metric assigned to this interface in /etc/config/network" +msgstr "这里显示了这个接口在 /etc/config/network 中配置的跃点数" + +msgid "" +"This hostname or IP address will be pinged to determine if the link is up or " +"down. Leave blank to assume interface is always online" +msgstr "通过 ping 此主机或 IP 地址来确定链路是否在线。留空则认为接口始终在线" + +msgid "This section allows you to modify the contents of /etc/config/mwan3" +msgstr "这里允许你修改 /etc/config/mwan3 的内容" + +msgid "This section allows you to modify the contents of /etc/config/network" +msgstr "这里允许你修改 /etc/config/network 的内容" + +msgid "This section allows you to modify the contents of /etc/config/wireless" +msgstr "这里允许你修改 /etc/config/wireless 的内容" + +msgid "" +"This section allows you to modify the contents of /etc/hotplug.d/iface/16-" +"mwancustom
This is useful for running system commands and/or scripts " +"based on interface ifup or ifdown hotplug events

Notes:
The " +"first line of the script must be "#!/bin/sh" without quotes
Lines beginning with # are comments and are not executed

Available variables:
$ACTION is the hotplug event (ifup, ifdown)
" +"$INTERFACE is the interface name (wan1, wan2, etc.)
$DEVICE is the " +"device name attached to the interface (eth0.1, eth1, etc.)" +msgstr "" +"这里允许你修改 /etc/hotplug.d/iface/16-mwancustom 的内容
这可以在接口 " +"ifup 或 ifdown Hotplug 事件时运行系统命令或脚本

注意:
脚本的" +"第一行必须是 "#!/bin/sh" 不含引号
以#开头的行是注释,不会执行" +"

可用变量:
$ACTION 是 Hotplug 事件(ifup, ifdown)
" +"$INTERFACE 是接口名称(wan1、wan2 等)
$DEVICE 是连接到接口的设备名称 " +"(eth0.1、eth1 等)" + +msgid "Tracking IP" +msgstr "追踪的 IP" + +msgid "Tracking hostname or IP address" +msgstr "追踪的主机或 IP 地址" + +msgid "Tracking reliability" +msgstr "追踪可靠性" + +msgid "Traffic Rules" +msgstr "流量规则" + +msgid "" +"Traffic from the same source IP address that previously matched this rule " +"within the sticky timeout period will use the same WAN interface" +msgstr "" +"来自相同源 IP 的流量,如果已经匹配过此规则并且在粘滞超时时间内,将会使用相同" +"的 WAN 接口" + +msgid "Troubleshooting" +msgstr "故障排除" + +msgid "Troubleshooting Data" +msgstr "故障排除数据" + +msgid "View the contents of /etc/protocols for protocol descriptions" +msgstr "请查看 /etc/protocols 获取可选协议详情" + +msgid "WARNING: %d interfaces are configured exceeding the maximum of 250!" +msgstr "警告: 已配置 %d 个接口,超过最大值 250!" + +msgid "" +"WARNING: Some policies have names exceeding the maximum of 15 characters!" +msgstr "警告: 某些策略的名称超过了 15 个字符!" + +msgid "" +"WARNING: some interfaces are configured incorrectly or not at all in /etc/" +"config/network!" +msgstr "警告: 某些接口配置不正确或未配置到 /etc/config/network!" + +msgid "" +"WARNING: some interfaces have a higher reliability requirement than there " +"are tracking IP addresses!" +msgstr "警告: 某些接口的追踪可靠性要求大于了追踪 IP 地址总数!" + +msgid "" +"WARNING: some interfaces have duplicate metrics configured in /etc/config/" +"network!" +msgstr "警告: 某些接口在 /etc/config/network 中配置了相同的跃点数!" + +msgid "" +"WARNING: some interfaces have no default route in the main routing table!" +msgstr "警告: 某些接口在主路由表中没有默认路由!" + +msgid "" +"WARNING: some interfaces have no metric configured in /etc/config/network!" +msgstr "警告: 某些接口没有在 /etc/config/network 中配置跃点数!" + +msgid "" +"WARNING: some rules have a port configured with no or improper protocol " +"specified! Please configure a specific protocol!" +msgstr "" +"警告: 某些规则指定了端口却没有配置或配置了不正确的协议,请重新指定协议!" + +msgid "" +"WARNING: this and other interfaces have duplicate metrics configured in /etc/" +"config/network!" +msgstr "警告: 此接口和其他接口在 /etc/config/network 中配置了相同的跃点数!" + +msgid "" +"WARNING: this interface has a higher reliability requirement than there are " +"tracking IP addresses!" +msgstr "警告: 此接口的追踪可靠性要求大于了追踪 IP 地址总数!" + +msgid "WARNING: this interface has no default route in the main routing table!" +msgstr "警告: 此接口在主路由表中没有默认路由!" + +msgid "" +"WARNING: this interface has no metric configured in /etc/config/network!" +msgstr "警告: 此接口没有在 /etc/config/network 中配置跃点数!" + +msgid "" +"WARNING: this interface is configured incorrectly or not at all in /etc/" +"config/network!" +msgstr "警告: 此接口配置不正确或未配置到 /etc/config/network!" + +msgid "" +"WARNING: this policy's name is %d characters exceeding the maximum of 15!" +msgstr "警告: 此策略的名称具有 %d 个字符,超过了 15 个字符!" + +msgid "" +"WARNING: this rule is incorrectly configured with no or improper protocol " +"specified! Please configure a specific protocol!" +msgstr "警告: 此规则没有配置或配置了不正确的协议,请重新指定协议!" + +msgid "Waiting for MWAN to %s..." +msgstr "等待 MWAN %s..." + +msgid "Waiting for diagnostic results..." +msgstr "等待诊断结果..." + +msgid "Weight" +msgstr "比重" + +msgid "" +"When all policy members are offline use this behavior for matched traffic" +msgstr "当所有策略成员都无法使用的时候,对使用该策略的流量使用这个操作" + +msgid "Wireless Config" +msgstr "无线配置" + +msgid "Yes" +msgstr "是" + +msgid "always" +msgstr "总是" + +msgid "blackhole (drop)" +msgstr "黑洞(丢弃)" + +msgid "default (use main routing table)" +msgstr "默认(使用主路由表)" + +msgid "ifdown" +msgstr "ifdown" + +msgid "ifup" +msgstr "ifup" + +msgid "never" +msgstr "从不" + +msgid "restart" +msgstr "" + +msgid "start" +msgstr "" + +msgid "stop" +msgstr "" + +msgid "unreachable (reject)" +msgstr "不可达(拒绝)" + +msgid "%d IPv4-only hosts" +msgstr "%d 个主机仅支持 IPv4" + +msgid "%d IPv6-only hosts" +msgstr "%d 个主机仅支持 IPv6" + +msgid "%d dual-stack hosts" +msgstr "%d 个双协议栈主机" + +msgid "%s and %s" +msgstr "%s 和 %s" + +msgid "%s, %s and %s" +msgstr "%s, %s 和 %s" + +msgid "-1 - Restart every last day of month" +msgstr "-1 - 每月的最后一天重新开始" + +msgid "-7 - Restart a week before end of month" +msgstr "-7 - 每月底前一周重新开始" + +msgid "1 - Restart every 1st of month" +msgstr "1 - 每月的第一天重新开始" + +msgid "10m - frequent commits at the expense of flash wear" +msgstr "10m - 频繁提交,闪存损耗的开销也增大" + +msgid "12h - compromise between risk of data loss and flash wear" +msgstr "12h - 平衡统计数据丢失的风险以及闪存使用寿命" + +msgid "24h - least flash wear at the expense of data loss risk" +msgstr "24h - 以数据丢失风险的代价换取最小的闪存损耗" + +msgid "30s - refresh twice per minute for reasonably current stats" +msgstr "30s - 每分钟刷新二次以获得较准确的当前统计值" + +msgid "5m - rarely refresh to avoid frequently clearing conntrack counters" +msgstr "5m - 较少刷新以避免频繁清除连接跟踪计数器" + +msgid "60s - commit minutely, useful for non-flash storage" +msgstr "60s - 每分钟提交,适用于非闪存类型存储" + +msgid "0 connections" +msgstr "连接:0" + +msgid "0 hosts" +msgstr "主机:0" + +msgid "0% IPv6 support rate among hosts" +msgstr "支持 IPv6 的主机比例:0%" + +msgid "0B total IPv6 download" +msgstr "IPv6 总下载量:0B" + +msgid "0% of the total traffic is IPv6" +msgstr "IPv6 流量比例:0%" + +msgid "0B total IPv6 upload" +msgstr "IPv6 总上传量:0B" + +msgid "0 cause the most connections" +msgstr "0 是连接数最多的协议" + +msgid "0 cause the most download" +msgstr "0 是下载量最大的协议" + +msgid "0 cause the most upload" +msgstr "0 是上传量最大的协议" + +msgid "0 different application protocols" +msgstr "0 种不同的应用层协议" + +msgid "0 download" +msgstr "下载:0" + +msgid "0 upload" +msgstr "上传:0" + +msgid "Accounting period" +msgstr "统计周期" + +msgid "Advanced Settings" +msgstr "高级设置" + +msgid "Application" +msgstr "应用层协议" + +msgid "Application Protocols" +msgstr "应用层协议" + +msgid "Backup" +msgstr "备份" + +msgid "Bandwidth Monitor" +msgstr "带宽监控" + +msgid "CSV, grouped by IP" +msgstr "CSV,按 IP 分组" + +msgid "CSV, grouped by MAC" +msgstr "CSV,按 MAC 分组" + +msgid "CSV, grouped by protocol" +msgstr "CSV,按协议分组" + +msgid "" +"Changing the accounting interval type will invalidate existing databases!" +"
Download backup." +msgstr "" +"更改统计周期类型会使现有数据库无效!
下载备份." + +msgid "" +"Choose \"Day of month\" to restart the accounting period monthly on a " +"specific date, e.g. every 3rd. Choose \"Fixed interval\" to restart the " +"accounting period exactly every N days, beginning at a given date." +msgstr "" +"选择“每月的某一天”来设置统计周期的重启时间,例如:每个月的第 3 天。选择“固定周" +"期”来设置从给定日期开始每 N 天重启统计周期。" + +msgid "Commit interval" +msgstr "提交间隔" + +msgid "Compress database" +msgstr "压缩数据库" + +msgid "Configuration" +msgstr "配置" + +msgid "Conn." +msgstr "连接" + +msgid "Connections" +msgstr "连接" + +msgid "Connections / Host" +msgstr "连接 / 主机" + +msgid "Database directory" +msgstr "数据库目录" + +msgid "" +"Database storage directory. One file per accounting period will be placed " +"into this directory." +msgstr "数据库存储目录。每个“统计周期”的文件将被放到这个目录中。" + +msgid "Day of month" +msgstr "每月的某一天" + +msgid "" +"Day of month to restart the accounting period. Use negative values to count " +"towards the end of month, e.g. \"-5\" to specify the 27th of July or the " +"24th of Februrary." +msgstr "" +"每个月重启统计周期的日期。使用负数表示从月底开始计算,例如:\"-5\" 可以表" +"示 7 月份的 27 号或者 2 月份的 24 号。" + +msgid "Display" +msgstr "显示" + +msgid "Down. (Bytes / Pkts.)" +msgstr "下载(字节 / 数据包)" + +msgid "Download (Bytes / Packets)" +msgstr "下载(字节 / 数据包)" + +msgid "Download / Application" +msgstr "下载 / 应用层协议" + +msgid "Download Database Backup" +msgstr "下载数据库备份" + +msgid "Dualstack enabled hosts" +msgstr "双协议栈主机" + +msgid "Due date" +msgstr "重置日期" + +msgid "Export" +msgstr "导出" + +msgid "Family" +msgstr "协议类型" + +msgid "Fixed interval" +msgstr "固定周期" + +msgid "Force reload…" +msgstr "强制重新加载..." + +msgid "General Settings" +msgstr "基本设置" + +msgid "Generate Backup" +msgstr "生成备份" + +msgid "Host" +msgstr "主机" + +msgid "Hostname: example.org" +msgstr "主机名:example.org" + +msgid "IPv4 vs. IPv6" +msgstr "IPv4 与 IPv6" + +msgid "IPv6" +msgstr "IPv6" + +msgid "Interval" +msgstr "周期" + +msgid "" +"Interval at which the temporary in-memory database is committed to the " +"persistent database directory." +msgstr "将内存中的临时数据库提交到持久性数据库目录的间隔时间。" + +msgid "" +"Interval at which traffic counters of still established connections are " +"refreshed from netlink information." +msgstr "从 netlink 信息中刷新“已建立连接”的流量计数器的间隔时间。" + +msgid "Invalid or empty backup archive" +msgstr "备份存档无效或为空" + +msgid "JSON dump" +msgstr "JSON 输出" + +msgid "Length of accounting interval in days." +msgstr "统计周期(天)。" + +msgid "Local interfaces" +msgstr "本地接口" + +msgid "Local subnets" +msgstr "本地子网" + +msgid "MAC" +msgstr "MAC" + +msgid "Maximum entries" +msgstr "最大条目" + +msgid "" +"Maximum number of accounting periods to keep, use zero to keep databases " +"forever." +msgstr "保留的统计周期数据库的最大数量,设置 0 表示不限制。" + +msgid "Netlink Bandwidth Monitor" +msgstr "网络带宽监视器" + +msgid "Netlink Bandwidth Monitor - Backup / Restore" +msgstr "网络带宽监视器 - 备份 / 恢复" + +msgid "Netlink Bandwidth Monitor - Configuration" +msgstr "网络带宽监视器 - 配置" + +msgid "No data recorded yet." +msgstr "暂无数据记录。" + +msgid "Only conntrack streams from or to any of these networks are counted." +msgstr "仅统计来自或目标为这些网络接口的连接流量。" + +msgid "Only conntrack streams from or to any of these subnets are counted." +msgstr "仅统计来自或目标为这些子网的连接流量。" + +msgid "Preallocate database" +msgstr "预分配数据库" + +msgid "Protocol" +msgstr "协议" + +msgid "Protocol Mapping" +msgstr "协议映射" + +msgid "" +"Protocol mappings to distinguish traffic types per host, one mapping per " +"line. The first value specifies the IP protocol, the second value the port " +"number and the third column is the name of the mapped protocol." +msgstr "" +"协议映射用于区分流量类型,每行一条。第一个值指定 IP 协议类型,第二个值是" +"端口号,第三个值是映射的协议名称。" + +msgid "Refresh interval" +msgstr "刷新间隔" + +msgid "Restore" +msgstr "恢复" + +msgid "Restore Database Backup" +msgstr "恢复数据库备份" + +msgid "Select accounting period:" +msgstr "选择统计周期:" + +msgid "Source IP" +msgstr "源 IP" + +msgid "Start date" +msgstr "起始日期" + +msgid "Start date of the first accounting period, e.g. begin of ISP contract." +msgstr "第一个统计周期的起始日期,例如:ISP 合约的起始日期。" + +msgid "Stored periods" +msgstr "储存周期" + +msgid "" +"The Netlink Bandwidth Monitor (nlbwmon) is a lightweight, efficient traffic " +"accounting program keeping track of bandwidth usage per host and protocol." +msgstr "" +"网络带宽监视器(nlbwmon)是一个轻量、高效的流量统计程序,可以统计每个主机和" +"协议的带宽使用情况。" + +msgid "The following database files have been restored: %s" +msgstr "以下数据库文件已恢复:%s" + +msgid "" +"The maximum amount of entries that should be put into the database, setting " +"the limit to 0 will allow databases to grow indefinitely." +msgstr "数据库中的最大条目数量, 设置为 0 将允许数据库无限增长。" + +msgid "Traffic / Host" +msgstr "流量 / 主机" + +msgid "Traffic Distribution" +msgstr "流量分布" + +msgid "Up. (Bytes / Pkts.)" +msgstr "上传(字节 / 数据包)" + +msgid "Upload (Bytes / Packets)" +msgstr "上传(字节 / 数据包)" + +msgid "Upload / Application" +msgstr "上传 / 应用层协议" + +msgid "Vendor: Example Corp." +msgstr "供应商: Example Corp." + +msgid "Warning" +msgstr "警告" + +msgid "" +"Whether to gzip compress archive databases. Compressing the database files " +"makes accessing old data slightly slower but helps to reduce storage " +"requirements." +msgstr "" +"是否使用 gzip 压缩数据库存档。压缩数据库文件会使访问旧数据稍微慢一些, 但有助" +"于减少存储占用空间。" + +msgid "" +"Whether to preallocate the maximum possible database size in memory. This is " +"mainly useful for memory constrained systems which might not be able to " +"satisfy memory allocation after longer uptime periods." +msgstr "" +"是否预先分配数据库最大可能占用的内存大小。这主要适用于内存较小系统,这些系统" +"在长时间运行之后可能无法满足数据库的内存需求。" + +msgid "no traffic" +msgstr "无流量数据" + +msgid "other" +msgstr "其他" + +msgid "Enable IGMP snooping" +msgstr "开启 IGMP snooping" + +msgid "Enables IGMP snooping on this bridge" +msgstr "在此桥接上启用 IGMP snooping 组播(多播)" + +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8" + +msgid "Action" +msgstr "动作" + +msgid "Advanced Reboot" +msgstr "双分区启动切换" + +msgid "Alternative" +msgstr "备选" + +msgid "Cancel" +msgstr "取消" + +msgid "Confirm" +msgstr "确定" + +msgid "Current" +msgstr "当前" + +msgid "Firmware/OS (Kernel)" +msgstr "固件/系统 (内核)" + +msgid "Partition" +msgstr "分区" + +msgid "Partitions" +msgstr "分区" + +msgid "Perform power off..." +msgstr "点击关机..." + +msgid "Power Off Device" +msgstr "关闭设备" + +msgid "Proceed" +msgstr "处理" + +msgid "Reboot Device to an Alternative Partition" +msgstr "重启设备到备选分区" + +msgid "Reboot to alternative partition..." +msgstr "重启到备选分区" + +msgid "Reboot to current partition" +msgstr "重启到当前分区" + +msgid "Rebooting..." +msgstr "正在重启..." + +msgid "Shutting down..." +msgstr "正在关闭..." + +msgid "Status" +msgstr "状态" + +msgid "" +"The system is rebooting now.
DO NOT POWER OFF THE DEVICE!
Wait a " +"few minutes before you try to reconnect. It might be necessary to renew the " +"address of your computer to reach the device again, depending on your " +"settings." +msgstr "" + +msgid "" +"The system is rebooting to an alternative partition now.
DO NOT POWER " +"OFF THE DEVICE!
Wait a few minutes before you try to reconnect. It " +"might be necessary to renew the address of your computer to reach the device " +"again, depending on your settings." +msgstr "" + +msgid "" +"The system is shutting down now.
DO NOT POWER OFF THE DEVICE!
It " +"might be necessary to renew the address of your computer to reach the device " +"again, depending on your settings." +msgstr "" + +msgid "" +"WARNING: An alternative partition might have its own settings and completely " +"different firmware.

As your network configuration and WiFi SSID/" +"password on alternative partition might be different, you might have to " +"adjust your computer settings to be able to access your device once it " +"reboots.

Please also be aware that alternative partition " +"firmware might not provide an easy way to switch active partition and boot " +"back to the currently active partition.

Click \"Proceed\" below " +"to reboot device to an alternative partition." +msgstr "" + +msgid "" +"WARNING: Power off might result in a reboot on a device which doesn't " +"support power off.

Click \"Proceed\" below to power off your " +"device." +msgstr "" + +msgid "Warning: There are unsaved changes that will get lost on reboot!" +msgstr "警告:某些设置没有保存,重启将导致丢失这些配置!" + +msgid "Warning: This system does not have two partitions!" +msgstr "警告:当前系统没有包括两个分区!" + +msgid "Warning: This system does not support powering off!" +msgstr "警告:本系统不支持软关机!" + diff --git a/package/lean/default-settings/i18n/sqm.zh-cn.po b/package/lean/default-settings/i18n/sqm.zh-cn.po new file mode 100644 index 000000000..02a706de5 --- /dev/null +++ b/package/lean/default-settings/i18n/sqm.zh-cn.po @@ -0,0 +1,203 @@ +msgid "" +msgstr "" +"Project-Id-Version: luci-i18n-sqm\n" +"POT-Creation-Date: 2017-03-28 04:14+0800\n" +"PO-Revision-Date: 2017-03-28 04:15+0800\n" +"Last-Translator: \n" +"Language-Team: player131 \n" +"Language: zh_CN\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 1.8.10\n" +"X-Poedit-Basepath: .\n" +"Plural-Forms: nplurals=1; plural=0;\n" +"X-Poedit-KeywordsList: translate\n" +"X-Poedit-SearchPath-0: .\n" + +#: usr/lib/lua/luci/controller/sqm.lua:24 +msgid "SQM QoS" +msgstr "SQM QoS" + +#: usr/lib/lua/luci/model/cbi/sqm.lua:25 +msgid "Smart Queue Management" +msgstr "智能队列管理" + +#: usr/lib/lua/luci/model/cbi/sqm.lua:26 +msgid "" +"With SQM you can enable " +"traffic shaping, better mixing (Fair Queueing), active queue length " +"management (AQM) and prioritisation on one network interface." +msgstr "" +"使用 SQM 你可以启用流量整形,更好的混合" +"(公平列队)主动列队管理(AQM) 并设置网络接口优先级。" + +#: usr/lib/lua/luci/model/cbi/sqm.lua:32 +msgid "Queues" +msgstr "队列" + +#: usr/lib/lua/luci/model/cbi/sqm.lua:33 +msgid "Basic Settings" +msgstr "基本设置" + +#: usr/lib/lua/luci/model/cbi/sqm.lua:34 +msgid "Queue Discipline" +msgstr "列队规则" + +#: usr/lib/lua/luci/model/cbi/sqm.lua:35 +msgid "Link Layer Adaptation" +msgstr "链路层适配" + +#: usr/lib/lua/luci/model/cbi/sqm.lua:40 +msgid "Enable this SQM instance." +msgstr "启用此SQM实例" + +#: usr/lib/lua/luci/model/cbi/sqm.lua:54 +msgid "" +"The SQM GUI has just enabled the sqm initscript on your behalf. Remember to " +"disable the sqm initscript manually under System Startup menu in case this " +"change was not wished for." +msgstr "" +"你刚刚开启了SQM随机启动功能,如果你不希望SQM随机启动,可以在系统启动菜单下手" +"动禁用。" + +#: usr/lib/lua/luci/model/cbi/sqm.lua:60 +msgid "Interface name" +msgstr "接口名称" + +#: usr/lib/lua/luci/model/cbi/sqm.lua:70 +msgid "" +"Download speed (kbit/s) (ingress) set to 0 to selectively disable ingress " +"shaping:" +msgstr "下载速度(kbit/s)(入口)
设置为0关闭入口控制:" + +#: usr/lib/lua/luci/model/cbi/sqm.lua:74 +msgid "" +"Upload speed (kbit/s) (egress) set to 0 to selectively disable egress " +"shaping:" +msgstr "上传速度(kbit/s)(出口)
设置为0关闭出口控制:" + +#: usr/lib/lua/luci/model/cbi/sqm.lua:78 +msgid "" +"Create log file for this SQM instance under /var/run/sqm/${Inerface_name}." +"debug.log. Make sure to delete log files manually." +msgstr "" +"创建日志文件到/var/run/sqm/
${Inerface_name}.debug.log。
请务必手动" +"删除日志文件。" + +#: usr/lib/lua/luci/model/cbi/sqm.lua:82 +msgid "Verbosity of SQM's output into the system log." +msgstr "SQM输出到系统日志的详细程度。" + +#: usr/lib/lua/luci/model/cbi/sqm.lua:86 usr/lib/lua/luci/model/cbi/sqm.lua:99 +#: usr/lib/lua/luci/model/cbi/sqm.lua:148 +#: usr/lib/lua/luci/model/cbi/sqm.lua:155 +#: usr/lib/lua/luci/model/cbi/sqm.lua:202 +#: usr/lib/lua/luci/model/cbi/sqm.lua:243 +msgid "default" +msgstr "默认" + +#: usr/lib/lua/luci/model/cbi/sqm.lua:98 +msgid "" +"Queuing disciplines useable on this system. After installing a new qdisc, " +"you need to restart the router to see updates!" +msgstr "系统上可用的列队规则。安装新的队列规则后,重新启动路由器才会看到更新!" + +#: usr/lib/lua/luci/model/cbi/sqm.lua:112 +msgid "Queue setup script" +msgstr "队列脚本设置" + +#: usr/lib/lua/luci/model/cbi/sqm.lua:129 +msgid "" +"Show and Use Advanced Configuration. Advanced options will only be used as " +"long as this box is checked." +msgstr "选中该复选框显示高级配置。" + +#: usr/lib/lua/luci/model/cbi/sqm.lua:133 +msgid "Squash DSCP on inbound packets (ingress):" +msgstr "入站数据包压缩DSCP:" + +#: usr/lib/lua/luci/model/cbi/sqm.lua:140 +msgid "Ignore DSCP on ingress:" +msgstr "忽略入站DSCP" + +#: usr/lib/lua/luci/model/cbi/sqm.lua:147 +msgid "" +"Explicit congestion notification (ECN) status on inbound packets (ingress):" +msgstr "入站数据包的显式拥塞通知(ECN)状态" + +#: usr/lib/lua/luci/model/cbi/sqm.lua:154 +msgid "" +"Explicit congestion notification (ECN) status on outbound packets (egress)." +msgstr "出站数据包的显式拥塞通知(ECN)状态" + +#: usr/lib/lua/luci/model/cbi/sqm.lua:161 +msgid "" +"Show and Use Dangerous Configuration. Dangerous options will only be used as " +"long as this box is checked." +msgstr "选中该复选框显示危险配置。" + +#: usr/lib/lua/luci/model/cbi/sqm.lua:166 +msgid "Hard limit on ingress queues; leave empty for default." +msgstr "入站队列严格限制;留空为默认。" + +#: usr/lib/lua/luci/model/cbi/sqm.lua:173 +msgid "Hard limit on egress queues; leave empty for default." +msgstr "出站队列严格限制;留空为默认。" + +#: usr/lib/lua/luci/model/cbi/sqm.lua:180 +msgid "Latency target for ingress, e.g 5ms [units: s, ms, or us]; leave empty for automatic selection, put in the word default for the qdisc's default." +msgstr "入站延迟目标,例如 5ms [单位: s, ms, 或 us];留空为自动选择,default为列队规则默认值。" + +#: usr/lib/lua/luci/model/cbi/sqm.lua:185 +msgid "Latency target for egress, e.g. 5ms [units: s, ms, or us]; leave empty for automatic selection, put in the word default for the qdisc's default." +msgstr "出站延迟目标,例如 5ms [单位: s, ms, 或 us];留空为自动选择,default为列队规则默认值。" + +#: usr/lib/lua/luci/model/cbi/sqm.lua:192 +msgid "" +"Advanced option string to pass to the ingress queueing disciplines; no error " +"checking, use very carefully." +msgstr "传递到入站队列规则的高级选项字符串;没有错误检查。请谨慎使用!" + +#: usr/lib/lua/luci/model/cbi/sqm.lua:196 +msgid "" +"Advanced option string to pass to the egress queueing disciplines; no error " +"checking, use very carefully." +msgstr "传递到出站队列规则的高级选项字符串;没有错误检查。请谨慎使用!" + +#: usr/lib/lua/luci/model/cbi/sqm.lua:201 +msgid "Which link layer to account for:" +msgstr "对哪个链路层生效:" + +#: usr/lib/lua/luci/model/cbi/sqm.lua:207 +msgid "Per Packet Overhead (byte):" +msgstr "每个数据包开销" + +#: usr/lib/lua/luci/model/cbi/sqm.lua:216 +msgid "" +"Show Advanced Linklayer Options, (only needed if MTU > 1500). Advanced " +"options will only be used as long as this box is checked." +msgstr "" +"显示高级链路选项,(仅在MTU> 1500时才需要)。 只有选中此框时,才会使用高级选" +"项。" + +#: usr/lib/lua/luci/model/cbi/sqm.lua:221 +msgid "" +"Maximal Size for size and rate calculations, tcMTU (byte); needs to be >= " +"interface MTU + overhead:" +msgstr "大小和速率计算的最大尺寸,tcMTU(byte); 需要> =接口MTU +开销:" + +#: usr/lib/lua/luci/model/cbi/sqm.lua:228 +msgid "" +"Number of entries in size/rate tables, TSIZE; for ATM choose TSIZE = (tcMTU " +"+ 1) / 16:" +msgstr "大小/速率表中的条目数,TSIZE; 对于ATM选择TSIZE =(tcMTU + 1)/ 16:" + +#: usr/lib/lua/luci/model/cbi/sqm.lua:235 +msgid "" +"Minimal packet size, MPU (byte); needs to be > 0 for ethernet size tables:" +msgstr "最小数据包大小,MPU(byte); 在以太网中需要>0:" + +#: usr/lib/lua/luci/model/cbi/sqm.lua:242 +msgid "Which linklayer adaptation mechanism to use; for testing only" +msgstr "使用哪个链路适应机制; 仅用于测试" \ No newline at end of file diff --git a/package/lean/default-settings/tools/po2lmo/Makefile b/package/lean/default-settings/tools/po2lmo/Makefile new file mode 100644 index 000000000..ad2c13320 --- /dev/null +++ b/package/lean/default-settings/tools/po2lmo/Makefile @@ -0,0 +1,12 @@ + +INSTALL = install +PREFIX = /usr/bin + +po2lmo: src/po2lmo.o src/template_lmo.o + $(CC) $(LDFLAGS) -o src/po2lmo src/po2lmo.o src/template_lmo.o + +install: + $(INSTALL) -m 755 src/po2lmo $(PREFIX) + +clean: + $(RM) src/po2lmo src/*.o diff --git a/package/lean/default-settings/tools/po2lmo/src/po2lmo b/package/lean/default-settings/tools/po2lmo/src/po2lmo new file mode 100644 index 0000000000000000000000000000000000000000..134a59c27bdeb6dc92f3cd225a5ce411f121ad8c GIT binary patch literal 17424 zcmeHPeRx#WnLm@6zzA_NV6+jiPBB=tIs}LmMcM>1d??@u0kM7zLo#6!lbJYk2cZ>( zos1sC zF1pX|zx#0YDV zEiM-`!~~GYtJw(|1RpXml!E3$a3VASH|%n`87=~5AP;025D9_23>7nlU|@dXRebjx zA>7Zq+zfrl^fUs?CBFnw1^5-a&-^PIM(Yuj34scrsb+&@q8n3w$JYu4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LuC-1F;;X~Sd%vUt`6s8>a ztXz9mnL>z7xq77Wc|@H0xR-s#kTYMklw(+fz#S*$xX0yh=ZgrY9QWe; zAXiHxjE6Q*_F)85j(hY$7$FxzhMbxHhDDBR#SzFIw{!&RqM(1U9(wm~y9p zJqTpUf1hEF@`E8(ulQXvojsSWA_TRxPlG1834W8m2zb(zmKpAo|PZwF9@4`WNW6t6;GKl&<~Su8}L UeYAsP!>X?r%sz7vfoJObZ#|)5-T(jq literal 0 HcmV?d00001 diff --git a/package/lean/default-settings/tools/po2lmo/src/po2lmo.c b/package/lean/default-settings/tools/po2lmo/src/po2lmo.c new file mode 100644 index 000000000..0da792b68 --- /dev/null +++ b/package/lean/default-settings/tools/po2lmo/src/po2lmo.c @@ -0,0 +1,247 @@ +/* + * lmo - Lua Machine Objects - PO to LMO conversion tool + * + * Copyright (C) 2009-2012 Jo-Philipp Wich + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "template_lmo.h" + +static void die(const char *msg) +{ + fprintf(stderr, "Error: %s\n", msg); + exit(1); +} + +static void usage(const char *name) +{ + fprintf(stderr, "Usage: %s input.po output.lmo\n", name); + exit(1); +} + +static void print(const void *ptr, size_t size, size_t nmemb, FILE *stream) +{ + if( fwrite(ptr, size, nmemb, stream) == 0 ) + die("Failed to write stdout"); +} + +static int extract_string(const char *src, char *dest, int len) +{ + int pos = 0; + int esc = 0; + int off = -1; + + for( pos = 0; (pos < strlen(src)) && (pos < len); pos++ ) + { + if( (off == -1) && (src[pos] == '"') ) + { + off = pos + 1; + } + else if( off >= 0 ) + { + if( esc == 1 ) + { + switch (src[pos]) + { + case '"': + case '\\': + off++; + break; + } + dest[pos-off] = src[pos]; + esc = 0; + } + else if( src[pos] == '\\' ) + { + dest[pos-off] = src[pos]; + esc = 1; + } + else if( src[pos] != '"' ) + { + dest[pos-off] = src[pos]; + } + else + { + dest[pos-off] = '\0'; + break; + } + } + } + + return (off > -1) ? strlen(dest) : -1; +} + +static int cmp_index(const void *a, const void *b) +{ + uint32_t x = ((const lmo_entry_t *)a)->key_id; + uint32_t y = ((const lmo_entry_t *)b)->key_id; + + if (x < y) + return -1; + else if (x > y) + return 1; + + return 0; +} + +static void print_uint32(uint32_t x, FILE *out) +{ + uint32_t y = htonl(x); + print(&y, sizeof(uint32_t), 1, out); +} + +static void print_index(void *array, int n, FILE *out) +{ + lmo_entry_t *e; + + qsort(array, n, sizeof(*e), cmp_index); + + for (e = array; n > 0; n--, e++) + { + print_uint32(e->key_id, out); + print_uint32(e->val_id, out); + print_uint32(e->offset, out); + print_uint32(e->length, out); + } +} + +int main(int argc, char *argv[]) +{ + char line[4096]; + char key[4096]; + char val[4096]; + char tmp[4096]; + int state = 0; + int offset = 0; + int length = 0; + int n_entries = 0; + void *array = NULL; + lmo_entry_t *entry = NULL; + uint32_t key_id, val_id; + + FILE *in; + FILE *out; + + if( (argc != 3) || ((in = fopen(argv[1], "r")) == NULL) || ((out = fopen(argv[2], "w")) == NULL) ) + usage(argv[0]); + + memset(line, 0, sizeof(key)); + memset(key, 0, sizeof(val)); + memset(val, 0, sizeof(val)); + + while( (NULL != fgets(line, sizeof(line), in)) || (state >= 2 && feof(in)) ) + { + if( state == 0 && strstr(line, "msgid \"") == line ) + { + switch(extract_string(line, key, sizeof(key))) + { + case -1: + die("Syntax error in msgid"); + case 0: + state = 1; + break; + default: + state = 2; + } + } + else if( state == 1 || state == 2 ) + { + if( strstr(line, "msgstr \"") == line || state == 2 ) + { + switch(extract_string(line, val, sizeof(val))) + { + case -1: + state = 4; + break; + default: + state = 3; + } + } + else + { + switch(extract_string(line, tmp, sizeof(tmp))) + { + case -1: + state = 2; + break; + default: + strcat(key, tmp); + } + } + } + else if( state == 3 ) + { + switch(extract_string(line, tmp, sizeof(tmp))) + { + case -1: + state = 4; + break; + default: + strcat(val, tmp); + } + } + + if( state == 4 ) + { + if( strlen(key) > 0 && strlen(val) > 0 ) + { + key_id = sfh_hash(key, strlen(key)); + val_id = sfh_hash(val, strlen(val)); + + if( key_id != val_id ) + { + n_entries++; + array = realloc(array, n_entries * sizeof(lmo_entry_t)); + entry = (lmo_entry_t *)array + n_entries - 1; + + if (!array) + die("Out of memory"); + + entry->key_id = key_id; + entry->val_id = val_id; + entry->offset = offset; + entry->length = strlen(val); + + length = strlen(val) + ((4 - (strlen(val) % 4)) % 4); + + print(val, length, 1, out); + offset += length; + } + } + + state = 0; + memset(key, 0, sizeof(key)); + memset(val, 0, sizeof(val)); + } + + memset(line, 0, sizeof(line)); + } + + print_index(array, n_entries, out); + + if( offset > 0 ) + { + print_uint32(offset, out); + fsync(fileno(out)); + fclose(out); + } + else + { + fclose(out); + unlink(argv[2]); + } + + fclose(in); + return(0); +} diff --git a/package/lean/default-settings/tools/po2lmo/src/template_lmo.c b/package/lean/default-settings/tools/po2lmo/src/template_lmo.c new file mode 100644 index 000000000..27205a722 --- /dev/null +++ b/package/lean/default-settings/tools/po2lmo/src/template_lmo.c @@ -0,0 +1,328 @@ +/* + * lmo - Lua Machine Objects - Base functions + * + * Copyright (C) 2009-2010 Jo-Philipp Wich + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "template_lmo.h" + +/* + * Hash function from http://www.azillionmonkeys.com/qed/hash.html + * Copyright (C) 2004-2008 by Paul Hsieh + */ + +uint32_t sfh_hash(const char *data, int len) +{ + uint32_t hash = len, tmp; + int rem; + + if (len <= 0 || data == NULL) return 0; + + rem = len & 3; + len >>= 2; + + /* Main loop */ + for (;len > 0; len--) { + hash += sfh_get16(data); + tmp = (sfh_get16(data+2) << 11) ^ hash; + hash = (hash << 16) ^ tmp; + data += 2*sizeof(uint16_t); + hash += hash >> 11; + } + + /* Handle end cases */ + switch (rem) { + case 3: hash += sfh_get16(data); + hash ^= hash << 16; + hash ^= data[sizeof(uint16_t)] << 18; + hash += hash >> 11; + break; + case 2: hash += sfh_get16(data); + hash ^= hash << 11; + hash += hash >> 17; + break; + case 1: hash += *data; + hash ^= hash << 10; + hash += hash >> 1; + } + + /* Force "avalanching" of final 127 bits */ + hash ^= hash << 3; + hash += hash >> 5; + hash ^= hash << 4; + hash += hash >> 17; + hash ^= hash << 25; + hash += hash >> 6; + + return hash; +} + +uint32_t lmo_canon_hash(const char *str, int len) +{ + char res[4096]; + char *ptr, prev; + int off; + + if (!str || len >= sizeof(res)) + return 0; + + for (prev = ' ', ptr = res, off = 0; off < len; prev = *str, off++, str++) + { + if (isspace(*str)) + { + if (!isspace(prev)) + *ptr++ = ' '; + } + else + { + *ptr++ = *str; + } + } + + if ((ptr > res) && isspace(*(ptr-1))) + ptr--; + + return sfh_hash(res, ptr - res); +} + +lmo_archive_t * lmo_open(const char *file) +{ + int in = -1; + uint32_t idx_offset = 0; + struct stat s; + + lmo_archive_t *ar = NULL; + + if (stat(file, &s) == -1) + goto err; + + if ((in = open(file, O_RDONLY)) == -1) + goto err; + + if ((ar = (lmo_archive_t *)malloc(sizeof(*ar))) != NULL) + { + memset(ar, 0, sizeof(*ar)); + + ar->fd = in; + ar->size = s.st_size; + + fcntl(ar->fd, F_SETFD, fcntl(ar->fd, F_GETFD) | FD_CLOEXEC); + + if ((ar->mmap = mmap(NULL, ar->size, PROT_READ, MAP_SHARED, ar->fd, 0)) == MAP_FAILED) + goto err; + + idx_offset = ntohl(*((const uint32_t *) + (ar->mmap + ar->size - sizeof(uint32_t)))); + + if (idx_offset >= ar->size) + goto err; + + ar->index = (lmo_entry_t *)(ar->mmap + idx_offset); + ar->length = (ar->size - idx_offset - sizeof(uint32_t)) / sizeof(lmo_entry_t); + ar->end = ar->mmap + ar->size; + + return ar; + } + +err: + if (in > -1) + close(in); + + if (ar != NULL) + { + if ((ar->mmap != NULL) && (ar->mmap != MAP_FAILED)) + munmap(ar->mmap, ar->size); + + free(ar); + } + + return NULL; +} + +void lmo_close(lmo_archive_t *ar) +{ + if (ar != NULL) + { + if ((ar->mmap != NULL) && (ar->mmap != MAP_FAILED)) + munmap(ar->mmap, ar->size); + + close(ar->fd); + free(ar); + + ar = NULL; + } +} + + +lmo_catalog_t *_lmo_catalogs = NULL; +lmo_catalog_t *_lmo_active_catalog = NULL; + +int lmo_load_catalog(const char *lang, const char *dir) +{ + DIR *dh = NULL; + char pattern[16]; + char path[PATH_MAX]; + struct dirent *de = NULL; + + lmo_archive_t *ar = NULL; + lmo_catalog_t *cat = NULL; + + if (!lmo_change_catalog(lang)) + return 0; + + if (!dir || !(dh = opendir(dir))) + goto err; + + if (!(cat = malloc(sizeof(*cat)))) + goto err; + + memset(cat, 0, sizeof(*cat)); + + snprintf(cat->lang, sizeof(cat->lang), "%s", lang); + snprintf(pattern, sizeof(pattern), "*.%s.lmo", lang); + + while ((de = readdir(dh)) != NULL) + { + if (!fnmatch(pattern, de->d_name, 0)) + { + snprintf(path, sizeof(path), "%s/%s", dir, de->d_name); + ar = lmo_open(path); + + if (ar) + { + ar->next = cat->archives; + cat->archives = ar; + } + } + } + + closedir(dh); + + cat->next = _lmo_catalogs; + _lmo_catalogs = cat; + + if (!_lmo_active_catalog) + _lmo_active_catalog = cat; + + return 0; + +err: + if (dh) closedir(dh); + if (cat) free(cat); + + return -1; +} + +int lmo_change_catalog(const char *lang) +{ + lmo_catalog_t *cat; + + for (cat = _lmo_catalogs; cat; cat = cat->next) + { + if (!strncmp(cat->lang, lang, sizeof(cat->lang))) + { + _lmo_active_catalog = cat; + return 0; + } + } + + return -1; +} + +static lmo_entry_t * lmo_find_entry(lmo_archive_t *ar, uint32_t hash) +{ + unsigned int m, l, r; + uint32_t k; + + l = 0; + r = ar->length - 1; + + while (1) + { + m = l + ((r - l) / 2); + + if (r < l) + break; + + k = ntohl(ar->index[m].key_id); + + if (k == hash) + return &ar->index[m]; + + if (k > hash) + { + if (!m) + break; + + r = m - 1; + } + else + { + l = m + 1; + } + } + + return NULL; +} + +int lmo_translate(const char *key, int keylen, char **out, int *outlen) +{ + uint32_t hash; + lmo_entry_t *e; + lmo_archive_t *ar; + + if (!key || !_lmo_active_catalog) + return -2; + + hash = lmo_canon_hash(key, keylen); + + for (ar = _lmo_active_catalog->archives; ar; ar = ar->next) + { + if ((e = lmo_find_entry(ar, hash)) != NULL) + { + *out = ar->mmap + ntohl(e->offset); + *outlen = ntohl(e->length); + return 0; + } + } + + return -1; +} + +void lmo_close_catalog(const char *lang) +{ + lmo_archive_t *ar, *next; + lmo_catalog_t *cat, *prev; + + for (prev = NULL, cat = _lmo_catalogs; cat; prev = cat, cat = cat->next) + { + if (!strncmp(cat->lang, lang, sizeof(cat->lang))) + { + if (prev) + prev->next = cat->next; + else + _lmo_catalogs = cat->next; + + for (ar = cat->archives; ar; ar = next) + { + next = ar->next; + lmo_close(ar); + } + + free(cat); + break; + } + } +} diff --git a/package/lean/default-settings/tools/po2lmo/src/template_lmo.h b/package/lean/default-settings/tools/po2lmo/src/template_lmo.h new file mode 100644 index 000000000..57f59aa56 --- /dev/null +++ b/package/lean/default-settings/tools/po2lmo/src/template_lmo.h @@ -0,0 +1,92 @@ +/* + * lmo - Lua Machine Objects - General header + * + * Copyright (C) 2009-2012 Jo-Philipp Wich + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _TEMPLATE_LMO_H_ +#define _TEMPLATE_LMO_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if (defined(__GNUC__) && defined(__i386__)) +#define sfh_get16(d) (*((const uint16_t *) (d))) +#else +#define sfh_get16(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8)\ + +(uint32_t)(((const uint8_t *)(d))[0]) ) +#endif + + +struct lmo_entry { + uint32_t key_id; + uint32_t val_id; + uint32_t offset; + uint32_t length; +} __attribute__((packed)); + +typedef struct lmo_entry lmo_entry_t; + + +struct lmo_archive { + int fd; + int length; + uint32_t size; + lmo_entry_t *index; + char *mmap; + char *end; + struct lmo_archive *next; +}; + +typedef struct lmo_archive lmo_archive_t; + + +struct lmo_catalog { + char lang[6]; + struct lmo_archive *archives; + struct lmo_catalog *next; +}; + +typedef struct lmo_catalog lmo_catalog_t; + + +uint32_t sfh_hash(const char *data, int len); +uint32_t lmo_canon_hash(const char *data, int len); + +lmo_archive_t * lmo_open(const char *file); +void lmo_close(lmo_archive_t *ar); + + +extern lmo_catalog_t *_lmo_catalogs; +extern lmo_catalog_t *_lmo_active_catalog; + +int lmo_load_catalog(const char *lang, const char *dir); +int lmo_change_catalog(const char *lang); +int lmo_translate(const char *key, int keylen, char **out, int *outlen); +void lmo_close_catalog(const char *lang); + +#endif