Rosetta can't find anything to translate "Nothing to translate!"

772 Views Asked by At

Versions:

  • Python 3.5.1
  • django 1.10
  • django-rosetta 0.7.13

I followed the rosetta tutorial. After creating some sentences to translate in a template using {% trans "sentence" %} (and {% load i18n %}), and running django-admin's makemessages and compilemessages, rosetta still cannot find anything to translate:

Nothing to translate!

You haven't specified any languages in your settings file, or haven't yet generated a batch of translation catalogs.

Please refer to Django's I18N documentation for a guide on how to set up internationalization for your project.

Notes:

  • I had to solve some other bugs along the way. See here.
  • I looked in the locale folder and the .po and .mo files are there, and they look correct (i.e. have the sentences I made in the template). Here's the .po file.
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-06-13 13:31+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: templates/www/batch.html:8
msgid "(mother) and"
msgstr ""

#: templates/www/batch.html:8
msgid "(father)"
msgstr ""
  • I haven't used any fuzzy or laziness, except in one place needed to avoid an error (see below). But it didn't work before I did that either.
  • I tried adding the desired language to settings.py's LANGUAGES list. No effect, except I had to solve yet another bug.
  • I did add the LOCALE_PATHS suggested in this question.
  • I did restart the server a bunch of times.
  • I'm running the server via runserver (via PyCharm). Local development.

I can't think of or find anything more to try.

1

There are 1 best solutions below

1
Ehsan Bitaraf On

This worked for me:

  1. create locale directory in project root

  2. run django-admin makemessages -l fa -i myenv