From 5bd7e4a67f3c7d683f08179c119566f85de6e979 Mon Sep 17 00:00:00 2001 From: joan Date: Fri, 5 Feb 2021 08:05:57 +0100 Subject: [PATCH] Translation fix --- loopback/locale/en.json | 4 ++-- loopback/locale/es.json | 4 ++-- loopback/util/date.js | 25 ++++++++++++++++++++ modules/ticket/back/models/ticket-request.js | 8 ++----- 4 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 loopback/util/date.js diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 207b4a7e7..44f882638 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -89,7 +89,7 @@ "Company has to be official": "Company has to be official", "A travel with this data already exists": "A travel with this data already exists", "The observation type can't be repeated": "The observation type can't be repeated", - "New ticket request has been created with price": "New ticket request has been created '{{description}}' for day {{shipped}}, with a quantity of {{quantity}} and a price of {{price}} €", - "New ticket request has been created": "New ticket request has been created '{{description}}' for day {{shipped}}, with a quantity of {{quantity}}", + "New ticket request has been created with price": "New ticket request has been created *'{{description}}'* for day *{{shipped}}*, with a quantity of *{{quantity}}* and a price of *{{price}} €*", + "New ticket request has been created": "New ticket request has been created *'{{description}}'* for day *{{shipped}}*, with a quantity of *{{quantity}}*", "There's a new urgent ticket": "There's a new urgent ticket: [{{title}}](https://cau.verdnatura.es/WorkOrder.do?woMode=viewWO&woID={{issueId}})" } \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 25976c952..16bd1d361 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -168,8 +168,8 @@ "The selected ticket is not suitable for this route": "El ticket seleccionado no es apto para esta ruta", "Sorts whole route": "Reordena ruta entera", "Invalid account": "Cuenta inválida", - "New ticket request has been created with price": "Se ha creado una nueva petición de compra '{{description}}' para el día {{shipped}}, con una cantidad de {{quantity}} y un precio de {{price}} €", - "New ticket request has been created": "Se ha creado una nueva petición de compra '{{description}}' para el día {{shipped}}, con una cantidad de {{quantity}}", + "New ticket request has been created with price": "Se ha creado una nueva petición de compra *'{{description}}'* para el día *{{shipped}}*, con una cantidad de *{{quantity}}* y un precio de *{{price}} €*", + "New ticket request has been created": "Se ha creado una nueva petición de compra *'{{description}}'* para el día *{{shipped}}*, con una cantidad de *{{quantity}}*", "That item doesn't exists": "Ese artículo no existe", "There's a new urgent ticket": "Hay un nuevo ticket urgente: [{{title}}](https://cau.verdnatura.es/WorkOrder.do?woMode=viewWO&woID={{issueId}})" } \ No newline at end of file diff --git a/loopback/util/date.js b/loopback/util/date.js new file mode 100644 index 000000000..66774544c --- /dev/null +++ b/loopback/util/date.js @@ -0,0 +1,25 @@ +/** + * Transforms a UTC date to string without datetime. + * + * @param {date} date Date to format + * @return {String} Formatted date string + */ +function toString(date) { + date = new Date(date); + + let day = date.getDate(); + let month = date.getMonth() + 1; + let year = date.getFullYear(); + + if (day < 10) + day = `0${day}`; + + if (month < 10) + month = `0${month}`; + + return `${day}-${month}-${year}`; +} + +module.exports = { + toString: toString +}; diff --git a/modules/ticket/back/models/ticket-request.js b/modules/ticket/back/models/ticket-request.js index 814f47bae..234978f33 100644 --- a/modules/ticket/back/models/ticket-request.js +++ b/modules/ticket/back/models/ticket-request.js @@ -1,4 +1,5 @@ const LoopBackContext = require('loopback-context'); +const dateUtil = require('vn-loopback/util/date'); module.exports = function(Self) { require('../methods/ticket-request/filter')(Self); @@ -26,12 +27,7 @@ module.exports = function(Self) { if (instance.price) messageText = 'New ticket request has been created with price'; - const shipped = new Intl.DateTimeFormat('es', { - year: 'numeric', - month: 'numeric', - day: 'numeric' - }).format(ticket.shipped); - + const shipped = dateUtil.toString(ticket.shipped); const message = $t(messageText, { description: instance.description, shipped: shipped,