replace zxq.co/ripple/hanayo

This commit is contained in:
Alicia
2019-02-23 13:29:15 +00:00
commit c3d206c173
5871 changed files with 1353715 additions and 0 deletions

23
localisation.go Normal file
View File

@@ -0,0 +1,23 @@
package main
import (
"github.com/gin-gonic/gin"
"github.com/osuYozora/hanayo/modules/locale"
)
// T translates a string into the language specified by the request.
func T(c *gin.Context, s string, args ...interface{}) string {
return locale.Get(getLang(c), s, args...)
}
func (b *baseTemplateData) T(s string, args ...interface{}) string {
return T(b.Gin, s, args...)
}
func getLang(c *gin.Context) []string {
s, _ := c.Cookie("language")
if s != "" {
return []string{s}
}
return locale.ParseHeader(c.Request.Header.Get("Accept-Language"))
}