Skip to content

Commit

Permalink
Les dates dans les pdf sont en francais apres une migration
Browse files Browse the repository at this point in the history
DevHugo committed Sep 17, 2015
1 parent 8c1fb2a commit af226ab
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion zds/tutorialv2/utils.py
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@
from django.core.exceptions import ObjectDoesNotExist
from django.template.loader import render_to_string
from django.utils.translation import ugettext_lazy as _
from django.utils import translation

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

# 1. markdown file (base for the others) :
parsed = render_to_string('tutorialv2/export/content.md', {'content': versioned})
# If we come from a command line, we need to activate i18n, to have the date in the french language.
cur_language = translation.get_language()
try:
translation.activate(settings.LANGUAGE_CODE)
parsed = render_to_string('tutorialv2/export/content.md', {'content': versioned})
finally:
translation.activate(cur_language)

parsed_with_local_images = retrieve_and_update_images_links(parsed, directory=extra_contents_path)

md_file_path = base_name + '.md'

0 comments on commit af226ab

Please sign in to comment.