Confusing with "toLocalizedTime" Helper Method


in my Template i use the following snippet to display the Date:

        toLocalizedTime nocall: context/@@plone/toLocalizedTime;
        item_startdate python:toLocalizedTime(, long_format=0);"

toLocalizedTime is here:

and call toLocalizedTime from Translation Service in

I have define a plonelocales.po in my AddOn in locales/LC_MESSAGES/de to override the which is defined in

msgid "date_format_long"
msgstr "${d}.${B}.${Y} ${H}:${M}"

msgid "date_format_short"
msgstr "${d}.${B}.${Y}"

My Site Configuration:

Products.CMFPlone.i18nl10n.override_dateformat.date_format_long %d. %B %Y %H:%M
Products.CMFPlone.i18nl10n.override_dateformat.date_format_short %d. %B %Y
The default Language of the Site is set to German.

2 Situations:
In the Registry controlpanel, i enable the option

In the Registry controlpanel, i disable the option

I would like to display the name of month in german, but it didn't. No matter which configuration is present. My last idea is to write a helperview which replace the Name of Month via datestr.replace("Name1","Name2"), but i think that is not the right way. Any Ideas?

Short answer (but quick and dirty):
I developed it for Plone 3, it was working on Plone 4 also (not sure on Plone 5, but probably works too).

PS: the key Products.CMFPlone.i18nl10n.override_dateformat is new to me, how is intended to be used?

Ok, i use Plone 5. In ulocalized_time it would checked the right format. I think it's a override mechanism for whatever.:confused: You can split in normal time.strftime or the the defined dateformat via date_format_long and date_format_short.

Thats the definition in

    # 1. if our Enabled flag in the configuration registry is set,
    # the format string there should override the translation machinery
    formatstring = get_formatstring_from_registry(msgid)
    if formatstring is not None:
        return time.strftime(formatstring)

    # 2. the normal case: translation machinery,
    # that is the ".../LC_MESSAGES/plonelocales.po" files
    formatstring = translate(msgid, domain, mapping, request,

    # 3. if both failed, fall back to hardcoded ISO style
    if formatstring == msgid:
        if msgid == 'date_format_long':
            formatstring = '%Y-%m-%d %H:%M'  # 2038-01-19 03:14
        elif msgid == 'date_format_short':
            formatstring = '%Y-%m-%d'  # 2038-01-19
        elif msgid == 'time_format':
            formatstring = '%H:%M'  # 03:14
            formatstring = '[INTERNAL ERROR]'
        return time.strftime(formatstring)

some time ago I wrote this to solve a similar problem:

1 Like

May I heartily recommend to use the pat-moment js thingie when on Plone 5? It's so much easier


Are your custom translations available? In Plone 4, I had to add my translation package in the zcml line of my instance part


zcml = translation.package