У меня есть приложение angular, и я использую пакет ngx translate для интернационализации моего приложения с двумя json файлами (ar, fr), я хочу перевести возвращенную ошибку и ответ с сервера nodejs, как внедрить их в мои файлы перевода и использовать его в файле html!
export async function getByUser (req, res) {
try {
let complaints = await Complaint.find({
issuer: req.params.id,
city: req.user.city._id
})
.populate({
path: 'issuer',
select: 'firstName lastName'
})
.populate({
path: 'type',
select: '-_id'
})
.populate({
path: 'subType',
select: '-_id'
})
.populate('servicesResponsibles.service')
.populate({
path: 'attachments',
select: 'filePath'
})
.sort({
updatedAt: 'descending'
})
.exec()
complaints.forEach(complaint => {
complaint.history = [{
title: 'Plainte déposée',
date: complaint.dateCreation,
msg: 'Votre plainte a été déposée chez votre commune.'
}]
if (complaint.servicesResponsibles.length != 0) {
complaint.servicesResponsibles.forEach(service => {
complaint.history.push({
title: (complaint.status == 'pending' || complaint.status == 'inProgress' || complaint.status == 'done') ? service.service.name : 'Plainte rejetée',
date: (complaint.status == 'rejected') ? complaint.dateRejection : ((complaint.status == 'done') ? complaint.dateClosed : ((complaint.status == 'inProgress') ? service.dateHandling : (complaint.dateViewed || complaint.dateCreation))),
msg: (complaint.status == 'pending') ? 'Affectée au service. En attente de commencer à le traiter ...' : ((complaint.status == 'rejected') ? 'Votre plainte est refusée.' : ((complaint.status == 'done') ? 'Plainte vérifiée et finalisée.' : 'Le service a commencé le traitement de cette plainte.')),
pending: (complaint.status === 'pending') ? true : null,
inProgress: (complaint.status === 'inProgress') ? true : null
})
})
} else {
if (complaint.status == 'rejected') {
complaint.history.push({
title: 'Plainte rejetée',
date: complaint.dateRejection,
msg: 'Votre plainte est refusée.',
rejected: true,
rejectionReason: complaint.rejectionReason
})
} else if (complaint.status == 'done') {
complaint.history.push({
approvedReason: 'complaint.approvedReason',
title: 'Plainte finalisée',
date: complaint.dateClosed,
msg: 'Plainte vérifiée et finalisée.',
done: true,
after: complaint.after
})
}
}
})
return res.json(complaints)
} catch (error) {
if (error.name == 'CastError') {
return res.status(400).json({
error: error.message
})
}
return res.status(500).end()
}
}
{
"key": "محتوى",
"align": "r2l",
"dir": "rtl",
"menu": {
"reclamations": "شكايات",
"propositions": "إقتراحات",
"participations": "مشاركات",
"documents": "ملفّات",
"conseillers": "المجلس البلدي",
"appmobiles": "تطبيقة الهاتف",
"renseignements": "معلومات",
"lacommune": "البلديّة",
"nouvelleréclamation": "شكاية جديدة",
"mesreclamations": "شكاياتي"
},
"search": {
"ex.:Plaintes,Membres,Sondages,Documents ...": "مثال: شكاوي, أعضاء, وثائق ..."
},
}
Где именно я должен реализовать этот случай!