Skip to content

Commit

Permalink
Add support of customization object for the method "moment.locale(...…
Browse files Browse the repository at this point in the history
…)". (#50)

* Add support of customization object for the method "moment.locale(...)".

* Fix code style.
  • Loading branch information
NordenF authored and miguelgrinberg committed Aug 4, 2019
1 parent f0ad8c4 commit 5b27413
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions flask_moment.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,18 @@ def include_jquery(version=default_jquery_version, local_js=None,
return Markup(js)

@staticmethod
def locale(language='en', auto_detect=False):
def locale(language='en', auto_detect=False, customization=None):
if auto_detect:
return Markup('<script>\nvar locale = '
'window.navigator.userLanguage || '
'window.navigator.language;\n'
'moment.locale(locale);\n</script>')
else:
if customization:
return Markup(
'<script>\nmoment.locale("%s");\n</script>' % language)
'<script>\nmoment.locale("%s", %s);\n</script>' % (
language, customization))
return Markup(
'<script>\nmoment.locale("%s");\n</script>' % language)

@staticmethod
def lang(language):
Expand Down

0 comments on commit 5b27413

Please sign in to comment.