How florrain/locale works
locale is a small Node.js library for choosing a locale from an HTTP request’s Accept-Language header. Its main workflow parses the request and supported locales, selects the best match, and attaches that result to the request for downstream middleware. The same module also exposes Locale and Locales APIs for standalone use. Runtime relationships are supported by the excerpted lib/index.js; the README documents standalone and Express/Connect use.
Main entry points: index.js Locale middleware
Components 6
Other components
- HTTP request
- Locale middleware
lib/index.js - Locales parser
lib/index.js - Best-match selector
lib/index.js - Locale value
lib/index.js - Downstream handler
Connections 9
- HTTP request → Locale middleware: provides header
lib/index.js - Locale middleware → Locales parser: parses header
lib/index.js - Locale middleware → Locales parser: parses supported
lib/index.js - Locales parser → Locale value: constructs tags
lib/index.js - Locale middleware → Best-match selector: selects match
lib/index.js - Best-match selector → Locales parser: checks supported
lib/index.js - Best-match selector → Locale value: uses fallback
lib/index.js - Locale middleware → HTTP request: sets locale
lib/index.js - Locale middleware → Downstream handler: calls next
lib/index.js