Install `fr_FR.UTF-8` in my Koyeb Service

Hello,

I’m deploying a python webapp on a Koyeb Service. I’m working with datetime and want to format them in French, so I’ve set locale.setlocale(locale.LC_TIME, 'fr_FR.UTF-8') in my python script.

It works fine on my machine but I got an error when running on my service:

locale.Error: unsupported locale setting

Running locale -a on the service console returns a list of available locale settings, french is missing. I’m wondering how to install this local on my service?

I tried locale-gen fr_FR.UTF-8 but got a permission error and can’t manage to run it with sudo privileges.

I’m quite new to koyeb, thank you for your help!

Because you don’t have sudo permissions on Koyeb (unless you’re using a privileged Docker image), the best solution is to use Babel, which is designed for this.

Add Babel to your requirements.txt (or install with pip) and modify your code like this:

from datetime import datetime
from babel.dates import format_datetime

now = datetime.now()
formatted = format_datetime(now, locale='fr_FR')
print(formatted)

Hope this helps!