mirror of
https://github.com/HackPlan/RootPanel.git
synced 2026-04-23 11:17:54 +08:00
fixbugs with i18n
This commit is contained in:
@@ -59,14 +59,14 @@ exports.run = ->
|
||||
|
||||
app.use connect.json()
|
||||
app.use connect.urlencoded()
|
||||
app.use connect.cookieParser()
|
||||
app.use connect.logger()
|
||||
app.use require('cookie-parser')()
|
||||
|
||||
app.use require 'middleware-injector'
|
||||
|
||||
app.use (req, res, next) ->
|
||||
res.locals.app = app
|
||||
res.locals.res = res
|
||||
res.locals.req = req
|
||||
res.locals.config = app.config
|
||||
res.locals.t = res.t = app.i18n.getTranslator req
|
||||
|
||||
@@ -84,7 +84,7 @@ exports.run = ->
|
||||
app.set 'views', path.join(__dirname, 'core/view')
|
||||
app.set 'view engine', 'jade'
|
||||
|
||||
app.get '/locale/:language', app.i18n.downloadLocales
|
||||
app.get '/locale/:language?', app.i18n.downloadLocales
|
||||
|
||||
app.use '/account', require './core/router/account'
|
||||
app.use '/billing', require './core/router/billing'
|
||||
|
||||
@@ -3,6 +3,7 @@ fs = require 'fs'
|
||||
_ = require 'underscore'
|
||||
|
||||
stringify = require 'json-stable-stringify'
|
||||
Negotiator = require 'negotiator'
|
||||
|
||||
utils = require './utils'
|
||||
cache = require './cache'
|
||||
@@ -25,8 +26,8 @@ exports.parseLanguageCode = parseLanguageCode = (language) ->
|
||||
|
||||
return {
|
||||
language: language
|
||||
lang: lang.toLowerCase()
|
||||
country: country.toUpperCase()
|
||||
lang: lang?.toLowerCase()
|
||||
country: country?.toUpperCase()
|
||||
}
|
||||
|
||||
exports.calcLanguagePriority = (req) ->
|
||||
@@ -88,6 +89,7 @@ exports.getTranslator = (req) ->
|
||||
return result
|
||||
|
||||
exports.pickClientLocale = (req) ->
|
||||
console.log req.cookies
|
||||
cache_key = "client.locale:#{req.cookies['language']}/#{req.headers['accept-language']}"
|
||||
cached_result = cache.counter.get cache_key
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ html
|
||||
for hook in selectHook('view.layout.styles')
|
||||
link(rel='stylesheet', href=hook.path)
|
||||
|
||||
body(data-locale-version=app.i18n.clientLocaleHash(res))
|
||||
body(data-locale-version=app.i18n.clientLocaleHash(req))
|
||||
header.navbar-fixed-top
|
||||
.container
|
||||
nav.navbar.navbar-default.navbar-inverse(role='navigation')
|
||||
@@ -75,8 +75,7 @@ html
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
ga('create', '#{config.web.google_analytic
|
||||
s_id}', 'auto');
|
||||
ga('create', '#{config.web.google_analytics_id}', 'auto');
|
||||
ga('send', 'pageview');
|
||||
script(src='http://cdn.staticfile.org/jquery/2.0.3/jquery.min.js')
|
||||
script(src='http://cdn.staticfile.org/jquery-cookie/1.4.1/jquery.cookie.min.js')
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
"tmp": "^0.0.24",
|
||||
"underscore": "^1.6.0",
|
||||
"json-stable-stringify": "^1.0.0",
|
||||
"counter-cache": "^0.1.0"
|
||||
"counter-cache": "^0.1.0",
|
||||
"cookie-parser": "^1.3.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
extends ../../../core/view/layout
|
||||
|
||||
prepend head
|
||||
prepend header
|
||||
title RP 主机:Linux 虚拟主机 | #{t('app.name')}
|
||||
|
||||
append head
|
||||
append header
|
||||
link(rel='stylesheet', href='/plugin/rpvhost/style/index.css')
|
||||
|
||||
block content
|
||||
|
||||
Reference in New Issue
Block a user