MCPcopy
hub / github.com/github/docs / detectLanguage

Function detectLanguage

middleware/detect-language.js:60–68  ·  view source on GitHub ↗
(req, res, next)

Source from the content-addressed store, hash-verified

58}
59
60export default function detectLanguage(req, res, next) {
61 req.language = getLanguageCodeFromPath(req.path)
62 // Detecting browser language by user preference
63 req.userLanguage = getUserLanguageFromCookie(req)
64 if (!req.userLanguage) {
65 req.userLanguage = getLanguageCodeFromHeader(req)
66 }
67 return next()
68}

Callers

nothing calls this directly

Calls 4

getLanguageCodeFromPathFunction · 0.85
nextFunction · 0.50

Tested by

no test coverage detected