1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-09 13:05:56 +00:00

Update to 6.1.2

This commit is contained in:
Gerasimos (Makis) Maropoulos
2017-01-13 05:57:46 +02:00
parent c73c2a00c3
commit f380d710cc
5 changed files with 83 additions and 6 deletions

View File

@@ -2,6 +2,64 @@
**How to upgrade**: remove your `$GOPATH/src/github.com/kataras` folder, open your command-line and execute this command: `go get -u github.com/kataras/iris/iris`.
## 6.1.1 -> 6.1.2
Better internalization and localization support, with ability to change the cookie's key and context's keys.
- Real example: https://github.com/iris-contrib/examples/tree/master/middleware_internationalization_i18n
**read the comments:**
```go
package main
import (
"github.com/iris-contrib/middleware/i18n"
"github.com/kataras/iris"
)
func main() {
iris.Use(i18n.New(i18n.Config{
Default: "en-US",
URLParameter: "lang",
Languages: map[string]string{
"en-US": "./locales/locale_en-US.ini",
"el-GR": "./locales/locale_el-GR.ini",
"zh-CN": "./locales/locale_zh-CN.ini"}}))
iris.Get("/", func(ctx *iris.Context) {
// it tries to find the language by:
// ctx.Get("language") , that should be setted on other middleware before the i18n middleware*
// if that was empty then
// it tries to find from the URLParameter setted on the configuration
// if not found then
// it tries to find the language by the "lang" cookie
// if didn't found then it it set to the Default setted on the configuration
// hi is the key, 'kataras' is the %s on the .ini file
// the second parameter is optional
// hi := ctx.Translate("hi", "kataras")
// or:
hi := i18n.Translate(ctx, "hi", "kataras")
language := ctx.Get(iris.TranslateLanguageContextKey) // language is the language key, example 'en-US'
// The first succeed language found saved at the cookie with name ("language"),
// you can change that by changing the value of the: iris.TranslateLanguageContextKey
ctx.Writef("From the language %s translated output: %s", language, hi)
})
// go to http://localhost:8080/?lang=el-GR
// or http://localhost:8080
// or http://localhost:8080/?lang=zh-CN
iris.Listen(":8080")
}
```
## 6.1.0 -> 6.1.1
- **NEW FEATURE**: `Offline routes`.