Class TranslationFileRequestHandler

java.lang.Object
com.vaadin.flow.i18n.TranslationFileRequestHandler
All Implemented Interfaces:
SessionlessRequestHandler, Serializable

public class TranslationFileRequestHandler extends Object implements SessionlessRequestHandler
Handles translation file requests. Translation file requests are internal requests sent by the client-side to retrieve the translations for the specified language tag. The response contains the translations in JSON format. The requested language tag 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 translations are those of the I18NProvider: all of them for the locale when the request names no keys, otherwise the keys of the requested chunks, as listed in vaadin-i18n/i18n.json, together with the requested keys. Which bundle answers for the locale is up to the provider.

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 Details

    • TranslationFileRequestHandler

      public TranslationFileRequestHandler(I18NProvider i18NProvider, ClassLoader classLoader)
  • Method Details

    • handleRequest

      public boolean handleRequest(VaadinRequest request, VaadinResponse response) throws IOException
      Handles translation file requests. Translations only depend on the I18NProvider and the requested locale, so they are served without a session.
      Specified by:
      handleRequest in interface SessionlessRequestHandler
      Parameters:
      request - the request to handle
      response - the response object to which a response can be written
      Returns:
      true if the request was handled, false if this handler does not handle the given request type
      Throws:
      IOException - if an IO error occurred
      Since:
      25.4