Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Aug 4, 2019

Conversation

NordenF
Copy link
Contributor

@NordenF NordenF commented Jul 30, 2019

Moment.js allows customization of locale by dictionary-object
(docs: https://momentjs.com/docs/#/i18n/changing-locale/ )

Example:

    @bp.before_app_request
    def before_request():
        g.locale = "eo"
        g.locale_customization = {
            "longDateFormat": {
                "L": "DD.MM.YYYY",
                "LLL": "DD.MM.YYYY hh:mm",
            },
        }
    {% block scripts %}
        {{ moment.include_jquery() }}
        {{ moment.include_moment() }}
        {{ moment.locale(g.locale, customization=g.locale_customization) }}
    {% endblock %}

It should render:

	<script>
	    moment.locale('eo', {
                    'longDateFormat': {
                        'L': 'DD.MM.YYYY',
                        'LLL': 'DD.MM.YYYY hh:mm'
                    }
                }
            );
	</script>

@miguelgrinberg
Copy link
Owner

Thanks! Looks good. I'll test it out a bit before merging it.

@miguelgrinberg miguelgrinberg merged commit 5b27413 into miguelgrinberg:master Aug 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants