aboutsummaryrefslogtreecommitdiff
path: root/i18n.patch
blob: 07916c342049682c681d6dd1586291ec59b2c57a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
diff --git a/honk-0.9.6/web.go.orig b/honk-0.9.6/web.go
index 600f28b..cadca17 100644
--- a/web.go
+++ b/web.go
@@ -85,6 +85,9 @@ func getInfo(r *http.Request) map[string]interface{} {
 	templinfo["IconName"] = iconName
 	templinfo["UserInfo"] = u
 	templinfo["UserSep"] = userSep
+    templinfo["Lang"] = getLangCookie(r)
+    templinfo["i18n"] = setLangStr(getLangCookie(r))
+
 	if u != nil {
 		var combos []string
 		combocache.Get(u.UserID, &combos)
@@ -99,12 +102,17 @@ func homepage(w http.ResponseWriter, r *http.Request) {
 	var honks []*Honk
 	var userid int64 = -1
 
-	templinfo["ServerMessage"] = serverMsg
+    templinfo["ServerMessage"] = serverMsg
 	if u == nil || r.URL.Path == "/front" {
 		switch r.URL.Path {
 		case "/events":
 			honks = geteventhonks(userid)
-			templinfo["ServerMessage"] = "some recent and upcoming events"
+            switch templinfo["Lang"] {
+                case "fr":
+                    templinfo["ServerMessage"] = "quelques évenements récents et à venir"
+                default:
+                    templinfo["ServerMessage"] = "some recent and upcoming events"
+            }
 		default:
 			templinfo["ShowRSS"] = true
 			honks = getpublichonks()
@@ -113,17 +121,32 @@ func homepage(w http.ResponseWriter, r *http.Request) {
 		userid = u.UserID
 		switch r.URL.Path {
 		case "/atme":
-			templinfo["ServerMessage"] = "at me!"
+            switch templinfo["Lang"] {
+                case "fr":
+                    templinfo["ServerMessage"] = "pour moi!"
+                default:
+                    templinfo["ServerMessage"] = "at me!"
+            }
 			templinfo["PageName"] = "atme"
 			honks = gethonksforme(userid, 0)
 			honks = osmosis(honks, userid, false)
 		case "/longago":
-			templinfo["ServerMessage"] = "long ago and far away!"
+            switch templinfo["Lang"] {
+                case "fr":
+                    templinfo["ServerMessage"] = "il y a longtemps"
+                default:
+			        templinfo["ServerMessage"] = "long ago and far away!"
+            }
 			templinfo["PageName"] = "longago"
 			honks = gethonksfromlongago(userid, 0)
 			honks = osmosis(honks, userid, false)
 		case "/events":
-			templinfo["ServerMessage"] = "some recent and upcoming events"
+            switch templinfo["Lang"] {
+                case "fr":
+                    templinfo["ServerMessage"] = "quelques événements récents et à venir"
+                default:
+                    templinfo["ServerMessage"] = "some recent and upcoming events"
+            }
 			templinfo["PageName"] = "events"
 			honks = geteventhonks(userid)
 			honks = osmosis(honks, userid, true)
@@ -132,7 +155,12 @@ func homepage(w http.ResponseWriter, r *http.Request) {
 			honks = gethonksforuserfirstclass(userid, 0)
 			honks = osmosis(honks, userid, true)
 		case "/saved":
-			templinfo["ServerMessage"] = "saved honks"
+            switch templinfo["Lang"] {
+                case "fr":
+                    templinfo["ServerMessage"] = "klaxons "
+                default:
+                    templinfo["ServerMessage"] = "saved honks"
+            }
 			templinfo["PageName"] = "saved"
 			honks = getsavedhonks(userid, 0)
 		default:
@@ -744,6 +772,8 @@ func showhonker(w http.ResponseWriter, r *http.Request) {
 	templinfo["PageArg"] = name
 	templinfo["ServerMessage"] = msg
 	templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r)
+    templinfo["Lang"] = getLangCookie(r)
+
 	honkpage(w, u, honks, templinfo)
 }
 
@@ -755,7 +785,12 @@ func showcombo(w http.ResponseWriter, r *http.Request) {
 	templinfo := getInfo(r)
 	templinfo["PageName"] = "combo"
 	templinfo["PageArg"] = name
-	templinfo["ServerMessage"] = "honks by combo: " + name
+    switch templinfo["Lang"] {
+        case "fr":
+	        templinfo["ServerMessage"] = "klaxons par groupes: " + name
+        default:
+	        templinfo["ServerMessage"] = "honks by combo: " + name
+    }
 	templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r)
 	honkpage(w, u, honks, templinfo)
 }
@@ -1120,8 +1155,9 @@ func saveuser(w http.ResponseWriter, r *http.Request) {
 		options.MapLink = ""
 	}
 	options.Reaction = r.FormValue("reaction")
-
-	sendupdate := false
+    setLangCookie(w, r)
+	
+    sendupdate := false
 	ava := re_avatar.FindString(whatabout)
 	if ava != "" {
 		whatabout = re_avatar.ReplaceAllString(whatabout, "")
@@ -2192,11 +2228,22 @@ func webhydra(w http.ResponseWriter, r *http.Request) {
 	case "atme":
 		honks = gethonksforme(userid, wanted)
 		honks = osmosis(honks, userid, false)
-		templinfo["ServerMessage"] = "at me!"
+        switch templinfo["Lang"] {
+            case "fr":
+		        templinfo["ServerMessage"] = "pour moi!"
+            default:
+		        templinfo["ServerMessage"] = "at me!"
+        }
 	case "longago":
 		honks = gethonksfromlongago(userid, wanted)
 		honks = osmosis(honks, userid, false)
-		templinfo["ServerMessage"] = "from long ago"
+
+        switch templinfo["Lang"] {
+            case "fr":
+                templinfo["ServerMessage"] = "il y a longtemps"
+            default:
+                templinfo["ServerMessage"] = "from long ago"
+        }
 	case "home":
 		honks = gethonksforuser(userid, wanted)
 		honks = osmosis(honks, userid, true)
@@ -2229,6 +2276,12 @@ func webhydra(w http.ResponseWriter, r *http.Request) {
 			</form>`, login.GetCSRF("submithonker", r), xid)
 		msg := templates.Sprintf(`honks by honker: <a href="%s" ref="noreferrer">%s</a>%s`, xid, xid, miniform)
 		templinfo["ServerMessage"] = msg
+        switch templinfo["Lang"]{
+            case "fr":
+                templinfo["ServerMessage"] = "klaxons enregistrés"
+            default:
+                templinfo["ServerMessage"] = "saved honks"
+        }
 	default:
 		http.NotFound(w, r)
 	}
@@ -2454,6 +2507,7 @@ func serve() {
 	getters.HandleFunc("/server", serveractor)
 	posters.HandleFunc("/server/inbox", serverinbox)
 	posters.HandleFunc("/inbox", serverinbox)
+    posters.HandleFunc("/langcookie", setLangCookie)
 
 	getters.HandleFunc("/style.css", serveasset)
 	getters.HandleFunc("/local.css", serveasset)