louislam / uptime-kuma

A fancy self-hosted monitoring tool
https://uptime.kuma.pet
MIT License
56.19k stars 5.05k forks source link

Notifications in different languages #456

Open saschabrockel opened 3 years ago

saschabrockel commented 3 years ago

Describe the solution you'd like It would be nice if the notifications would be in the same language as the interface or that you could choose the language or even individualize them. Currently, I've set the web interface to German but I'm still getting my mails, Discord & Telegram notifications in English. The problem is that not everybody speaks English especially older people.

zsxeee commented 3 years ago

Seems we need the server-side translation, including response message and notification message.

Saibamen commented 3 years ago

@zsxeee The simplest way -> return message codes (with parameters if any) from server. Frontend will translate it with interpolation (https://www.i18next.com/translation-function/interpolation)

Saibamen commented 3 years ago

But for notifications, IMO it will be better if translation keys will be in new object-key, like:

notifications: {
   LOGIN_SUCCESS: "Logged in successfully",
   UNEXPECTED_ERROR: "Unexpected error detected. Please try again, check if you have latest app version or report a bug in GitHub"
}
zsxeee commented 3 years ago

@Saibamen After check "notification-providers", I found many notification messages have their message text with little difference. It will make many unnecessary translation works. Before add translation keys, I think we need a common message format/template first.

louislam commented 3 years ago

@Saibamen After check "notification-providers", I found many notification messages have their message text with little difference. It will make many unnecessary translation works. Before add translation keys, I think we need a common message format/template first.

Agree, but it is not an easy task, as some notification payloads are very special such as Discord and MS Teams.

deefdragon commented 2 years ago

While the card on discord etc. are nice, I think that the priority should be creating a general text template to use for most supported notifications (with potentially some specific ones for the special cases like twitter with its character limits).

Ideally, the templates could be over-ridden by the user for customization, or personal translation if a community translation has not yet been done. In the best case, you could override the templates on a per-notification basis, as well as override the default notifications (thus updating all notifications without needing to update them separately).

From the quick searching I have done, I think liquidjs might be a good option for the templates, as Liquid appears to be a reasonable enough language for what most kuma users need, and the library is actively maintained.

The special cases that need an object, such as discord's card, might be done by accepting a JSON object as the "template", and running each non obj/array in the object against the template engine. You could also generate raw JSON with the template, and use that. In either case, building a custom template or translation would be a bit messy for discord etc., but it would still be possible.

There are several other issues that I think all boil down to more customization on the notification message (#524, #582, #172, #208, #428) and I think using a template engine would solve the lot, while also potentially providing a work-around to a number of others such as #570 and #40 (depending on the data available to the template)

I would be willing to take a crack at a proof of concept implementing luquidjs, but there is a small chance someone else will need to finish it as I will be loosing some of my free time following next week. If you think that this has a good chance of being used, I will create a new issue to track progress.