From c1a5279da9863fdfacade8654437d9d7b73f6b13 Mon Sep 17 00:00:00 2001 From: Nicolas Stinus Date: Sat, 4 Jun 2016 09:00:17 -0400 Subject: [PATCH] Localize default lang and timezone in pelican-quickstart Fixes #1971. --- docs/quickstart.rst | 12 ++++++++++-- pelican/tools/pelican_quickstart.py | 11 +++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/docs/quickstart.rst b/docs/quickstart.rst index ef5256c2..752c1857 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -28,8 +28,9 @@ by asking some questions about your site:: pelican-quickstart For questions that have default values denoted in brackets, feel free to use -the Return key to accept those default values. When asked for your URL prefix, -enter your domain name as indicated (e.g., ``http://example.com``). +the Return key to accept those default values [#tzlocal_fn]_. When asked for +your URL prefix, enter your domain name as indicated (e.g., +``http://example.com``). Create an article ----------------- @@ -72,3 +73,10 @@ Continue reading the other documentation sections for more detail, and check out the Pelican wiki's Tutorials_ page for links to community-published tutorials. .. _Tutorials: https://github.com/getpelican/pelican/wiki/Tutorials + +Footnotes +--------- + +.. [#tzlocal_fn] You can help localize default fields by installing the + optional `tzlocal `_ + module. diff --git a/pelican/tools/pelican_quickstart.py b/pelican/tools/pelican_quickstart.py index e6ccf2a8..6b4eb5a5 100755 --- a/pelican/tools/pelican_quickstart.py +++ b/pelican/tools/pelican_quickstart.py @@ -4,12 +4,19 @@ from __future__ import print_function, unicode_literals import argparse import codecs +import locale import os import string import sys import pytz +try: + import tzlocal + _DEFAULT_TIMEZONE = tzlocal.get_localzone().zone +except: + _DEFAULT_TIMEZONE = 'Europe/Paris' + import six from pelican import __version__ @@ -42,8 +49,8 @@ CONF = { 'github_pages_branch': _GITHUB_PAGES_BRANCHES['project'], 'default_pagination': 10, 'siteurl': '', - 'lang': 'en', - 'timezone': 'Europe/Paris' + 'lang': locale.getlocale()[0].split('_')[0], + 'timezone': _DEFAULT_TIMEZONE } # url for list of valid timezones