mirror of
https://github.com/kataras/iris.git
synced 2025-02-09 02:34:55 +01:00
Update i18n middleware and toolkit methods to support IETF and RFC2616.
Add IETF matching method to vendor unkwon/i18n. Update i18n middleware to support RFC2616. Former-commit-id: 186f08dec3eb98df13bf2a0da61f0a31fe135358
This commit is contained in:
parent
351f099ad6
commit
3a3d1f24a1
|
@ -31,9 +31,16 @@ func (i *i18nMiddleware) ServeHTTP(ctx context.Context) {
|
||||||
if len(language) > 0 {
|
if len(language) > 0 {
|
||||||
wasByCookie = true
|
wasByCookie = true
|
||||||
} else {
|
} else {
|
||||||
// try to get by the request headers(?)
|
// try to get by the request headers.
|
||||||
if langHeader := ctx.GetHeader("Accept-Language"); i18n.IsExist(langHeader) {
|
langHeader := ctx.GetHeader("Accept-Language")
|
||||||
language = langHeader
|
if len(langHeader) > 0 {
|
||||||
|
for _, langEntry := range strings.Split(langHeader, ",") {
|
||||||
|
lc := strings.Split(langEntry, ";")[0]
|
||||||
|
if lc, ok := i18n.IsExistSimilar(lc); ok {
|
||||||
|
language = lc
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user