Localised date inside of a string issue

Localised date inside of a string issue

by Neill Magill -
Number of replies: 0
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

I have been trying to use a string from my Moodle plugin that contains a place holder for a date in it's Moodle App implementation. However I have been having difficulties making this work well because I suspect the timestamp should be localised by the app and not in Moodle, I have not been able to work out a way to do this in the templates yet.

So for example the string in Moodle is something like:

$string['strwithdate'] = 'On {$a->date} something will happen';

The data passed to the app includes a value for the date as a Unix timestamp (so it can be localised to a date in the app). In the template I can render the string using the raw timestamp by doing something like this:

{{ 'plugin.mod_myplugin.strwithdate' | translate: { $a: { date: <% timestamp %> } } }}

I can also display the date localised date using:

{{ <% timestamp %> | coreToLocaleString }}

or

{{ '<% timestamp %>000' | coreFormatDate: "dffulldate" }}

but I have been unable to find a way to get the app to pass a localised version of the timestamp into the string. 

Is it possible or is this something I'm only going to be able to do by passing some additional JavaScript to the App from my Moodle plugin?

Average of ratings: -