The new Ripple frontend.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

localisation.go 550B

1234567891011121314151617181920212223
  1. package main
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "zxq.co/ripple/hanayo/modules/locale"
  5. )
  6. // T translates a string into the language specified by the request.
  7. func T(c *gin.Context, s string, args ...interface{}) string {
  8. return locale.Get(getLang(c), s, args...)
  9. }
  10. func (b *baseTemplateData) T(s string, args ...interface{}) string {
  11. return T(b.Gin, s, args...)
  12. }
  13. func getLang(c *gin.Context) []string {
  14. s, _ := c.Cookie("language")
  15. if s != "" {
  16. return []string{s}
  17. }
  18. return locale.ParseHeader(c.Request.Header.Get("Accept-Language"))
  19. }