Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git command when translating files in Django

I have an existing application in Django. I want to add a translation on the page. On page I have:

{% trans 'Projects'%}

In .po file I added:

#: templates/staff/site.html: 200
msgid "Projects"
msgid "Projekty"

Then executes the command:

django-admin.py compilemessages -l pl

After this command, I get an error:

CommandError: This Should Be Run script from the Django Git checkout or your project or app tree, or with the settings Specified module.
like image 843
mark Avatar asked Mar 13 '15 07:03

mark


People also ask

How do I translate a template in Django?

In Django templates, the translate tag allows you to translate either a constant string or variable content. In fact, you can mark a string to be translated via {{ _("Hello World") }} or {% trans "Hello World" %} .

What is internationalization in Django?

The goal of internationalization and localization is to allow a single web application to offer its content in languages and formats tailored to the audience. Django has full support for translation of text, formatting of dates, times and numbers, and time zones.

Which support Django to use multilingual websites through its built in internationalization system to develop the websites which would support multiple languages?

Multilingual Support − Django supports multilingual websites through its built-in internationalization system. So you can develop your website, which would support multiple languages. Framework Support − Django has built-in support for Ajax, RSS, Caching and various other frameworks.


2 Answers

$ python manage.py compilemessages --settings nsp.settings

CommandError: This script should be run from the Django Git checkout or your project or app tree, or with the settings module specified.

I have got this error while I truly was inside project root folder. The problem was, that I was running this command without python manage.py makemessages first.

The error message is misleading.

like image 179
sobolevn Avatar answered Sep 24 '22 08:09

sobolevn


The error holds the answer, you could be running the script from anywhere so it cannot know which files to compile. Run the command from the project directory or specify the settings and you should be fine.

like image 32
Hedde van der Heide Avatar answered Sep 25 '22 08:09

Hedde van der Heide