Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it Possible to have more than one messages file in Play framework

We have a site which will be used for two different clients. During first request the user will be asked to choose a client. Based on that text,labels and site content should be displayed.

Is it possible to have two messages file in Play framework and during session startup the messages file would be decided

As of my research we can have more than a file for each Locale, the messages will be get based on locale in the request.

like image 692
Selvakumar Ponnusamy Avatar asked Dec 12 '11 08:12

Selvakumar Ponnusamy


People also ask

Why play framework is used?

Play Framework makes it easy to build web applications with Java & Scala. Play is based on a lightweight, stateless, web-friendly architecture. Built on Akka, Play provides predictable and minimal resource consumption (CPU, memory, threads) for highly-scalable applications.

Is play a Java framework?

Play is a high-productivity web application framework for programming languages whose code is compiled and run on the JVM, mainly Java and Scala. It integrates the components and APIs we need for modern web application development.

Which property is used to specify supported language of the play application?

To ensure that languages are resolved correctly, specify the languages your app supports using the resConfigs property in the module-level build.


1 Answers

No, it is not supported at the moment. You can easily do that either in a plugin(Look at MessagesPlugin ) or even using a bootstrap job with the @onApplicationStartup annotation

// From MessagesPlugin.java

//default languange messages
VirtualFile appDM = Play.getVirtualFile("conf/messages");
if(appDM != null && appDM.exists()) {
    Messages.defaults.putAll(read(appDM));
}

static Properties read(VirtualFile vf) {
    if (vf != null) {
        return IO.readUtf8Properties(vf.inputstream());
    }
    return null;
}
like image 175
mericano1 Avatar answered Sep 30 '22 13:09

mericano1