Unable to get I18N localization to work

Hi All,

I am new to Vaadin and am trying to get I18N localization to work. As an implementation example, I attempted to follow the steps on the Internationalization training video and an initial test, I am trying to get the Hint text on the login screen to display by getting the text from the translation.properties Resource Bundle file, but when I click on “Forgot password” on the login screen, I get “!{login.hint.message.key}!” instead of the text “Hint: same as username”.

I would really appreciate it if I could be pointed in the right direction, as to what I am missing or where I am going wrong.

Thanking you in anticipation.

Please find attached translation.properties, TranslationProvider.java and LoginScreen.java files.
18321667.properties (79 Bytes)
18321670.java (828 Bytes)
18321673.java (4.05 KB)

Your I18NProvider does not wrap the key inside !{ ... }! if it doesn’t find the key in the bundle. If you look at the only usage of I18NProvider::getTranslation (at Component::getTranslation), you will see that it does that wrapping because it doesn’t find your I18NProvider in the first place.

You must tell Vaadin where to find your I18NProvider implementation. You can do that easiest with a @Component annotation if you are using Spring, or otherwise you can [tell vaadin with a system property]
(https://vaadin.com/learn/tutorials/i18n/i18nprovider#_activation_of_the_implementation) vaadin.i18n.provider

Hi Kaspar,

Thank you for the swift response. I am using Spring, However, I have attempted placing the @Component annotation, as follows (please see extract of TranslationProvider.java below) and the issue still persists:

import com.vaadin.flow.i18n.I18NProvider;
import org.springframework.stereotype.Component;

import java.text.MessageFormat;
import java.util.*;

@Component
public class TranslationProvider implements I18NProvider {

Is your TranslationProvider being scanned by @ComponentScan in a configuration class?