In contrast to English there are two different "versions" of how you can speak with others in German. You can use the formal, more impersonal "Sie" or the informal, more personal "du".

So, while you just say "Can you help me?" in English, you could say

  • Können Sie mir helfen? (formal, when you don't really know the person)
  • Kannst du mir helfen? (informal, when you know the person already)

in German.

My problem now is that for my Django application I would like to use the second version ("du") because it just suits much better for my web application. Thing is that Django (what I know?) just supports the formal version and now I have inconsistencies in the web application. Sometimes, there you can read "du" and sometimes "Sie" (from the default Django translations).

Of course, I could remove my manually added sentences with "du", but I do not like it because the web page will be for people who know each other.

My two questions:

  1. Is there a way to let Django use the informal translation that I perhaps have missed?
  2. In case Django does not provide this feature, is there a way to let Django support it (I would be happy to provide/change the translations). Or do you know some other solution?

Django's translation system is just gettext, so you have the features of gettext available to you.

The one you probably want here is contextual markers. Django supports this.

So you can mark strings for translation with a contextual marker of 'formal' or 'informal', and this will allow you to supply multiple translations of the string (one for each distinct contextual marker).

So, for example, if you have template code containing both

[% trans "Can you help me?" context "formal" %}

and

{% trans "Can you help me?" context "informal" %}

then your .po file will end up with that string twice, and you can supply the formal and informal translations, and Django will pull the correct one for the context you requested.

  • But I want to have informal for EVERY translation and only for Djangos default messages. Because my web application is German-only my manually added messages are hard-coded. – Aliquis Apr 29 at 8:09
  • Then supply your own translation files. You even get a head start by copy/pasting. Django will use any translation files it finds in your apps before it falls back to its own built-in ones. – James Bennett Apr 29 at 8:11

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.