I have a similar issue as found here Why doesn't Django produce locale files from template files in another directory?
However I don't understand the solution. My structure:
Project
App1
locale
templates
App2
locale
templates
templates
somefilethatneedstranslation.html
Now when I run this command from App1:
python ../manage.py App1 -l nl
It nicely creates a po file for the App1 templates in the App1 locale folder
However I want my global templates to be translated aswell.. note: I do NOT want a locale folder in my project root, so I tried adding a symlink to the templates folder from App1 but it does not append the translation results to the App1/locale/po file
from the App1 folder
ln -s ../templates/locale/* translations
python ../manage.py App1 -l nl --symlinks
What am I missing?
note:
from the templates folder
python ../manage.py templates -l nl
could work, but it won't because obviously templates is not an installed app, it seems I am missing the obvious...
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.
Django offers multiple language support out-of-the-box. In fact, Django is translated into more than 100 languages. This tutorial looks at how to add multiple language support to your Django project.
Internationalization, shortly known as i18n, is the process of adapting your software to support various linguistic and cultural settings. It should not only translate instructions and messages but also take into account varying user experience across societies.
gettext_lazy() In definitions like forms or models you should use gettext_lazy because the code of this definitions is only executed once (mostly on django's startup); gettext_lazy translates the strings in a lazy fashion, which means, eg.
The full deprecation message (which is also explained in the translation docs) is:
Translations in the project directory aren't supported anymore. LOCALE_PATHS setting instead.
This message is perhaps a bit unclear. While automatic discovery of translations in the project directory is deprecated, the use of LOCALE_PATHS
to reference a project-level locale folder is totally acceptable.
If you have project-level templates, it doesn't make sense to have these templates translated in an app-specific locale location: keep a project-level locale directory, reference it in LOCALE_PATHS.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With