O'Reilly logo
  • Shawn Zhai thinks this is interesting:

The timestamps rendered by Flask-Moment can be localized to many languages. A language can be selected in the template by passing the language code to function lang():


Cover of Flask Web Development


Internationalization By default dates and times are rendered in English. To change to a different language add the following line in the <head> section after the include_moment() line: {{ moment.lang("es") }} The above example sets the language to Spanish. Moment.js supports a large number of languages, consult the documentation for the list of languages and their two letter codes.

exp. {{ super() }} {{ moment.include_moment() }} {{ moment.lang('zh-CN') }}

<p>The local date and time is {{ moment(current_time).format('YYYY年M月D日, h:mm:ss a') }}.</p> <p>That was {{ moment(current_time).fromNow(refresh=True) }}.</p>