Mercurial > dive4elements > river
changeset 8248:2b0ff11cef3f
Fix duration curve i18n.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Tue, 09 Sep 2014 18:41:11 +0200 |
parents | b8f343230eab |
children | d81c4b0d5ca7 |
files | artifacts/src/main/java/org/dive4elements/river/exports/ChartGenerator.java artifacts/src/main/java/org/dive4elements/river/exports/DurationCurveExporter.java artifacts/src/main/java/org/dive4elements/river/exports/DurationCurveGenerator.java artifacts/src/main/resources/messages.properties artifacts/src/main/resources/messages_de.properties artifacts/src/main/resources/messages_de_DE.properties |
diffstat | 6 files changed, 30 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/ChartGenerator.java Tue Sep 09 17:05:21 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/ChartGenerator.java Tue Sep 09 18:41:11 2014 +0200 @@ -16,6 +16,8 @@ import org.dive4elements.artifacts.CallMeta; import org.dive4elements.artifacts.PreferredLocale; import org.dive4elements.artifacts.common.utils.XMLUtils; + +import org.dive4elements.river.artifacts.access.RiverAccess; import org.dive4elements.river.artifacts.access.RangeAccess; import org.dive4elements.river.artifacts.D4EArtifact; import org.dive4elements.river.artifacts.resources.Resources; @@ -1412,18 +1414,23 @@ return Resources.getMsg(context.getMeta(), key, key); } + protected String msg(String key, Object[] args) { + return Resources.getMsg(context.getMeta(), key, key, args); + } + protected String msg(String key, String def, Object[] args) { return Resources.getMsg(context.getMeta(), key, def, args); } protected String getRiverName() { - D4EArtifact flys = (D4EArtifact) master; - - River river = RiverUtils.getRiver(flys); - return (river != null) ? river.getName() : ""; + return new RiverAccess((D4EArtifact)master).getRiver().getName(); } + protected String getRiverUnit() { + return new RiverAccess((D4EArtifact)master).getRiver() + .getWstUnit().getName(); + } protected double[] getRange() { D4EArtifact flys = (D4EArtifact) master;
--- a/artifacts/src/main/java/org/dive4elements/river/exports/DurationCurveExporter.java Tue Sep 09 17:05:21 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/DurationCurveExporter.java Tue Sep 09 18:41:11 2014 +0200 @@ -32,6 +32,7 @@ import org.dive4elements.river.artifacts.D4EArtifact; +import org.dive4elements.river.artifacts.access.RiverAccess; import org.dive4elements.river.artifacts.access.RangeAccess; import org.dive4elements.river.artifacts.model.WQDay; import org.dive4elements.river.artifacts.model.CalculationResult; @@ -60,10 +61,6 @@ public static final String CSV_Q_HEADER = "export.duration.curve.csv.header.q"; - public static final String DEFAULT_CSV_DURATION_HEADER = "D [Tagen]"; - public static final String DEFAULT_CSV_W_HEADER = "W [NN + m]"; - 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"; @@ -99,10 +96,13 @@ protected void writeCSVHeader(CSVWriter writer) { log.info("DurationCurveExporter.writeCSVHeader"); + String unit = new RiverAccess((D4EArtifact)master) + .getRiver().getWstUnit().getName(); + writer.writeNext(new String[] { - msg(CSV_W_HEADER, DEFAULT_CSV_W_HEADER), - msg(CSV_Q_HEADER, DEFAULT_CSV_Q_HEADER), - msg(CSV_DURATION_HEADER, DEFAULT_CSV_DURATION_HEADER) + msg(CSV_W_HEADER, new Object[] { unit }), + msg(CSV_Q_HEADER), + msg(CSV_DURATION_HEADER) }); }
--- a/artifacts/src/main/java/org/dive4elements/river/exports/DurationCurveGenerator.java Tue Sep 09 17:05:21 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/DurationCurveGenerator.java Tue Sep 09 18:41:11 2014 +0200 @@ -58,8 +58,11 @@ public static final String I18N_XAXIS_LABEL = "chart.duration.curve.xaxis.label"; - public static final String I18N_YAXIS_LABEL = - "chart.duration.curve.yaxis.label"; + public static final String I18N_YAXIS_LABEL_W = + "chart.duration.curve.yaxis.label.w"; + + public static final String I18N_YAXIS_LABEL_Q = + "chart.duration.curve.yaxis.label.q"; public static final String I18N_CHART_TITLE_DEFAULT = "Dauerlinie"; @@ -67,9 +70,6 @@ public static final String I18N_XAXIS_LABEL_DEFAULT = "Unterschreitungsdauer [Tage]"; - public static final String I18N_YAXIS_LABEL_DEFAULT = - "W [NN + m]"; - public DurationCurveGenerator() { super(); @@ -123,12 +123,10 @@ protected String getDefaultYAxisLabel(int index) { String label = "default"; if (index == YAXIS.W.idx) { - label = msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT); + label = msg(I18N_YAXIS_LABEL_W, new Object[] { getRiverUnit() }); } else if (index == YAXIS.Q.idx) { - // TODO i18n for this label - label = "Q [m\u00b3/s]"; - //label = msg(get2YAxisLabelKey(), get2YAxisDefaultLabel()); + label = msg(I18N_YAXIS_LABEL_Q); } return label;
--- a/artifacts/src/main/resources/messages.properties Tue Sep 09 17:05:21 2014 +0200 +++ b/artifacts/src/main/resources/messages.properties Tue Sep 09 18:41:11 2014 +0200 @@ -379,7 +379,7 @@ export.computed.discharge.curve.csv.header.w = W [{0}] export.computed.discharge.curve.csv.header.q = Q [m\u00b3/s] export.duration.curve.csv.header.duration = D [Days] -export.duration.curve.csv.header.w = W [NN + m] +export.duration.curve.csv.header.w = W [{0}] export.duration.curve.csv.header.q = Q [m\u00b3/s] export.discharge.longitudinal.section.csv.header.km = River-Km export.discharge.longitudinal.section.csv.header.w = W [NN + m]
--- a/artifacts/src/main/resources/messages_de.properties Tue Sep 09 17:05:21 2014 +0200 +++ b/artifacts/src/main/resources/messages_de.properties Tue Sep 09 18:41:11 2014 +0200 @@ -379,7 +379,7 @@ export.waterlevel.csv.not.in.gauge.range = au\u00dferh. d. Bez.pegels export.computed.discharge.curve.csv.header.w = W [{0}] export.computed.discharge.curve.csv.header.q = Q [m\u00b3/s] -export.duration.curve.csv.header.duration = D [Tagen] +export.duration.curve.csv.header.duration = D [Tage] export.duration.curve.csv.header.w = W [{0}] export.duration.curve.csv.header.q = Q [m\u00b3/s] export.discharge.longitudinal.section.csv.header.km = Fluss-Km
--- a/artifacts/src/main/resources/messages_de_DE.properties Tue Sep 09 17:05:21 2014 +0200 +++ b/artifacts/src/main/resources/messages_de_DE.properties Tue Sep 09 18:41:11 2014 +0200 @@ -179,7 +179,8 @@ chart.duration.curve.title = Dauerlinie chart.duration.curve.subtitle = {0}-km: {1,number,#.###} chart.duration.curve.xaxis.label = Unterschreitungsdauer [Tage] -chart.duration.curve.yaxis.label = W [NN + m] +chart.duration.curve.yaxis.label.w = W [{0}] +chart.duration.curve.yaxis.label.q = Q [m\u00b3/s] chart.duration.curve.curve.w = Wasserstandsdauerline f\u00fcr {0} (km:{1}) chart.duration.curve.curve.q = Abflussdauerline f\u00fcr {0} (km:{1}) chart.historical.discharge.title = Historische Abflusskurven @@ -376,7 +377,7 @@ export.waterlevel.csv.not.in.gauge.range = au\u00dferh. d. Bez.pegels export.computed.discharge.curve.csv.header.w = W [{0}] export.computed.discharge.curve.csv.header.q = Q [m\u00b3/s] -export.duration.curve.csv.header.duration = D [Tagen] +export.duration.curve.csv.header.duration = D [Tage] export.duration.curve.csv.header.w = W [{0}] export.duration.curve.csv.header.q = Q [m\u00b3/s] export.discharge.longitudinal.section.csv.header.km = Fluss-Km