SetLocaleMiddleware class final
Picks the request's locale from ?lang= (or query) or the
Accept-Language header, among supported, and makes it the locale of
the request: trans, App.locale and validation messages follow it.
Without a match the application locale stays.
middleware.use(const [SetLocaleMiddleware(supported: ['en', 'id'])]);
- Implemented types
Constructors
-
SetLocaleMiddleware({required List<
String> supported, String? query = 'lang'}) -
const
Properties
Methods
-
handle(
Request request, Next next) → Future< Response> -
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
match(
String? tag, List< String> supported) → String? -
The entry of
supportedfortag(id-IDmatchesid_ID, thenid), ignoring case;nullwhen none fits. -
negotiate(
String? header, List< String> supported) → String? -
The best of
supportedfor anAccept-Languageheader(id-ID,id;q=0.9,en;q=0.8): highest quality first,q=0excluded.