# HG changeset patch # User Fadi Abbud # Date 1571063206 -7200 # Node ID c47c8085cc7efa8186bfbdf1e01e8b73401e9d99 # Parent 7d2463c7b4ad96af8493518f2f2b00e2c7731237 client: translation: implement marking of diagram labels * mark date/time strings of diagrams labels for translations diff -r 7d2463c7b4ad -r c47c8085cc7e client/src/components/fairway/AvailableFairwayDepth.vue --- a/client/src/components/fairway/AvailableFairwayDepth.vue Mon Oct 14 16:10:31 2019 +0200 +++ b/client/src/components/fairway/AvailableFairwayDepth.vue Mon Oct 14 16:26:46 2019 +0200 @@ -92,6 +92,7 @@ import { displayError } from "@/lib/errors"; import { FREQUENCIES } from "@/store/fairwayavailability"; import { defaultDiagramTemplate } from "@/lib/DefaultDiagramTemplate"; +import { localeDateString } from "@/lib/datelocalization"; export default { mixins: [diagram, pdfgen, templateLoader], @@ -370,6 +371,7 @@ }; }, drawDiagram() { + d3.timeFormatDefaultLocale(localeDateString); const elem = document.querySelector("#" + this.containerId); const svgWidth = elem != null ? elem.clientWidth : 0; const svgHeight = elem != null ? elem.clientHeight : 0; diff -r 7d2463c7b4ad -r c47c8085cc7e client/src/components/fairway/AvailableFairwayDepthLNWL.vue --- a/client/src/components/fairway/AvailableFairwayDepthLNWL.vue Mon Oct 14 16:10:31 2019 +0200 +++ b/client/src/components/fairway/AvailableFairwayDepthLNWL.vue Mon Oct 14 16:26:46 2019 +0200 @@ -92,6 +92,7 @@ import { displayError } from "@/lib/errors"; import { defaultDiagramTemplate } from "@/lib/DefaultDiagramTemplate"; import sanitize from "sanitize-filename"; +import { localeDateString } from "@/lib/datelocalization"; export default { mixins: [diagram, pdfgen, templateLoader], @@ -364,6 +365,7 @@ }; }, drawDiagram() { + d3.timeFormatDefaultLocale(localeDateString); const elem = document.querySelector("#" + this.containerId); const svgWidth = elem != null ? elem.clientWidth : 0; const svgHeight = elem != null ? elem.clientHeight : 0; diff -r 7d2463c7b4ad -r c47c8085cc7e client/src/components/gauge/HydrologicalConditions.vue --- a/client/src/components/gauge/HydrologicalConditions.vue Mon Oct 14 16:10:31 2019 +0200 +++ b/client/src/components/gauge/HydrologicalConditions.vue Mon Oct 14 16:26:46 2019 +0200 @@ -116,6 +116,7 @@ import { HTTP } from "@/lib/http"; import { displayError } from "@/lib/errors"; import { defaultDiagramTemplate } from "@/lib/DefaultDiagramTemplate"; +import { localeDateString } from "@/lib/datelocalization"; import sanitize from "sanitize-filename"; export default { @@ -324,6 +325,7 @@ drawDiagram() { // remove old diagram d3.select("#" + this.containerId + " svg").remove(); + d3.timeFormatDefaultLocale(localeDateString); const el = document.querySelector("#" + this.containerId); if (!this.selectedGaugeD || !this.longtermWaterlevels.length || !el) return; diff -r 7d2463c7b4ad -r c47c8085cc7e client/src/components/gauge/Waterlevel.vue --- a/client/src/components/gauge/Waterlevel.vue Mon Oct 14 16:10:31 2019 +0200 +++ b/client/src/components/gauge/Waterlevel.vue Mon Oct 14 16:26:46 2019 +0200 @@ -127,6 +127,7 @@ import { displayError } from "@/lib/errors"; import { defaultDiagramTemplate } from "@/lib/DefaultDiagramTemplate"; import sanitize from "sanitize-filename"; +import { localeDateString } from "@/lib/datelocalization"; // we should load only d3 modules we need but for now we'll go with the lazy way // https://www.giacomodebidda.com/how-to-import-d3-plugins-with-webpack/ // d3-line-chunked plugin: https://github.com/pbeshai/d3-line-chunked @@ -318,6 +319,7 @@ drawDiagram(zoom) { // remove old diagram and exit if necessary data is missing d3.select("#" + this.containerId + " svg").remove(); + d3.timeFormatDefaultLocale(localeDateString); const elem = document.querySelector("#" + this.containerId); const svgWidth = elem.clientWidth; const svgHeight = elem.clientHeight; diff -r 7d2463c7b4ad -r c47c8085cc7e client/src/lib/datelocalization.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/src/lib/datelocalization.js Mon Oct 14 16:26:46 2019 +0200 @@ -0,0 +1,55 @@ +import app from "@/main"; +const localeDateString = { + dateTime: app.$gettext("%a %e %b %X %Y"), + date: app.$gettext("%d/%m/%Y"), + time: app.$gettext("%H:%M:%S"), + periods: [app.$gettext("AM"), app.$gettext("PM")], + days: [ + app.$gettext("Sunday"), + app.$gettext("Monday"), + app.$gettext("Tuesday"), + app.$gettext("Wednesday"), + app.$gettext("Thursday"), + app.$gettext("Friday"), + app.$gettext("Saturday") + ], + shortDays: [ + app.$gettext("Sun"), + app.$gettext("Mon"), + app.$gettext("Tue"), + app.$gettext("Wed"), + app.$gettext("Thu"), + app.$gettext("Fri"), + app.$gettext("Sat") + ], + months: [ + app.$gettext("January"), + app.$gettext("February"), + app.$gettext("March"), + app.$gettext("April"), + app.$gettext("May"), + app.$gettext("June"), + app.$gettext("July"), + app.$gettext("August"), + app.$gettext("September"), + app.$gettext("October"), + app.$gettext("November"), + app.$gettext("December") + ], + shortMonths: [ + app.$gettext("Jan"), + app.$gettext("Feb"), + app.$gettext("Mar"), + app.$gettext("Apr"), + app.$gettext("May"), + app.$gettext("Jun"), + app.$gettext("Jul"), + app.$gettext("Aug"), + app.$gettext("Sep"), + app.$gettext("Oct"), + app.$gettext("Nov"), + app.$gettext("Dec") + ] +}; + +export { localeDateString };