arrow
arrow copied to clipboard
Set default locale globally in app
It would be awesome if we could set a default locale for arrow globally. Right now it's hardcoded to en_us
in several places in the code. If we could set a global default then it would be easier to integrate with packages like Babel and Flask-Babel.
I'm imagining an API like this:
import arrow
from .myapp.i18n import get_locale
# It can be set statically...
arrow.set_locale_default('sv_se')
# ... or dynamically like this:
def get_arrow_locale():
return get_locale().lower()
arrow.set_locale_default(get_arrow_locale)
Agreed. A PR for this would be helpful if you have the time
I took a whack at this ticket and solved the issue with a global default variable that gets set with a call to arrow.set_locale_default()
, but a stranger on the internet told me it was a bad idea and could lead to trouble. I'd really like this feature implemented... does anyody have any bright ideas on how to solve this without a global variable?