Skip to content
Snippets Groups Projects
Commit 95ac7108 authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Added i18n support

parent e8362df1
No related branches found
No related tags found
No related merge requests found
......@@ -62,6 +62,11 @@
<artifactId>cors-filter</artifactId>
<version>1.7.1</version>
</dependency>
<dependency>
<groupId>no.bioforsk.vips.model.</groupId>
<artifactId>NaerstadModel</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
......
......@@ -46,6 +46,22 @@ public class ModelResource {
/**
* Prints the usage instructions from the requested model
* @param modelId
* @param language two-letter code (<a href="http://www.loc.gov/standards/iso639-2/php/English_list.php">ISO-639-2</a>)
* @return
*/
@GET
@Path("models/{modelId}/usage/{language}")
@Produces("text/plain;charset=UTF-8")
public Response printModelUsage(@PathParam("modelId") String modelId, @PathParam("language") String language)
{
String usage = ModelFactory.getInstance().getModelUsage(modelId, language);
return Response.ok().entity(usage).build();
}
/**
* Prints the usage instructions from the requested model
* @param modelId
* @param language two-letter code (<a href="http://www.loc.gov/standards/iso639-2/php/English_list.php">ISO-639-2</a>)
* @return
*/
@GET
......@@ -53,8 +69,7 @@ public class ModelResource {
@Produces("text/plain;charset=UTF-8")
public Response printModelUsage(@PathParam("modelId") String modelId)
{
String usage = ModelFactory.getInstance().getModelUsage(modelId);
return Response.ok().entity(usage).build();
return this.printModelUsage(modelId, null);
}
/** Tests for XML and JSON output */
......
......@@ -149,14 +149,13 @@ public class ModelFactory {
}
/**
* TODO: Add support for locale
* @param modelId the id of the Model
* @return usage instructions for the requested Model
*
*/
public String getModelUsage(String modelId)
public String getModelUsage(String modelId, String language)
{
return this.models.get(modelId).getModelUsage();
return language != null ? this.models.get(modelId).getModelUsage(language) : this.models.get(modelId).getModelUsage();
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment