arrow icon indicating copy to clipboard operation
arrow copied to clipboard

Set default locale globally in app

Open jacobsvante opened this issue 8 years ago • 2 comments

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)

jacobsvante avatar May 10 '16 16:05 jacobsvante

Agreed. A PR for this would be helpful if you have the time

andrewelkins avatar Dec 31 '16 22:12 andrewelkins

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?

teschmitt avatar Apr 15 '17 12:04 teschmitt