Skip to content

Getting 'en_US.UTF-8' instead of 'en' #39

@wmertens

Description

@wmertens

When the browser sends a preference for 'en_US.UTF-8' and the provided locale list has 'en', I would expect the locale to be set to 'en', not the full string. Is that a wrong assumption?

I'm using express 4 and

import locale from 'locale'
const languages = ['en', 'nl']
app.use(locale(languages), (req, res, next) => {
		if (!languages.includes(req.locale)) {
			console.error(`!!! ${req.locale} was badly picked by locale`)
			req.locale = languages[0]
		}
		next()
})

to detect this situation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions