There were a few gotchas I found when trying to do the obvious thing, but here’s a code snippet that will allow you to add German as the default locale to anvil’s datepicker
from anvil.js.window import moment, document
script = document.createElement('script')
script.src = "https://cdn.jsdelivr.net/npm/moment@2.29.1/locale/de.js"
document.head.appendChild(script)
# We need to add the locale after anvil has loaded moment
# I used moment's predefined locale
# you can also set a custom locale without using a script
# moment.updateLocale('en', {'weekdaysMin': ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa']}) # etc
# see docs https://momentjs.com/docs/#/customization/
locale = moment.locale('de')
# this doesn't happen instantly so set it and then wait
while locale != 'de':
from time import sleep
sleep(.01)
locale = moment.locale()
# you may want to set a way to exit here to prevent an infinite loop
# put the code above your startup form or in a startup module
class Form1(Form1Template):
...