# translation in three different languages for portfolio website

**URL:** <https://forum.djangoproject.com/t/translation-in-three-different-languages-for-portfolio-website/33314>\
**Category:** Getting Started\
**Created:** [July 26, 2024, 6:32pm UTC](https://forum.djangoproject.com/t/translation-in-three-different-languages-for-portfolio-website/33314 "2024-07-26T18:32:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![DoriDoro](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/doridoro/32/5014_2.png) [@DoriDoro](https://forum.djangoproject.com/u/DoriDoro)\
**Post date:** [July 26, 2024, 6:32pm UTC](https://forum.djangoproject.com/t/translation-in-three-different-languages-for-portfolio-website/33314/1 "2024-07-26T18:32:52Z")

</div>

Hello,

I am building a portfolio website with a lot of content and I would like to have the website content available in three languages (English, German and French). That what I have seen and done is really time consuming and really intensive and I hope there is a easier way of doing the translation.

My settings:

```python
# settings.py

MIDDLEWARE = [
    "django.middleware.security.SecurityMiddleware",
    "django.contrib.sessions.middleware.SessionMiddleware",
    "django.middleware.locale.LocaleMiddleware",
    "django.middleware.common.CommonMiddleware",
...
]

LANGUAGE_CODE = "en-us"
TIME_ZONE = "Europe/Paris"
USE_I18N = True
USE_L10N = True
USE_TZ = True
LANGUAGES = (
    ("en", _("English")),
    ("de", _("German")),
    ("fr", _("French")),
)
LOCALE_PATHS = [
    os.path.join(BASE_DIR, "locale"),
]

```

I have created the ‘locale’ folder in root directory, the ‘django.po’ files for German and French are generated with command: `django-admin makemessages -a`. For simple `gettext_lazy` translations in models.py files and in settings.py file is everything working fine. Even I think to translate everything by yourself is really time consuming! If there is an easier way of translating these texts, it would be very much appreciated if you can tell me.

**What problem am I facing?**

The view looks like:

```python
#views.py

class IndexView(TemplateView):
    template_name = "index.html"

    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context["facts"] = Fact.objects.filter(published=True).values_list(
            "content", flat=True
        )
        return context

```

In index.html file I use a for loop to display facts.

```html
      {% if facts %}
      <div class="row mt-4 container">
        <div class="col-lg-7 content">
          {% for fact in facts %}
          <ul>
            <li>
              <i class="bi bi-chevron-right"></i>
              {% blocktrans %}{{ fact }}{% endblocktrans %}
            </li>
          </ul>
          {% endfor %}
        </div>
      </div>
      {% endif %}

```

For the index.html file, I get this ‘template’ (I do not know how to call it) after I use `django-admin makemessages -a`

```po
#: app/templates/index.html:21
#, python-format
msgid "%(fact)s"
msgstr ""

```

Now my question: How do I use this ‘template’ to create 3 facts in the django.po file?

**What have I tried?**

```po
# django.po

#: app/templates/index.html:21
#, python-format
msgid "%(enter the text)s"
msgstr "%(gebe die Übersetzung ein)s"

#: app/templates/index.html:21
#, python-format
msgid "%(enter the second text)s"
msgstr "%(gebe die zweite Übersetzung ein)s"

#: app/templates/index.html:21
#, python-format
msgid "%(enter the third text)s"
msgstr "%(gebe die dritte Übersetzung ein)s"

```

```po
# django.po

#: app/templates/index.html:21
#, python-format
msgid "enter the text"
msgstr "gebe die Übersetzung ein"

#: app/templates/index.html:21
#, python-format
msgid "enter the second text"
msgstr "gebe die zweite Übersetzung ein"

#: app/templates/index.html:21
#, python-format
msgid "enter the third text"
msgstr "gebe die dritte Übersetzung ein"

```

output when using command: `django-admin compilemessages`:

```sh
File “/home/doro/Desktop/django_portfolio/.venv/lib/python3.11/site-packages/django/contrib/flatpages/locale/af/LC_MESSAGES/django.po” is already compiled and up to date.
CommandError: compilemessages generated one or more errors.

```

this red message `CommandError: compilemessages generated one or more errors.` is at the end of the command and no indications why, where, etc.

Is it possible to generate with this html template the complied messages?

Thanks in advance,  
Doro

---

<div class="post-metadata">

**Author:** ![leandrodesouzadev](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/leandrodesouzadev/32/8981_2.png) [@leandrodesouzadev](https://forum.djangoproject.com/u/leandrodesouzadev)\
**Post date:** [July 27, 2024, 12:17pm UTC](https://forum.djangoproject.com/t/translation-in-three-different-languages-for-portfolio-website/33314/2 "2024-07-27T12:17:46Z")

</div>

The question is: translating “static” text is one thing.  
Translating content that is on your database, is another thing.  
You can use something like: [django-modeltranslation](https://github.com/deschler/django-modeltranslation) to that

---

<div class="post-metadata">

**Author:** ![DoriDoro](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/doridoro/32/5014_2.png) [@DoriDoro](https://forum.djangoproject.com/u/DoriDoro)\
**Post date:** [July 27, 2024, 1:57pm UTC](https://forum.djangoproject.com/t/translation-in-three-different-languages-for-portfolio-website/33314/3 "2024-07-27T13:57:54Z")

</div>

That was a really nice advice. Thank you very much.

I can recommend this tool. It was really simple to use.

- install the package
- add the package into `INSTALLED_APPS` in `settings.py`
- create the `translation.py` files and add the fields which should be translated
- add the `TranslationAdmin` into `admin.py` file
- makemigrations
- migrate

and that was it…

---

<div class="post-metadata">

**Author:** ![leandrodesouzadev](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/leandrodesouzadev/32/8981_2.png) [@leandrodesouzadev](https://forum.djangoproject.com/u/leandrodesouzadev)\
**Post date:** [July 27, 2024, 2:17pm UTC](https://forum.djangoproject.com/t/translation-in-three-different-languages-for-portfolio-website/33314/4 "2024-07-27T14:17:11Z")

</div>

I have never used it, but always considered using it.  
Good to know that it worked for you!  
You can always find some awesome django packages on [django-packages](https://djangopackages.org/)
