Modify Notification text

Ólavur 9 years ago

Hello,

Is it possible to modify the notification text received by email?

Anton Tananaev 9 years ago

Yes, you can modify templates for emails. Check "templates" folder in Traccar.

federico 9 years ago

Hi Anton,
Congrats for this great work!

I have a question: Is there any variable for geofence name and for speed to use in sms/mail templates?

I need to edit the SMS template for entering and leaving geofences and I do not know how to include those data.

If a modify this:
$device.name has entered geofence $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)

Into this:
$device.name has entered geofence $geofence.name at $device.speed - $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)

it is ok?

Is there a variable list anywhere? (for using in templates)

Thanks in advance.

Best regards.
Federico.-

Anton Tananaev 9 years ago

Yes, I think it's OK. You can find available variables here:

NotificationFormatter.java

federico 9 years ago

Thanks!

federico 9 years ago

Is there any way to change locale per user?

Or a way to hardcode locale in this line ro es?
$device.name has entered geofence $dateTool.format(“YYYY-MM-dd HH:mm:ss”, $event.serverTime, $locale, $timezone)

$device.name has entered geofence $dateTool.format(“YYYY-MM-dd HH:mm:ss”, $event.serverTime, "es", $timezone)

Thanks

Anton Tananaev 9 years ago

You can either hardcore it in the server code, or you can always specify full date and time format.

federico 9 years ago

Thanks for your answer but what I need is the date to be translated

With
$device.name ha ingresado en $geofence.name el $dateTool.format("EEEE dd 'de' MMMM 'de' YYYY 'a las' HH:mma", $event.serverTime, $locale, $timezone) hs.<br>

I receive
Telefono Pablo ha ingresado en Altuwatt el Tuesday 25 de April de 2017 a las 17:37PM hs.

And I need the date in spanish, so Martes instead of Tuesday and Abril instead of April
I thought that changing locale this could be achieved. Am I wrong?

Thanks again.
Federico.-

Anton Tananaev 9 years ago

I don't know if you can create an instance of locale object from the template. You would have to do some research on it yourself.

Edgar 8 years ago

The answer might be a bit late now for Federico, but somebody else might have a similar problem.

I simply used the $locale instance you already have in the template together with the static method 'forLanguageTag()':

$locale.forLanguageTag("de") for German.

Your example in Spanish would then be something like

$device.name ha ingresado en $geofence.name el $dateTool.format("EEEE dd 'de' MMMM 'de' YYYY 'a las' HH:mma", $event.serverTime, $locale.forLanguageTag("es"), $timezone) hs.

@Anton:
As this is my first post in this forum, I want to thank you for offering such an excellent piece of software to the public and for offering such an icredible support for free. Thank you very much.

Juankaher 7 years ago

Hi Anton ( or Edgar),
Is tere a way to include a link with position into SMS message?

Anton Tananaev 7 years ago

Yes, you can modify template.

NS 6 years ago

Sorry for asking naive question. If I modify the template files for notifications texts, do I need to rebuild the jar file OR just the replacement of the templates folder on server would work?

Anton Tananaev 6 years ago

Just replace files.

hi Anton! Sorry for bothering, could you guide me on what page can I see how the templates are modified? I need to add to the reports the distance traveled and I go to this page NotificationFormatter.java and it is out of order. From already thank you very much.