Skip to content
Permalink
Browse files

Guess locale using locale.getdefaultlocale()

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed May 24, 2017
1 parent ee96e2a commit cf812c17b20866a513d66d08e538eca763f9d5f1
Showing with 9 additions and 2 deletions.
  1. +3 −2 CHANGES.txt
  2. +6 −0 nikola/nikola.py
@@ -16,8 +16,9 @@ Features
Bugfixes
--------

* Save dependencies for template hooks properly (using .__doc__ or
.template_registry_identifier for callables)
* Use ``locale.getdefaultlocale()`` for better locale guessing
* Save dependencies for template hooks properly (using ``.__doc__`` or
``.template_registry_identifier`` for callables)
* Enable larger panorama thumbnails (Issue #2780)
* Disable ``archive_rss`` link handler, which was useless because no
such RSS was ever generated (Issue #2783)
@@ -2817,6 +2817,12 @@ def guess_locale_from_lang_posix(lang):
if is_valid_locale(str(lang)):
locale_n = str(lang)
else:
# Guess using locale.getdefaultlocale()
try:
locale_n = '.'.join(locale.getdefaultlocale())
except (ValueError, TypeError):
pass
if not is_valid_locale(locale_n):
# this works in Travis when locale support set by Travis suggestion
locale_n = str((locale.normalize(lang).split('.')[0]) + '.UTF-8')
if not is_valid_locale(locale_n):

0 comments on commit cf812c1

Please sign in to comment.