Django French Translation – how to handle single quotes in translation strings?


I am using Python 3.5.2 and Django 1.10.

I have received the French translation .po file and can run the compilemessages command without receiving any errors.

However, when I run the site, many pages refuse to load.

I suspect that this is because the French translation .po file contains many single quotes (‘) in the translation strings.

For example,

#: .\core\constants\
msgid "Ascension Island"
msgstr "Île de l'Ascension"

I remember reading somewhere (but cannot find that reference anywhere) that the single quotes must have either a forward or back slash before them. So I tried that, but when I ran the compilemessage command, I got an error message of:

C:\Users\me\desktop\myapp\myapp\locale\fr\LC_MESSAGES\django.po:423:18: invalid control sequence

So how do I escape the French single quote in strings issue?

here is the header of my French language .po file:

# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <[email protected]>, YEAR.
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-05-04 12:55+1000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <[email protected]>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"


I am unsure what is the cause of this issue (maybe that the translator somehow corrupted the file?).

However, a workaround is instead of using the standard single quotation mark ', I have used this single quotation mark (taken from symbols in MS Word):

I am yet to check this with the French translator, but it looks and works OK.

I hope this helps someone.

Answered By – user1261774

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published