Commit 5d654d249a5d096cfdddd35bd9c143c3f7447b12
1 parent
3712c373f9
Exists in
master
interface change
Showing
1 changed file
with
5 additions
and
7 deletions
Show diff stats
localization.go
... | ... | @@ -4,7 +4,6 @@ import ( |
4 | 4 | "encoding/json" |
5 | 5 | "errors" |
6 | 6 | "io/ioutil" |
7 | - "net/http" | |
8 | 7 | "strings" |
9 | 8 | "sync" |
10 | 9 | ) |
... | ... | @@ -72,20 +71,19 @@ func (d *Dictionary) GetDefaultLocale() string { |
72 | 71 | return d.defaultLocale |
73 | 72 | } |
74 | 73 | |
75 | -func (d *Dictionary) GetBestMatchLocale(req *http.Request) (best string) { | |
76 | - accepted := d.parseAcceptedLanguageHeader(req) | |
74 | +func (d *Dictionary) GetBestMatchLocale(acceptedLanguages string) (best string) { | |
75 | + accepted := d.parseAcceptedLanguageHeader(acceptedLanguages) | |
77 | 76 | best = accepted[0] |
78 | 77 | return |
79 | 78 | } |
80 | 79 | |
81 | -func (d *Dictionary) parseAcceptedLanguageHeader(req *http.Request) (langs []string) { | |
82 | - a := req.Header.Get("Accepted-Language") | |
83 | - if a == "" { | |
80 | +func (d *Dictionary) parseAcceptedLanguageHeader(acceptedLanguages string) (langs []string) { | |
81 | + if acceptedLanguages == "" { | |
84 | 82 | langs = append(langs, d.GetDefaultLocale()) |
85 | 83 | return |
86 | 84 | } |
87 | 85 | |
88 | - parts := strings.Split(a, ",") | |
86 | + parts := strings.Split(acceptedLanguages, ",") | |
89 | 87 | for _, p := range parts { |
90 | 88 | langs = append(langs, p) |
91 | 89 | } | ... | ... |