Fixing Python’s “unknown locale”

One problem I run into every time I upgrade Python or install a new Ubuntu computer is this (caused by me running locale en_DK)

    raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: en_DK

I am not an Python expert (not even remotely) so I used some time looking for some sort of fix for this problem.

Open the file /usr/lib/python2.5/ and find the line containing en_gb (around line 760) and then add this above:

'en_dk':                                'en_DK.ISO8859-1',
'en_dk.iso88591':                       'en_DK.ISO8859-1',
'[email protected]':                           'en_DK.ISO8859-15'

Remember to use the right indentation.