16👍
The easiest way is to download the precompiled binary installer. Download the “static” flavor of your Operating System (32bit or 64bit) and simple run the installer.
Update the system PATH:
Control Panel > System > Advanced > Environment Variables
In the System variables list, click Path, click Edit and then New.
Add C:\Program Files\gettext-iconv\bin
value.
To check if it’s working, go to cmd, navigate to your project folder and type
"manage makemessages -l de".
You may have to configure the path to store translations. Create a dir named “locale” in your project dir and point to it at settings.py
Also make sure to set the local path in settings.py file:
LOCALE_PATHS = (
BASE_DIR + 'locale/', )
24👍
Django removed this explanation from the recent docs and it took me some time to found it so i pasted it here before this old documentation goes offline:
Source: Django Docs 1.7
Download the following zip files from the GNOME servers
- gettext-runtime-X.zip
- gettext-tools-X.zip
X is the version number (It needs to be 0.15 or higher)
Extract the contents of the bin\
directories in both files to the same folder on your system (i.e. C:\Program Files\gettext-utils
)
Update the system PATH:
Control Panel > System > Advanced > Environment Variables
In the System variables list, click Path, click Edit and then New.
Add C:\Program Files\gettext-utils\bin
value.
You may also use gettext binaries you have obtained elsewhere, so long as the xgettext –version command works properly. Do not attempt to use Django translation utilities with a gettext package if the command xgettext –version entered at a Windows command prompt causes a popup window saying “xgettext.exe has generated errors and will be closed by Windows”.
After doing this I tested and ./manage.py makemessages -l pt
works
- How do I add authentication and endpoint to Django Celery Flower Monitoring?
- How to convert request.user into a proxy auth.User class?
2👍
I also had the same problem. After that I downloaded and installed this and everything worked.https://mlocati.github.io/articles/gettext-iconv-windows.html.
- AngularJS + Django: URL refresh or direct access not loading correctly
- 'Questions ' object is not iterable Django
2👍
Let me save you many hours that I had to spend in order to solve this.
One of the possibilities is that after you have successfully done all the above and done
pip install python-gettext
you may have improperly configured your IDE or venv. In order to bypass this, go to the command prompt, navigate to your root folder and run py manage.py makemessages
from there. It will work.
- Django : Can we use .exclude() on .get() in django querysets
- Logout Django Rest Framework JWT
- How do i configure the django rest framework pagination url
- Defining a custom app_list in django admin index page
0👍
After extracting the relevant files and adding their location to the path, I still had the same problem. But then I ran the django-admin makemessages -l sr-Latn command in the command prompt instead of powershell and it worked. More preciselly, I first got notification that libstdc++-6.dll is missing, and after installing it in the relevant directory as explained here https://www.dll-files.com/support/#200924305 , it worked.
0👍
Thank you, for sharing your experience.
The best answer is https://stackoverflow.com/a/45574890/3786145.
Just after many efforts, it is good to mention that:
if you want to use this tool in Pycharm IDE such that works in a different environment(wich python path and path variable are changed (eg: OSGeo)), it is necessary to make a batch file and add these two directories to the changed path:
path %PATH%;C:\Program Files\gettext-iconv\bin
path %path%;C:\Program Files\gettext-iconv\lib\gettext
SET PYCHARM="D:\Program Files\JetBrains\PyCharm 2020.2.2\bin\pycharm64.exe"
start "PyCharm aware of get text" /B %PYCHARM% %*
After running Pycharm using this batch file, go to tools/Run manage.py Task. In the appeared window write your command like this:
makemessages -l ‘fa_IR’
for more information refer to:
[1] https://www.jetbrains.com/help/idea/creating-message-files.html
[2] https://silverspringenergy.com/using-pycharm-as-an-ide-for-qgis-3-plugin-development-2/
- Psycopg2 OperationalError: cursor does not exist
- Django drf simple-jwt authentication"detail": "No active account found with the given credentials"
- How to return data with 403 error in Django Rest Framework?
- Disabling Django CSRF for views that do not always have a response
- What is the right way to use angular2 http requests with Django CSRF protection?