openwrt设置语言的过程
设置语言的流程
一、关联的配置文件
/etc/config/luci
查看配置文件内容如下:
root@hbg:/# cat /etc/config/luci
config core 'main'
option mediaurlbase '/luci-static/openwrt.org'
option resourcebase '/luci-static/resources'
option lang 'zh_cn' // 目前使用的语言zh_cn,中文
config extern 'flash_keep'
option uci '/etc/config/'
option dropbear '/etc/dropbear/'
option openvpn '/etc/openvpn/'
option passwd '/etc/passwd'
option opkg '/etc/opkg.conf'
option firewall '/etc/firewall.user'
option uploads '/lib/uci/upload/'
config internal 'languages' // 语言选项
option zh_cn 'chinese' // 中文
option en 'English' // 英语
config internal 'sauth'
option sessionpath '/tmp/luci-sessions'
option sessiontime '3600'
config internal 'ccache'
option enable '1'
config internal 'themes'
option Bootstrap '/luci-static/bootstrap'
二、调用过程
在dispatcher.lua中httpdispatch() 函数中调用了函数dispatch(),
在dispatch()函数中实现:
local conf = require "luci.config" // 配置文件为/etc/config/luci
assert(conf.main, // 查看配置文件中是否有main段,若无,提示错误。
"/etc/config/luci seems to be corrupt, unable to find section 'main'")
local lang = conf.main.lang
if lang == nil then
lang = "zh_cn"
luci.sys.call("uci set luci.main.lang=zh_cn; uci commit luci")
end
require "luci.i18n".setlanguage(lang) // 设置语言
查找调用dispatch()的地方,可以找到:
1)cgi.lua
2)uhttpd.lua
两个脚本都位 ./feeds/luci/modules/base/luasrc/sgi目录下,
并且都是调用这句
local x = coroutine.create(luci.dispatcher.httpdispatch)
调用cgi.lua脚本的地方为./feeds/luci/modules/base/htdocs/cgi-bin/luci
文件内容如下:
#!/usr/bin/lua
require "luci.cacheloader"
require "luci.sgi.cgi" // 包含头文件cgi.lua
luci.dispatcher.indexcache = "/tmp/luci-indexcache"
luci.sgi.cgi.run() // 调用cgi.lua中的run函数。
三、luci的启动-uhttpd
uhttpd是一个简单的web服务器程序,主要就是cgi的处理,openwrt是利用uhttpd作为web服务器,
实现客户端web页面配置功能。对于request处理方式,采用的是cgi,而所用的cgi程序就是luci.
四、luci的启动-luci
在web server中的cgi-bin目录下,运行 luci 文件(权限一般是 755,luci的代码如下:
#!/usr/bin/lua --cgi的执行命令的路径
require"luci.cacheloader" --导入cacheloader包
require"luci.sgi.cgi" --导入sgi.cgi包
luci.dispatcher.indexcache = "/tmp/luci-indexcache" --cache缓存路径地址
luci.sgi.cgi.run() --执行run,此方法位于*/luci/sgi/cgi.lua
五、Luci-- Web
a.登录
输入: http://x.x.x.x/ 登录LuCI.
调用 /www/cgi-bin/luci.
b. 进入主菜单‘status’
输入: http://x.x.x.x/cgi-bin/luci/admin/status/即可访问status页面。
Luci则会调用 /luci/admin/目录下的status.lua脚本:
module("luci.controller.admin.status", package.seeall)
/usr/lib/lua/luci/controller/admin/status.lua->index()
openwrt设置语言的过程的更多相关文章
- 用source函数代替繁冗的R语言打包过程
用source函数代替繁冗的R语言打包过程 经过初级的学习和使用R语言之后我们渐渐的开始动手写自己的R语言小程序,这些小程序因为和自己的工作非常契合而变得通用性不是那么强.因此,要让它们成为一个独立的 ...
- C语言调试过程中duplicate symbol错误分析
说明:在我们调试C语言的过程中,经常会遇到duplicate symbol错误(在Mac平台下利用Xcode集成开发环境).如下图: 一.简单分析一下C语言程序的开发步骤. 由上图我们可以看出C语言由 ...
- Windows Store App 全球化:应用中设置语言选项
当开发者将开发的应用上传到Windows应用商店以后,使用Windows 8系统的用户可能会看到并下载这些应用,而这些用户所在的区域或者所使用的语言可能都不相同,如果他们在使用应用程序时希望改变应用显 ...
- SQL设置语言,返回中文”星期几”格式
SQL中语言表: SELECT * FROM sys.syslanguages eg: SET LANGUAGE 简体中文 --设置语言 PRINT DATENAME(weekday,GETDAT ...
- linux设置语言编码
前段时间在服务器上安装了centos6.2版本,当初安装时语言选择英文.这本来也没有什么问题,直到前一段时间.我的同事发现部署的web项目中出现乱码情况.但中文作为参数进行传递到下一个页面的时候就乱码 ...
- locale命令设置语言环境
locale命令设置语言环境 在Linux中通过locale来设置程序运行的不同语言环境,locale由 ANSI C提供支持.locale的命名规则为_.,如zh_CN.GBK,zh代表中文, CN ...
- C语言编译过程及数据类型
写在前面 C语言可以称得上是高级语言中的低级语言,接下来一段时间,我会写一下文章关于c语言,把它的神秘面纱一 一揭开.下面主要是c语言的C语言编译过程及数据类型 源文件编译过程 为了使计算机能执行高级 ...
- CentOS7--系统设置语言环境
设置语言: 系统范围的区域设置存储在/etc/locale.conf文件中,在systemd守护进程提前引导时读取.配置的区域设置/etc/locale.conf由每个服务或用户继承,除非个别程序或个 ...
- C语言编译过程以及gcc编译参数
1.1 C语言编译过程,gcc参数简介 1.1.1 C语言编译过程 一.gcc - o a a.c -o:指定文件输出名字 二.C语言编译的过程: 1.1.1 ...
随机推荐
- ASP.NET Core: Getting Started with ASP.NET MVC Core
1. ASP.NET Core the Unified Framework ASP.NET Core的统一框架 2. New Solution Project 新的解决方案项目 src folder: ...
- Leetcode easy
1. Two Sum Given an array of integers, return indices of the two numbers such that they add up to a ...
- CSS样式类型
CSS样式可以写在哪些地方呢?从CSS 样式代码插入的形式来看基本可以分为以下3种:内联式.嵌入式和外部式三种.这一小节先来讲解内联式 (一)内联式样式 内联式css样式表就是把css代码直接写在现有 ...
- Chapter 2 Open Book——36
"That was awful," he groaned. "They all looked exactly the same. You're lucky you had ...
- [Poi2015]
[POI2015]Łasuchy 一看以为是sb题 简单来说就是每个人获得热量要尽量多 不能找别人 首先这道题好像我自己找不到NIE的情况 很容易想到一个优化 如果一个数/2>另一个数 那么一定 ...
- HDU 1329 Hanoi Tower Troubles Again!(乱搞)
Hanoi Tower Troubles Again! Problem Description People stopped moving discs from peg to peg after th ...
- shell的入门
shell :弱类型. 解释型语言 从程序员的角度来看, Shell本身是一种用C语言编写的程序,从用户的角度来看,Shell是用户与Linux操作系统沟通的桥梁.用户既可以输入命令执行,又可以利用 ...
- how to check if you have TURNIN successfully?
For example, if I want to check if I have turnin my proj1 of cs130a successfully, I just use this co ...
- 🐒-mysql(1)
Mac 终端启动mysql 本文下载的mysql版本为:5.7.17.MySQL Workbench版本为:5.2.47(后面会提及如何选择下载版本) 一.下载MySQL 1.1.访问http://w ...
- 私有云Rabbitmq 集群部署
默认openstack使用rabbitmq做信息队列,如果想要是云高可用,那么需要对每个涉及的组件都进行高可用配置,本文介绍如何使用rabbitmq 做高可用 高可用方法 通过 Erlang 的分布式 ...