MCPcopy
hub / github.com/github/docs / getLanguageCodeFromPath

Function getLanguageCodeFromPath

middleware/detect-language.js:50–53  ·  view source on GitHub ↗
(path)

Source from the content-addressed store, hash-verified

48
49// determine language code from a path. Default to en if no valid match
50export function getLanguageCodeFromPath(path) {
51 const maybeLanguage = (path.split('/')[path.startsWith('/_next/data/') ? 4 : 1] || '').slice(0, 2)
52 return languageKeys.includes(maybeLanguage) ? maybeLanguage : 'en'
53}
54
55export function getLanguageCodeFromHeader(req) {
56 const browserLanguages = parser.parse(req.headers['accept-language'])

Callers 1

detectLanguageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected