magnolia

Internationalization version selector imputprompt


I am following this for internationalization document in magnolia cms 5.7.

I need to internationalize the version selector input prompt in the pagebar but cannot find the key for this value.

import com.vaadin.v7.ui.ComboBox;
private ComboBox versionSelector = new ComboBox();
    private Listener listener;



    public VersionSelectorViewImpl() {
        construct();
    }

    private void construct() {
        versionSelector.setVisible(false);
        versionSelector.setImmediate(true);
        versionSelector.setNullSelectionAllowed(false);
        versionSelector.setTextInputAllowed(false);
        versionSelector.setInputPrompt("Select a version"); //***this is the key I need ***
        versionSelector.addStyleName("version-selector");
        versionSelector.setSizeFull();
        

Solution

  • I was able to solve this by injecting SimpleTranslator in the constructor:

                private final SimpleTranslator i18n;
            
                @Inject
                public VersionSelectorViewImpl(SimpleTranslator i18n){
                    this.i18n = i18n;
                    construct();
                }
            
            
                private void construct() {
                    String inputPrompt = i18n.translate("module.pagebar.selectVersion");
                    
                    versionSelector.setInputPrompt(inputPrompt);
                    ...
                }
    

    and then passing the key value found in the message bundle file for each language respectively.

    An example is also found here info.magnolia.contacts.app.field.component.ContactPreviewComponent.