# HG changeset patch # User Raimund Renkert # Date 1327665515 0 # Node ID a9a8df1473fd78eb22ec069f6d061512e5a3bb96 # Parent fc86fcfe503e08c5c7becc3890e9a8c8c30750b6 Added i18n support to PDF report export. flys-artifacts/trunk@3789 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r fc86fcfe503e -r a9a8df1473fd flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Fri Jan 27 11:19:16 2012 +0000 +++ b/flys-artifacts/ChangeLog Fri Jan 27 11:58:35 2012 +0000 @@ -1,3 +1,29 @@ +2012-01-27 Raimund Renkert + + * src/main/java/de/intevation/flys/exports/WaterlevelExporter.java, + src/main/java/de/intevation/flys/exports/DurationCurveExporter.java, + src/main/java/de/intevation/flys/exports/ComputedDischargeCurveExporter.java, + src/main/java/de/intevation/flys/exports/WDifferencesExporter.java: + Read jasper template file from resources to support i18n reports. + + * doc/conf/jasper/wdifferences.jasper, + doc/conf/jasper/duration.jasper, + doc/conf/jasper/computed-discharge.jasper, + doc/conf/jasper/waterlevel.jasper: + Updated report template. Resized left margin. + + * doc/conf/jasper/computed-discharge_en.jasper, + doc/conf/jasper/duration_en.jasper, + doc/conf/jasper/wdifferences_en.jasper, + doc/conf/jasper/waterlevel_en.jasper: + New. Templates for english reports. + + * src/main/resources/messages.properties, + src/main/resources/messages_de_DE.properties, + src/main/resources/messages_en.properties, + src/main/resources/messages_de.properties: + Added i18n strings for template files and modes. + 2012-01-27 Felix Wolfsteller * src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java, diff -r fc86fcfe503e -r a9a8df1473fd flys-artifacts/doc/conf/jasper/computed-discharge.jasper Binary file flys-artifacts/doc/conf/jasper/computed-discharge.jasper has changed diff -r fc86fcfe503e -r a9a8df1473fd flys-artifacts/doc/conf/jasper/computed-discharge_en.jasper Binary file flys-artifacts/doc/conf/jasper/computed-discharge_en.jasper has changed diff -r fc86fcfe503e -r a9a8df1473fd flys-artifacts/doc/conf/jasper/duration.jasper Binary file flys-artifacts/doc/conf/jasper/duration.jasper has changed diff -r fc86fcfe503e -r a9a8df1473fd flys-artifacts/doc/conf/jasper/duration_en.jasper Binary file flys-artifacts/doc/conf/jasper/duration_en.jasper has changed diff -r fc86fcfe503e -r a9a8df1473fd flys-artifacts/doc/conf/jasper/waterlevel.jasper Binary file flys-artifacts/doc/conf/jasper/waterlevel.jasper has changed diff -r fc86fcfe503e -r a9a8df1473fd flys-artifacts/doc/conf/jasper/waterlevel_en.jasper Binary file flys-artifacts/doc/conf/jasper/waterlevel_en.jasper has changed diff -r fc86fcfe503e -r a9a8df1473fd flys-artifacts/doc/conf/jasper/wdifferences.jasper Binary file flys-artifacts/doc/conf/jasper/wdifferences.jasper has changed diff -r fc86fcfe503e -r a9a8df1473fd flys-artifacts/doc/conf/jasper/wdifferences_en.jasper Binary file flys-artifacts/doc/conf/jasper/wdifferences_en.jasper has changed diff -r fc86fcfe503e -r a9a8df1473fd flys-artifacts/src/main/java/de/intevation/flys/exports/ComputedDischargeCurveExporter.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ComputedDischargeCurveExporter.java Fri Jan 27 11:19:16 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ComputedDischargeCurveExporter.java Fri Jan 27 11:58:35 2012 +0000 @@ -22,6 +22,8 @@ import net.sf.jasperreports.engine.JasperPrint; import net.sf.jasperreports.engine.JRException; +import de.intevation.artifacts.common.utils.Config; + import de.intevation.artifacts.CallContext; import de.intevation.artifacts.CallMeta; @@ -56,7 +58,7 @@ public static final String DEFAULT_CSV_Q_HEADER = "Q [m\u00b3/s]"; public static final String PDF_HEADER_MODE = "export.computed.discharge.pdf.mode"; - + public static final String JASPER_FILE = "export.computed.discharge.pdf.file"; protected List data; @@ -139,11 +141,18 @@ @Override protected void writePDF(OutputStream out) { WKmsJRDataSource source = createJRData(); + + String jasperFile = Resources.getMsg( + context.getMeta(), + JASPER_FILE, + "/jasper/computed-discharge_en.jasper"); + String confPath = Config.getConfigDirectory().toString(); + Map parameters = new HashMap(); parameters.put("ReportTitle", "Exported Data"); try { JasperPrint print = JasperFillManager.fillReport( - "conf/jasper/computed-discharge.jasper", + confPath + jasperFile, parameters, source); JasperExportManager.exportReportToPdfStream(print, out); diff -r fc86fcfe503e -r a9a8df1473fd flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveExporter.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveExporter.java Fri Jan 27 11:19:16 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/DurationCurveExporter.java Fri Jan 27 11:58:35 2012 +0000 @@ -23,6 +23,7 @@ import de.intevation.artifacts.CallContext; import de.intevation.artifacts.CallMeta; +import de.intevation.artifacts.common.utils.Config; import de.intevation.flys.artifacts.FLYSArtifact; @@ -58,6 +59,7 @@ public static final String DEFAULT_CSV_Q_HEADER = "Q [m\u00b3/s]"; public static final String PDF_HEADER_MODE = "export.duration.pdf.mode"; + public static final String JASPER_FILE = "export.duration.pdf.file"; /** The storage that contains all WQKms objects for the different facets. */ protected List data; @@ -168,11 +170,18 @@ @Override protected void writePDF(OutputStream out) { WKmsJRDataSource source = createJRData(); + + String jasperFile = Resources.getMsg( + context.getMeta(), + JASPER_FILE, + "/jasper/duration_en.jasper"); + String confPath = Config.getConfigDirectory().toString(); + Map parameters = new HashMap(); parameters.put("ReportTitle", "Exported Data"); try { JasperPrint print = JasperFillManager.fillReport( - "conf/jasper/duration.jasper", + confPath + jasperFile, parameters, source); JasperExportManager.exportReportToPdfStream(print, out); diff -r fc86fcfe503e -r a9a8df1473fd flys-artifacts/src/main/java/de/intevation/flys/exports/WDifferencesExporter.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/WDifferencesExporter.java Fri Jan 27 11:19:16 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/WDifferencesExporter.java Fri Jan 27 11:58:35 2012 +0000 @@ -24,6 +24,7 @@ import de.intevation.artifacts.CallContext; import de.intevation.artifacts.CallMeta; +import de.intevation.artifacts.common.utils.Config; import de.intevation.flys.artifacts.WINFOArtifact; @@ -54,6 +55,7 @@ public static final String WDIFF_DEFAULT_CSV_W_HEADER = "m"; public static final String PDF_HEADER_MODE = "export.wdifferences.pdf.mode"; + public static final String JASPER_FILE = "export.wdifferences.pdf.file"; /** The storage that contains all WKms objects for the different facets. */ protected List data; @@ -182,11 +184,18 @@ @Override protected void writePDF(OutputStream out) { WKmsJRDataSource source = createJRData(); + + String jasperFile = Resources.getMsg( + context.getMeta(), + JASPER_FILE, + "/jasper/wdifferences_en.jasper"); + String confPath = Config.getConfigDirectory().toString(); + Map parameters = new HashMap(); parameters.put("ReportTitle", "Exported Data"); try { JasperPrint print = JasperFillManager.fillReport( - "conf/jasper/wdifferences.jasper", + confPath + jasperFile, parameters, source); JasperExportManager.exportReportToPdfStream(print, out); diff -r fc86fcfe503e -r a9a8df1473fd flys-artifacts/src/main/java/de/intevation/flys/exports/WaterlevelExporter.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/WaterlevelExporter.java Fri Jan 27 11:19:16 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/WaterlevelExporter.java Fri Jan 27 11:58:35 2012 +0000 @@ -26,6 +26,7 @@ import de.intevation.artifacts.CallContext; import de.intevation.artifacts.CallMeta; +import de.intevation.artifacts.common.utils.Config; import de.intevation.flys.model.Gauge; @@ -117,6 +118,7 @@ "außerhalb des gewählten Bezugspegels"; public static final String PDF_HEADER_MODE = "export.waterlevel.pdf.mode"; + public static final String JASPER_FILE = "export.waterlevel.pdf.file"; /** The storage that contains all WQKms objects for the different facets.*/ protected List data; @@ -591,11 +593,19 @@ protected void writePDF(OutputStream out) { logger.debug("write PDF"); WKmsJRDataSource source = createJRData(); + + String jasperFile = Resources.getMsg( + context.getMeta(), + JASPER_FILE, + "/jasper/waterlevel_en.jasper"); + String confPath = Config.getConfigDirectory().toString(); + + Map parameters = new HashMap(); parameters.put("ReportTitle", "Exported Data"); try { JasperPrint print = JasperFillManager.fillReport( - "conf/jasper/waterlevel.jasper", + confPath + jasperFile, parameters, source); JasperExportManager.exportReportToPdfStream(print, out); diff -r fc86fcfe503e -r a9a8df1473fd flys-artifacts/src/main/resources/messages.properties --- a/flys-artifacts/src/main/resources/messages.properties Fri Jan 27 11:19:16 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages.properties Fri Jan 27 11:58:35 2012 +0000 @@ -108,6 +108,13 @@ export.discharge.curve.at.header = Computed Discharge Curve for {0} {0}-km: {1} export.waterlevel.pdf.mode = Waterlevel +export.computed.discharge.pdf.mode = Computed Dischargecurve +export.duration.pdf.mode = Durationcurve +export.wdifferences.pdf.mode = W Differences +export.computed.discharge.pdf.file = /jasper/computed-discharge_en.jasper +export.duration.pdf.file = /jasper/duration_en.jasper +export.waterlevel.pdf.file = /jasper/waterlevel_en.jasper +export.wdifferences.pdf.file = /jasper/wdifferences_en.jasper floodmap.wmsbackground = Background Map floodmap.riveraxis = River Axis diff -r fc86fcfe503e -r a9a8df1473fd flys-artifacts/src/main/resources/messages_de.properties --- a/flys-artifacts/src/main/resources/messages_de.properties Fri Jan 27 11:19:16 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages_de.properties Fri Jan 27 11:58:35 2012 +0000 @@ -108,6 +108,13 @@ export.discharge.curve.at.header = Berechnete Abflusskurve f\u00fcr {0} {0}-km: {1} export.waterlevel.pdf.mode = Wasserstand +export.computed.discharge.pdf.mode = Abflusskurve +export.duration.pdf.mode = Dauerlinie +export.wdifferences.pdf.mode = W Differenzen +export.computed.discharge.pdf.file = /jasper/computed-discharge.jasper +export.duration.pdf.file = /jasper/duration.jasper +export.waterlevel.pdf.file = /jasper/waterlevel.jasper +export.wdifferences.pdf.file = /jasper/wdifferences.jasper floodmap.wmsbackground = Hintergrundkarte floodmap.riveraxis = Flussachse diff -r fc86fcfe503e -r a9a8df1473fd flys-artifacts/src/main/resources/messages_de_DE.properties --- a/flys-artifacts/src/main/resources/messages_de_DE.properties Fri Jan 27 11:19:16 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages_de_DE.properties Fri Jan 27 11:58:35 2012 +0000 @@ -108,6 +108,13 @@ export.discharge.curve.at.header = Berechnete Abflusskurve f\u00fcr {0} {0}-km: {1} export.waterlevel.pdf.mode = Wasserstand +export.computed.discharge.pdf.mode = Abflusskurve +export.duration.pdf.mode = Dauerline +export.wdifferences.pdf.mode = W Differenzen +export.computed.discharge.pdf.file = /jasper/computed-discharge.jasper +export.duration.pdf.file = /jasper/duration.jasper +export.waterlevel.pdf.file = /jasper/waterlevel.jasper +export.wdifferences.pdf.file = /jasper/wdifferences.jasper floodmap.wmsbackground = Hintergrundkarte floodmap.riveraxis = Flussachse diff -r fc86fcfe503e -r a9a8df1473fd flys-artifacts/src/main/resources/messages_en.properties --- a/flys-artifacts/src/main/resources/messages_en.properties Fri Jan 27 11:19:16 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages_en.properties Fri Jan 27 11:58:35 2012 +0000 @@ -104,6 +104,13 @@ export.discharge.curve.at.header = Computed Discharge Curve for {0} {0}-km: {1} export.waterlevel.pdf.mode = Waterlevel +export.computed.discharge.pdf.mode = Computed Dischargecurve +export.duration.pdf.mode = Durationcurve +export.wdifferences.pdf.mode = W Differences +export.computed.discharge.pdf.file = /jasper/computed-discharge_en.jasper +export.duration.pdf.file = /jasper/duration_en.jasper +export.waterlevel.pdf.file = /jasper/waterlevel_en.jasper +export.wdifferences.pdf.file = /jasper/wdifferences_en.jasper floodmap.wmsbackground = Background Map floodmap.riveraxis = River Axis