Skip to content
Permalink
Browse files
Merge pull request #3126 from getnikola/babel-instead-of-locale
Use Babel instead of system locale to format dates
  • Loading branch information
Kwpolska committed Aug 6, 2018
2 parents 69ef41d + 4d14b50 commit 3c45bdb9b98ec24703092fc71e7e52bc4b067e8f
Showing with 885 additions and 1,954 deletions.
  1. +3 −0 CHANGES.txt
  2. +1 −1 docs/manual.rst
  3. +0 −35 dodo.py
  4. +6 −16 nikola/conf.py.in
  5. +2 −4 nikola/data/themes/base/messages/messages_ar.py
  6. +2 −4 nikola/data/themes/base/messages/messages_az.py
  7. +2 −4 nikola/data/themes/base/messages/messages_bg.py
  8. +2 −4 nikola/data/themes/base/messages/messages_br.py
  9. +2 −4 nikola/data/themes/base/messages/messages_bs.py
  10. +2 −4 nikola/data/themes/base/messages/messages_ca.py
  11. +2 −4 nikola/data/themes/base/messages/messages_cs.py
  12. +2 −4 nikola/data/themes/base/messages/messages_da.py
  13. +2 −4 nikola/data/themes/base/messages/messages_de.py
  14. +2 −4 nikola/data/themes/base/messages/messages_el.py
  15. +2 −4 nikola/data/themes/base/messages/messages_en.py
  16. +6 −8 nikola/data/themes/base/messages/messages_eo.py
  17. +2 −4 nikola/data/themes/base/messages/messages_es.py
  18. +23 −25 nikola/data/themes/base/messages/messages_et.py
  19. +3 −5 nikola/data/themes/base/messages/messages_eu.py
  20. +4 −6 nikola/data/themes/base/messages/messages_fa.py
  21. +2 −4 nikola/data/themes/base/messages/messages_fi.py
  22. +2 −4 nikola/data/themes/base/messages/messages_fil.py
  23. +7 −9 nikola/data/themes/base/messages/messages_fr.py
  24. +2 −4 nikola/data/themes/base/messages/messages_gl.py
  25. +2 −4 nikola/data/themes/base/messages/messages_he.py
  26. +2 −4 nikola/data/themes/base/messages/messages_hi.py
  27. +2 −4 nikola/data/themes/base/messages/messages_hr.py
  28. +6 −8 nikola/data/themes/base/messages/messages_hu.py
  29. +7 −9 nikola/data/themes/base/messages/messages_id.py
  30. +7 −9 nikola/data/themes/base/messages/messages_it.py
  31. +2 −4 nikola/data/themes/base/messages/messages_ja.py
  32. +2 −4 nikola/data/themes/base/messages/messages_ko.py
  33. +2 −4 nikola/data/themes/base/messages/messages_lt.py
  34. +2 −4 nikola/data/themes/base/messages/messages_nb.py
  35. +2 −4 nikola/data/themes/base/messages/messages_nl.py
  36. +2 −4 nikola/data/themes/base/messages/messages_pa.py
  37. +3 −5 nikola/data/themes/base/messages/messages_pl.py
  38. +11 −13 nikola/data/themes/base/messages/messages_pt.py
  39. +6 −8 nikola/data/themes/base/messages/messages_pt_br.py
  40. +2 −4 nikola/data/themes/base/messages/messages_ru.py
  41. +2 −4 nikola/data/themes/base/messages/messages_si_lk.py
  42. +2 −4 nikola/data/themes/base/messages/messages_sk.py
  43. +2 −4 nikola/data/themes/base/messages/messages_sl.py
  44. +2 −4 nikola/data/themes/base/messages/messages_sq.py
  45. +2 −4 nikola/data/themes/base/messages/messages_sr.py
  46. +2 −4 nikola/data/themes/base/messages/messages_sr_latin.py
  47. +2 −4 nikola/data/themes/base/messages/messages_sv.py
  48. +2 −4 nikola/data/themes/base/messages/messages_te.py
  49. +2 −4 nikola/data/themes/base/messages/messages_th.py
  50. +2 −4 nikola/data/themes/base/messages/messages_tl.py
  51. +2 −4 nikola/data/themes/base/messages/messages_tr.py
  52. +2 −4 nikola/data/themes/base/messages/messages_uk.py
  53. +7 −9 nikola/data/themes/base/messages/messages_ur.py
  54. +3 −5 nikola/data/themes/base/messages/messages_zh_cn.py
  55. +2 −4 nikola/data/themes/base/messages/messages_zh_tw.py
  56. +23 −222 nikola/nikola.py
  57. +20 −17 nikola/plugins/task/archive.py
  58. +82 −124 nikola/utils.py
  59. +1 −0 requirements.txt
  60. +0 −106 tests/README.rst
  61. +6 −97 tests/base.py
  62. +7 −19 tests/test_integration.py
  63. +138 −245 tests/test_locale.py
  64. +2 −2 tests/test_rss_feeds.py
  65. +5 −12 translations/nikola.messages/ar.po
  66. +7 −14 translations/nikola.messages/az.po
  67. +7 −14 translations/nikola.messages/bg.po
  68. +5 −13 translations/nikola.messages/br.po
  69. +6 −14 translations/nikola.messages/bs.po
  70. +6 −14 translations/nikola.messages/ca.po
  71. +9 −15 translations/nikola.messages/cs.po
  72. +7 −15 translations/nikola.messages/da.po
  73. +9 −17 translations/nikola.messages/de.po
  74. +6 −14 translations/nikola.messages/el.po
  75. +4 −12 translations/nikola.messages/en.po
  76. +11 −19 translations/nikola.messages/eo.po
  77. +7 −15 translations/nikola.messages/es.po
  78. +30 −36 translations/nikola.messages/et.po
  79. +7 −15 translations/nikola.messages/eu.po
  80. +10 −17 translations/nikola.messages/fa.po
  81. +7 −15 translations/nikola.messages/fi.po
  82. +4 −12 translations/nikola.messages/fil.po
  83. +13 −20 translations/nikola.messages/fr.po
  84. +6 −14 translations/nikola.messages/gl.po
  85. +7 −15 translations/nikola.messages/he.po
  86. +6 −14 translations/nikola.messages/hi.po
  87. +7 −14 translations/nikola.messages/hr.po
  88. +12 −19 translations/nikola.messages/hu.po
  89. +13 −19 translations/nikola.messages/id.po
  90. +13 −21 translations/nikola.messages/it.po
  91. +8 −16 translations/nikola.messages/ja.po
  92. +7 −14 translations/nikola.messages/ko.po
  93. +7 −15 translations/nikola.messages/lt.po
  94. +6 −14 translations/nikola.messages/nb.po
  95. +7 −15 translations/nikola.messages/nl.po
  96. +8 −14 translations/nikola.messages/pa.po
  97. +11 −19 translations/nikola.messages/pl.po
  98. +17 −23 translations/nikola.messages/pt.po
  99. +17 −20 translations/nikola.messages/pt_BR.po
  100. +6 −14 translations/nikola.messages/ru.po
  101. +4 −12 translations/nikola.messages/si_LK.po
  102. +9 −15 translations/nikola.messages/sk.po
  103. +7 −14 translations/nikola.messages/sl.po
  104. +6 −14 translations/nikola.messages/sq.po
  105. +7 −14 translations/nikola.messages/sr.po
  106. +7 −15 translations/nikola.messages/sr@latin.po
  107. +7 −15 translations/nikola.messages/sv.po
  108. +5 −12 translations/nikola.messages/te.po
  109. +8 −14 translations/nikola.messages/th.po
  110. +4 −12 translations/nikola.messages/tl.po
  111. +7 −14 translations/nikola.messages/tr.po
  112. +8 −15 translations/nikola.messages/uk.po
  113. +13 −20 translations/nikola.messages/ur.po
  114. +10 −15 translations/nikola.messages/zh_CN.po
  115. +7 −15 translations/nikola.messages/zh_TW.po
