When I try to use the os.locale method to set the locale to pt_PT, the return of os.date method remains the same. How do I change locale? Below is my code. I'm trying to do this in the file /usr/lib/lua/luci/view/admin_status/index.htm.

require "luci.fs"
    require "luci.tools.status"

    local has_ipv6 = luci.fs.access("/proc/net/ipv6_route")
    local has_dhcp = luci.fs.access("/etc/config/dhcp")
    local has_wifi = luci.fs.stat("/etc/config/wireless")
          has_wifi = has_wifi and has_wifi.size > 0

    if luci.http.formvalue("status") == "1" then
    
        os.setlocale("pt_PT")
        
        local ntm = require "luci.model.network".init()
        local wan = ntm:get_wannet()
        local wan6 = ntm:get_wan6net()

        local _, _, memtotal, memcached, membuffers, memfree = luci.sys.sysinfo()

        local conn_count = tonumber((
            luci.sys.exec("wc -l /proc/net/nf_conntrack") or
            luci.sys.exec("wc -l /proc/net/ip_conntrack") or
            ""):match("%d+")) or 0

        local conn_max = tonumber((
            luci.sys.exec("sysctl net.nf_conntrack_max") or
            luci.sys.exec("sysctl net.ipv4.netfilter.ip_conntrack_max") or
            ""):match("%d+")) or 4096

        local rv = {
            uptime     = luci.sys.uptime(),
            localtime  = os.date(),
            loadavg    = { luci.sys.loadavg() },
            memtotal   = memtotal,
            memcached  = memcached,
            membuffers = membuffers,
            memfree    = memfree,
            connmax    = conn_max,
            conncount  = conn_count,
            leases     = luci.tools.status.dhcp_leases(),
            leases6    = luci.tools.status.dhcp6_leases(),
            wifinets   = luci.tools.status.wifi_networks()
        }

        if wan then
            rv.wan = {
                ipaddr  = wan:ipaddr(),
                gwaddr  = wan:gwaddr(),
                netmask = wan:netmask(),
                dns     = wan:dnsaddrs(),
                expires = wan:expires(),
                uptime  = wan:uptime(),
                proto   = wan:proto(),
                ifname  = wan:ifname(),
                link    = wan:adminlink()
            }
        end

        if wan6 then
            rv.wan6 = {
                ip6addr = wan6:ip6addr(),
                gw6addr = wan6:gw6addr(),
                dns     = wan6:dns6addrs(),
                uptime  = wan6:uptime(),
                ifname  = wan6:ifname(),
                link    = wan6:adminlink()
            }
        end

        luci.http.prepare_content("application/json")
        luci.http.write_json(rv)

        return
    end

    local system, model = luci.sys.sysinfo()

 

(Last edited by filipeobernardes on 12 Mar 2014, 20:19)