I have define a plonelocales.po in my AddOn in locales/LC_MESSAGES/de to override the plone.app.locales which is defined in plone.app.locales/plone/app/locales/locales/de/LC_MESSAGES/plonelocales.po
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:
First:
In the Registry controlpanel, i enable the option
Products.CMFPlone.i18nl10n.override_dateformat
Second:
In the Registry controlpanel, i disable the option
Products.CMFPlone.i18nl10n.override_dateformat
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): experimental.ulocalized_time · PyPI
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. You can split in normal time.strftime or the the defined dateformat via date_format_long and date_format_short.
# 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,
target_language=target_language)
# 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
else:
formatstring = '[INTERNAL ERROR]'
return time.strftime(formatstring)