Merge pull request #5 from fdb-hiroshima/feature/multiple-local

Try to explore other locals if first is unknown
pull/8/head
Baptiste Gelez 6 years ago committed by GitHub
commit 4eec3d2fe3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -164,14 +164,14 @@ impl Fairing for I18n {
.headers()
.get_one(ACCEPT_LANG)
.unwrap_or("en")
// Get the first requested locale
// TODO: try the other ones if this one is not available
.split(",")
.nth(0)
.unwrap_or("en")
// Get the locale, not the country code
.split("-")
.nth(0)
.filter_map(|lang| lang
// Get the locale, not the country code
.split(|c| c=='-'||c==';')
.nth(0)
)
// Get the first requested locale we support
.find(|lang| get_locales().contains(&lang.to_string()))
.unwrap_or("en");
// We can't use setlocale(LocaleCategory::LcAll, lang), because it only accepts system-wide installed

Loading…
Cancel
Save