summaryrefslogtreecommitdiff
path: root/utilities.go
diff options
context:
space:
mode:
authorHorus32015-03-23 23:17:51 +0100
committerHorus32015-03-23 23:17:51 +0100
commit05e32cd6787f3f5a48192a5604c5bd3e8e3defc7 (patch)
tree502697af748381e1cfd9cf0d0ea6ba324ad84921 /utilities.go
parentac1ee887205d068b7b1c1df690f157dda506e419 (diff)
downloadfreemail-05e32cd6787f3f5a48192a5604c5bd3e8e3defc7.tar.gz
German translation.
Diffstat (limited to 'utilities.go')
-rw-r--r--utilities.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/utilities.go b/utilities.go
index 60423dc..4bf0b92 100644
--- a/utilities.go
+++ b/utilities.go
@@ -4,6 +4,9 @@ import (
"crypto/md5"
"fmt"
"io"
+ "log"
+ "net/http"
+ "strings"
)
// Hashs and returns a string (md5)
@@ -26,3 +29,27 @@ func CompareStrings(strs ...string) bool {
}
return true
}
+
+func GetLanguage(r *http.Request) string {
+ c, err := r.Cookie("lang")
+ if err != nil {
+ log.Println("Cookie: lang", err)
+ } else {
+ if c.Value != "" {
+ if c.Value == "de" {
+ return "_" + c.Value
+ } else {
+ return ""
+ }
+ }
+ }
+ if len(r.Header["Accept-Language"]) == 0 {
+ return ""
+ }
+ lang := r.Header["Accept-Language"][0]
+ l := strings.TrimSpace(strings.Split(lang, ",")[0])
+ if l == "de" {
+ return "_" + l
+ }
+ return ""
+}