Package com.vaadin.flow.i18n
Class TranslationFileRequestHandler
java.lang.Object
com.vaadin.flow.i18n.TranslationFileRequestHandler
- All Implemented Interfaces:
SessionlessRequestHandler,Serializable
Handles translation file requests. Translation file requests are internal
requests sent by the client-side to retrieve the translation file for the
specified language tag. The response contains the translations in JSON
format. Also, the language tag of the retrieved translation file is included
as a header with the name
X-Vaadin-Retrieved-Locale. The language tag
parameter langtag supports both dash and underscore as separators.
The translation file to return is determined by matching the requested locale to the available bundles with the following prioritization order:
- Exact match
- Language and country match
- Language match
- Default bundle (root bundle)
This is a SessionlessRequestHandler, so the I18NProvider is
called without a VaadinSession: it gets the
requested locale and must not depend on
VaadinSession.getCurrent().
For internal use only. May be renamed or removed in a future release.
- Since:
- 24.4
- Author:
- Vaadin Ltd
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionTranslationFileRequestHandler(I18NProvider i18NProvider, ClassLoader classLoader) -
Method Summary
Modifier and TypeMethodDescriptionbooleanhandleRequest(VaadinRequest request, VaadinResponse response) Handles translation file requests.
-
Constructor Details
-
TranslationFileRequestHandler
-
-
Method Details
-
handleRequest
Handles translation file requests. Translations only depend on theI18NProviderand the requested locale, so they are served without a session.- Specified by:
handleRequestin interfaceSessionlessRequestHandler- Parameters:
request- the request to handleresponse- the response object to which a response can be written- Returns:
trueif the request was handled,falseif this handler does not handle the given request type- Throws:
IOException- if an IO error occurred
-