mirror of
https://github.com/HackPlan/RootPanel.git
synced 2026-04-27 17:24:05 +08:00
添加前端国际化文件缓存支持
This commit is contained in:
@@ -56,6 +56,7 @@ exports.run = ->
|
||||
ticket_create_email: fs.readFileSync('./core/template/ticket_create_email.html').toString()
|
||||
ticket_reply_email: fs.readFileSync('./core/template/ticket_reply_email.html').toString()
|
||||
|
||||
app.localeVersion = config.i18n.version
|
||||
app.use connect.json()
|
||||
app.use connect.urlencoded()
|
||||
app.use connect.cookieParser()
|
||||
@@ -102,7 +103,6 @@ exports.run = ->
|
||||
|
||||
app.listen config.web.listen, ->
|
||||
fs.chmodSync config.web.listen, 0o770
|
||||
|
||||
console.log "RootPanel start at #{config.web.listen}"
|
||||
|
||||
unless module.parent
|
||||
|
||||
@@ -48,5 +48,13 @@ $ ->
|
||||
window.tErr = (name) ->
|
||||
return "error_code.#{name}"
|
||||
|
||||
$.getJSON "/locale/#{$.cookie('language')}", (data) ->
|
||||
window.i18n_data = data
|
||||
clientVersion = localStorage.getItem 'localeVersion'
|
||||
currentVersion = "#{($ 'body').data 'locale'}"
|
||||
|
||||
if clientVersion == currentVersion
|
||||
window.i18n_data = JSON.parse(localStorage.getItem 'localeContent')
|
||||
else
|
||||
$.getJSON "/locale/#{$.cookie('language')}", (data) ->
|
||||
window.i18n_data = data
|
||||
localStorage.setItem 'localeVersion', currentVersion
|
||||
localStorage.setItem 'localeContent', JSON.stringify data
|
||||
|
||||
@@ -8,7 +8,7 @@ html
|
||||
for hook in selectHook('view.layout.styles')
|
||||
link(rel='stylesheet', href=hook.path)
|
||||
|
||||
body
|
||||
body(data-locale=app.localeVersion)
|
||||
header.navbar-fixed-top
|
||||
.container
|
||||
nav.navbar.navbar-default.navbar-inverse(role='navigation')
|
||||
|
||||
@@ -9,6 +9,7 @@ module.exports =
|
||||
cookie_time: 30 * 24 * 3600 * 1000
|
||||
|
||||
i18n:
|
||||
version: '0,1'
|
||||
available_language: ['zh_CN']
|
||||
default_language: 'zh_CN'
|
||||
default_timezone: 'Asia/Shanghai'
|
||||
|
||||
Reference in New Issue
Block a user