Humanize in django / python how to translate

I only need a quick way to translate days into Italian in django. Using humanize, it works correctly, but obviously always in English

<h1 class="">{{ h.datainserimento|date:"d M Y"  }} | {{ h.nomegiorno }}</h1>

def nomegiorno(self):
   pio = self.datainserimento.strftime("%A")
   return pio

at

<h1 class="">21 May 2014 | Wednesday</h1>

thank!

+4
source share
1 answer

Try using hardcoded test cases translation.activate(language)before submitting:

def nomegiorno(self):
   old = translation.get_language()
   print('old', old)
   translation.activate('it')
   pio = self.datainserimento.strftime("%A")
   translation.activate(old)
   return pio

And tell me what you have, this should help anyway

0
source

Source: https://habr.com/ru/post/1539884/


All Articles