Modify Notification text

Ólavur8 years ago

Hello,

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

Anton Tananaev8 years ago

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

federico8 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 Tananaev8 years ago

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

NotificationFormatter.java

federico8 years ago

Thanks!

federico8 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 Tananaev8 years ago

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

federico8 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 Tananaev8 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.

Edgar7 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.

Juankaher6 years ago

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

Anton Tananaev6 years ago

Yes, you can modify template.

NS5 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 Tananaev5 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.