@@ -11,6 +11,9 @@ Features
find a file (i.e. when an 404 error occurs).
* Better error messages for JSON download failures in ``nikola
plugin`` and ``nikola theme`` (Issue getnikola/plugins#282)
* Use Babel instead of the locale module to better handle
localizations (Issues #2606, #3121)
* Change ``DATE_FORMAT`` formats to CLDR formats (Issue #2606)

Bugfixes
--------
@@ -1611,7 +1611,7 @@ Fancy Dates
Nikola can use various styles for presenting dates.

DATE_FORMAT
The date format to use if there is no JS or fancy dates are off. Compatible with Python’s ``strftime()`` syntax.
The date format to use if there is no JS or fancy dates are off. `Compatible with CLDR syntax. <http://cldr.unicode.org/translation/date-time>`_

JS_DATE_FORMAT
The date format to use if fancy dates are on. Compatible with ``moment.js`` syntax.
35 dodo.py
@@ -1,7 +1,6 @@

import os
import fnmatch
import locale
import subprocess

DOIT_CONFIG = {
@@ -33,50 +32,16 @@ def task_pydocstyle():
}


def task_locale():
"""set environ locale vars used in nikola tests"""
def set_nikola_test_locales():
try:
out = subprocess.check_output(['locale', '-a'])
out = out.decode('utf-8')
locales = []
languages = set()
for line in out.splitlines():
if (line.endswith('.utf8') or line.endswith('.UTF-8')) and '_' in line:
lang = line.split('_')[0]
if lang not in languages:
try:
locale.setlocale(locale.LC_ALL, str(line))
except Exception:
continue
languages.add(lang)
locales.append((lang, line))
if len(locales) == 2:
break
if len(locales) != 2:
return False # task failed
else:
os.environ['NIKOLA_LOCALE_DEFAULT'] = ','.join(locales[0])
os.environ['NIKOLA_LOCALE_OTHER'] = ','.join(locales[1])
finally:
# restore to default locale
locale.resetlocale()

return {'actions': [set_nikola_test_locales], 'verbosity': 2}


def task_test():
"""run unit-tests using py.test"""
return {
'task_dep': ['locale'],
'actions': ['py.test tests/'],
}


def task_coverage():
"""run unit-tests using py.test, with coverage reporting"""
return {
'task_dep': ['locale'],
'actions': ['py.test --cov nikola --cov-report term-missing tests/'],
'verbosity': 2,
}
@@ -176,11 +176,12 @@ TIMEZONE = ${TIMEZONE}
# FORCE_ISO8601 = False

# Date format used to display post dates. (translatable)
# (str used by datetime.datetime.strftime)
# DATE_FORMAT = '%Y-%m-%d %H:%M'
# Used by babel.dates, CLDR style: http://cldr.unicode.org/translation/date-time
# You can also use 'full', 'long', 'medium', or 'short'
# DATE_FORMAT = 'YYYY-MM-dd HH:mm'

# Date format used to display post dates, if local dates are used. (translatable)
# (str used by moment.js)
# Used by moment.js: https://momentjs.com/docs/#/displaying/format/
# JS_DATE_FORMAT = 'YYYY-MM-DD HH:mm'

# Date fanciness.
@@ -192,20 +193,9 @@ TIMEZONE = ${TIMEZONE}
# Your theme must support it, Bootstrap already does.
# DATE_FANCINESS = 0

# While Nikola can select a sensible locale for each language,
# sometimes explicit control can come handy.
# In this file we express locales in the string form that
# python's locales will accept in your OS, by example
# "en_US.utf8" in Unix-like OS, "English_United States" in Windows.
# LOCALES = dict mapping language --> explicit locale for the languages
# in TRANSLATIONS. You can omit one or more keys.
# LOCALE_FALLBACK = locale to use when an explicit locale is unavailable
# LOCALE_DEFAULT = locale to use for languages not mentioned in LOCALES; if
# not set the default Nikola mapping is used.

# Customize the locale/region used for a language.
# For example, to use British instead of US English: LOCALES = {'en': 'en_GB'}
# LOCALES = {}
# LOCALE_FALLBACK = None
# LOCALE_DEFAULT = None

# One or more folders containing files to be copied as-is into the output.
# The format is a dictionary of {source: relative destination}.
@@ -24,8 +24,8 @@
"Posts about %s": "مقالات عن %s",
"Posts by %s": "مقالات بواسطة %s",
"Posts for year %s": "مقالات سنة %s",
"Posts for {month} {day}, {year}": "",
"Posts for {month} {year}": "",
"Posts for {month_day_year}": "",
"Posts for {month_year}": "",
"Previous post": "المقالة السابقة",
"Previous": "السابق",
"Publication date": "تاريخ النشر",
@@ -45,6 +45,4 @@
"Write your post here.": "أكتب مقالك هنا",
"old posts, page %d": "مقالات قديمة, صفحة %d",
"page %d": "صفحة %d",
"{month} {day}, {year}": "",
"{month} {year}": "",
}
@@ -24,8 +24,8 @@
"Posts about %s": "%s ilə bağlı yazılar",
"Posts by %s": "%s tərəfindən yazılmış yazılar",
"Posts for year %s": "%s ilindəki yazılar",
"Posts for {month} {day}, {year}": "{month} {day}, {year} üçün yazılar",
"Posts for {month} {year}": "{month} {year} üçün yazılar",
"Posts for {month_day_year}": "{month_day_year} üçün yazılar",
"Posts for {month_year}": "{month_year} üçün yazılar",
"Previous post": "Əvvəlki yazı",
"Previous": "Öncəki",
"Publication date": "Buraxılış tarixi",
@@ -45,6 +45,4 @@
"Write your post here.": "Öz məqaləni bura yaz",
"old posts, page %d": "köhnə yazılar, səhifə %s",
"page %d": "səhifə %d",
"{month} {day}, {year}": "{month} {day}, {year}",
"{month} {year}": "{month} {year}",
}
@@ -24,8 +24,8 @@
"Posts about %s": "Публикации относно %s",
"Posts by %s": "Публикации от %s",
"Posts for year %s": "Публикации за %s година",
"Posts for {month} {day}, {year}": "Публикации от {day} {month} {year}",
"Posts for {month} {year}": "Публикации за {month} {year}",
"Posts for {month_day_year}": "Публикации от {month_day_year}",
"Posts for {month_year}": "Публикации за {month_year}",
"Previous post": "Предишна публикация",
"Previous": "",
"Publication date": "Дата на публикуване",
@@ -45,6 +45,4 @@
"Write your post here.": "Напиши тук текста на твоята публикация.",
"old posts, page %d": "стари публикации, страница %d",
"page %d": "страница %d",
"{month} {day}, {year}": "",
"{month} {year}": "",
}
@@ -24,8 +24,8 @@
"Posts about %s": "",
"Posts by %s": "",
"Posts for year %s": "",
"Posts for {month} {day}, {year}": "",
"Posts for {month} {year}": "",
"Posts for {month_day_year}": "",
"Posts for {month_year}": "",
"Previous post": "",
"Previous": "",
"Publication date": "",
@@ -45,6 +45,4 @@
"Write your post here.": "",
"old posts, page %d": "",
"page %d": "",
"{month} {day}, {year}": "",
"{month} {year}": "",
}
@@ -24,8 +24,8 @@
"Posts about %s": "Objave o %s",
"Posts by %s": "Objave prema %s",
"Posts for year %s": "Objave u godini %s",
"Posts for {month} {day}, {year}": "Objave za {day}.{month}.{year}",
"Posts for {month} {year}": "Objave za {month} {year}",
"Posts for {month_day_year}": "Objave za {month_day_year}",
"Posts for {month_year}": "Objave za {month_year}",
"Previous post": "Prethodni članak",
"Previous": "",
"Publication date": "Datum objavljivanja",
@@ -45,6 +45,4 @@
"Write your post here.": "Vaš članak napišite ovdje.",
"old posts, page %d": "stare objave, strana %d",
"page %d": "strana %d",
"{month} {day}, {year}": "",
"{month} {year}": "",
}
@@ -24,8 +24,8 @@
"Posts about %s": "Entrades sobre %s",
"Posts by %s": "Entrades per %s",
"Posts for year %s": "Entrades de l'any %s",
"Posts for {month} {day}, {year}": "Entrades per {month} {day}, {year}",
"Posts for {month} {year}": "Publicat en {month} {year}",
"Posts for {month_day_year}": "Entrades per {month_day_year}",
"Posts for {month_year}": "Publicat en {month_year}",
"Previous post": "Entrada anterior",
"Previous": "",
"Publication date": "Data de publicació",
@@ -45,6 +45,4 @@
"Write your post here.": "Escribiu la vostra entrada aquí",
"old posts, page %d": "entrades antigues, pàgina %d",
"page %d": "pàgina %d",
"{month} {day}, {year}": "",
"{month} {year}": "",
}
@@ -24,8 +24,8 @@
"Posts about %s": "Příspěvky o %s",
"Posts by %s": "",
"Posts for year %s": "Příspěvky v roce %s",
"Posts for {month} {day}, {year}": "Příspěvky v {month} {day}, {year}",
"Posts for {month} {year}": "Příspěvky v {month} {year}",
"Posts for {month_day_year}": "Příspěvky v {month_day_year}",
"Posts for {month_year}": "Příspěvky v {month_year}",
"Previous post": "Předchozí příspěvek",
"Previous": "",
"Publication date": "Datum zveřejnění",
@@ -45,6 +45,4 @@
"Write your post here.": "",
"old posts, page %d": "staré příspěvky, strana %d",
"page %d": "strana %d",
"{month} {day}, {year}": "",
"{month} {year}": "",
}
@@ -24,8 +24,8 @@
"Posts about %s": "Indlæg om %s",
"Posts by %s": "",
"Posts for year %s": "Indlæg for %s",
"Posts for {month} {day}, {year}": "Indlæs for {month} {day}, {year}",
"Posts for {month} {year}": "Indlæg for {month} {year}",
"Posts for {month_day_year}": "Indlæs for {month_day_year}",
"Posts for {month_year}": "Indlæg for {month_year}",
"Previous post": "Tidligere indlæg",
"Previous": "",
"Publication date": "Udgivelsesdato",
@@ -45,6 +45,4 @@
"Write your post here.": "",
"old posts, page %d": "gamle indlæg, side %d",
"page %d": "side %d",
"{month} {day}, {year}": "",
"{month} {year}": "",
}
@@ -24,8 +24,8 @@
"Posts about %s": "Einträge über %s",
"Posts by %s": "Einträge von %s",
"Posts for year %s": "Einträge aus dem Jahr %s",
"Posts for {month} {day}, {year}": "Einträge vom {day}. {month} {year}",
"Posts for {month} {year}": "Einträge aus {month} {year}",
"Posts for {month_day_year}": "Einträge vom {month_day_year}",
"Posts for {month_year}": "Einträge aus {month_year}",
"Previous post": "Vorheriger Eintrag",
"Previous": "Vorheriger Eintrag",
"Publication date": "Veröffentlichungsdatum",
@@ -45,6 +45,4 @@
"Write your post here.": "Schreibe hier deinen Eintrag hin.",
"old posts, page %d": "Ältere Einträge, Seite %d",
"page %d": "Seite %d",
"{month} {day}, {year}": "{day}. {month} {year}",
"{month} {year}": "{month} {year}",
}
@@ -24,8 +24,8 @@
"Posts about %s": "Αναρτήσεις για %s",
"Posts by %s": "",
"Posts for year %s": "Αναρτήσεις για το έτος %s",
"Posts for {month} {day}, {year}": "Αναρτήσεις στις {day} {month}, {year}",
"Posts for {month} {year}": "Αναρτήσεις για τον {month} του {year}",
"Posts for {month_day_year}": "Αναρτήσεις στις {month_day_year}",
"Posts for {month_year}": "Αναρτήσεις για τον {month_year}",
"Previous post": "Προηγούμενη ανάρτηση",
"Previous": "",
"Publication date": "Ημερομηνία δημοσίευσης",
@@ -45,6 +45,4 @@
"Write your post here.": "",
"old posts, page %d": "σελίδα παλαιότερων αναρτήσεων %d",
"page %d": "σελίδα %d",
"{month} {day}, {year}": "",
"{month} {year}": "",
}
@@ -24,8 +24,8 @@
"Posts about %s": "Posts about %s",
"Posts by %s": "Posts by %s",
"Posts for year %s": "Posts for year %s",
"Posts for {month} {day}, {year}": "Posts for {month} {day}, {year}",
"Posts for {month} {year}": "Posts for {month} {year}",
"Posts for {month_day_year}": "Posts for {month_day_year}",
"Posts for {month_year}": "Posts for {month_year}",
"Previous post": "Previous post",
"Previous": "Previous",
"Publication date": "Publication date",
@@ -45,6 +45,4 @@
"Write your post here.": "Write your post here.",
"old posts, page %d": "old posts, page %d",
"page %d": "page %d",
"{month} {day}, {year}": "{month} {day}, {year}",
"{month} {year}": "{month} {year}",
}
@@ -6,7 +6,7 @@
"(active)": "(aktiva)",
"Also available in:": "Ankaŭ disponebla en:",
"Archive": "Arkivo",
"Atom feed": "",
"Atom feed": "Atom fluo",
"Authors": "Aŭtoroj",
"Categories": "Kategorioj",
"Comments": "Komentoj",
@@ -15,7 +15,7 @@
"More posts about %s": "Pli da artikoloj pri %s",
"Newer posts": "Pli novaj artikoloj",
"Next post": "Venonta artikolo",
"Next": "",
"Next": "Venonta",
"No posts found.": "Neniu artikoloj trovitaj.",
"Nothing found.": "Nenio trovita.",
"Older posts": "Pli malnovaj artikoloj",
@@ -24,10 +24,10 @@
"Posts about %s": "Artikoloj pri %s",
"Posts by %s": "Artikoloj de %s",
"Posts for year %s": "Artikoloj de la jaro %s",
"Posts for {month} {day}, {year}": "Artikoloj de la {day}a de {month} {year}",
"Posts for {month} {year}": "Artikoloj de {month} {year}",
"Posts for {month_day_year}": "Artikoloj de la {month_day_year}",
"Posts for {month_year}": "Artikoloj de {month_year}",
"Previous post": "Antaŭa artikolo",
"Previous": "",
"Previous": "Antaŭa",
"Publication date": "Eldona dato",
"RSS feed": "RSS fluo",
"Read in English": "Legu ĝin en Esperanto",
@@ -39,12 +39,10 @@
"Tags": "Etikedoj",
"Toggle navigation": "Ŝalti menuon",
"Uncategorized": "Sen kategorioj",
"Up": "",
"Up": "Supren",
"Updates": "Ĝisdatigoj",
"Write your page here.": "Skribu tie vian paĝon.",
"Write your post here.": "Skribu tie vian artikolon.",
"old posts, page %d": "%da paĝo de malnovaj artikoloj",
"page %d": "paĝo %d",
"{month} {day}, {year}": "",
"{month} {year}": "",
}
@@ -24,8 +24,8 @@
"Posts about %s": "Publicaciones sobre %s",
"Posts by %s": "Publicaciones de %s",
"Posts for year %s": "Publicaciones del año %s",
"Posts for {month} {day}, {year}": "Publicaciones del {day} de {month} de {year}",
"Posts for {month} {year}": "Posts de {month} de {year}",
"Posts for {month_day_year}": "Publicaciones del {month_day_year}",
"Posts for {month_year}": "Posts de {month_year}",
"Previous post": "Publicación anterior",
"Previous": "Anterior",
"Publication date": "Fecha de publicación",
@@ -45,6 +45,4 @@
"Write your post here.": "Escriba su publicación aquí.",
"old posts, page %d": "publicaciones antiguas, página %d",
"page %d": "página %d",
"{month} {day}, {year}": "{month} {day}, {year}",
"{month} {year}": "{month} {year}",
}

0 comments on commit 3c45bdb

Please sign in to comment.