Skip to content

Commit 475a9c0

Browse files
committed
Merge pull request #2992 from DevHugo/dates_pdf_migrations
Les dates dans les pdf sont en francais apres une migration de la zep-12
2 parents 8c1fb2a + af226ab commit 475a9c0

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

zds/tutorialv2/utils.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from django.core.exceptions import ObjectDoesNotExist
1919
from django.template.loader import render_to_string
2020
from django.utils.translation import ugettext_lazy as _
21+
from django.utils import translation
2122

2223
from zds.search.models import SearchIndexContent
2324
from zds.tutorialv2 import REPLACE_IMAGE_PATTERN
@@ -562,7 +563,14 @@ def publish_content(db_object, versioned, is_major_update=True):
562563
base_name = os.path.join(extra_contents_path, versioned.slug)
563564

564565
# 1. markdown file (base for the others) :
565-
parsed = render_to_string('tutorialv2/export/content.md', {'content': versioned})
566+
# If we come from a command line, we need to activate i18n, to have the date in the french language.
567+
cur_language = translation.get_language()
568+
try:
569+
translation.activate(settings.LANGUAGE_CODE)
570+
parsed = render_to_string('tutorialv2/export/content.md', {'content': versioned})
571+
finally:
572+
translation.activate(cur_language)
573+
566574
parsed_with_local_images = retrieve_and_update_images_links(parsed, directory=extra_contents_path)
567575

568576
md_file_path = base_name + '.md'

0 commit comments

Comments
 (0)