Utility functions


Accepts a .po file path as argument and generates an appropriate .mo file. This copies the needed functionality from the original compilemessages command

translations.utils.concat_message_files(files, fn)[source]

Accepts a list of po files and a target file and uses the msgcat command to concat the files.


Detects the default language from the database. If no default language is present, the default settings.LANGUAGE_CODE is used.

This will reload its values in the context of a new thread.

translations.utils.get_language_from_request(request, check_path=False)[source]
This method is used as a replacement to the original django language

detection algorithm. It takes the db default language into consideration and does not deal with the Accept-Language header.

Analyzes the request to find what language the user wants the system to show. Only languages listed in settings.LANGUAGES are taken into account. If the user requests a sublanguage where we have a main language, we send out the main language.

If check_path is True, the URL path prefix will be checked for a language code, otherwise this is skipped for backwards compatibility.


Retrieve the supported languages.


Empty django’s internal translations dictionary when a message translation changes or the translations list is regenerated.

Previous topic


This Page