M core/local.go => core/local.go +6 -1
@@ 8,7 8,7 @@ import (
"hg.code.netlandish.com/~netlandish/gobwebs/server"
)
-var sessionLanguage string = "sess_language"
+var sessionLanguage string = "_language"
// SetLang sets language in the users session
func SetLang(c echo.Context, lang string) error {
@@ 28,6 28,11 @@ func GetLang(c echo.Context) string {
return lang
}
+// GetDefaultLang returns the server set DefaultLang
+func GetDefaultLang() string {
+ return localizer.DefaultLang
+}
+
// GetLocalizer fetches a Localizer for given language using the Gatalog
// (gobwebs specific) language catalog
func GetLocalizer(lang string) (*localizer.Localizer, bool) {
M core/template.go => core/template.go +7 -0
@@ 7,6 7,13 @@ import (
"hg.code.netlandish.com/~netlandish/gobwebs/server"
)
+// AddContext will add the echo.Context into the template namespace
+func AddContext(c echo.Context) gobwebs.Map {
+ return gobwebs.Map{
+ "context": c,
+ }
+}
+
// LoadMessages loads all session flash messages into template data
// context under the variable name `messages`
func LoadMessages(c echo.Context) gobwebs.Map {