0

As I need that Play application should load and read a single message file, I was thinking of calling loadMessages() method of MessagesPlugin class of Scala from my Application class of Java and pass the path of single message file. I am assuming that when my application will boot , it will call loadMessages() method of Scala and create map of single message file. Kindly rectify if my understanding is wrong.

As I am totally new to Scala programming , kindly rectify me If I am calling Scala method in Java class in wrong way:

import play.api.i18n.MessagesPlugin;
class Application{
      private static boolean renderHomePage(){
        language="en";        
        String configPath=System.getProperty("IUI_CONFIG_DIR");
        MessagesPlugin.loadMessages(configPath+"/"+language+"/messages."+language);
        changeLang(language);       
        setSessionData(true);
        return true;
    }
}

But my above code is unable to recognize loadMessages(). Do I need to import something else.

1 Answer 1

1

As you can see here, loadMessages is protected. You have to extend MessagesPlugin to be able to call that method.

Sign up to request clarification or add additional context in comments.

3 Comments

In your link , method is shown as protected and in this link loadMessages method is private.So which one I should refer.
Depends on your version. My link is from master (newest version), yours is from version 2.0.
I am using 2.1.3 version of play in my project and in that loadMessages method is private. Can we override private method of scala in java?If yes , any link or example will be highly useful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.