Kind: Constant
Source: src/middleware/language/language.ts
Part of: Middleware
Collection of all language detection strategies
detectors is the collection of language detection strategies used by the language middleware. The middleware checks these strategies to determine the language for an incoming request and apply the selected language to downstream processing.
Definition
ts{
querystring: detectFromQuery,
cookie: detectFromCookie,
header: detectFromHeader,
path: detectFromPath,
} as const
Value
ts{
querystring: detectFromQuery,
cookie: detectFromCookie,
header: detectFromHeader,
path: detectFromPath,
} as const
Diagram
mermaidgraph LR Request[Incoming request] --> Middleware[Language middleware] Middleware --> Detectors[detectors] Detectors --> Strategy[Language detection strategy] Strategy --> Language[Detected language] Language --> Context[Request language context]
Usage
tsimport { detectors } from './middleware/language/language';
// Inspect the detection strategies registered with the language middleware.
for (const detector of detectors) {
console.log(detector);
}
AI Coding Instructions
- Keep each entry in
detectorscompatible with the language middleware's expected detector contract. - Add new language detection strategies to this collection so the middleware can evaluate them.
- Preserve detector ordering when precedence affects which language source is selected.
- Update related middleware tests when adding, removing, or changing a detector.
- Avoid placing request-specific state in the shared
detectorscollection.
Was this page helpful?