moment-module icon indicating copy to clipboard operation
moment-module copied to clipboard

updateLocale is not defined

Open kalnode opened this issue 2 years ago • 0 comments

This Moment plugin works in my Nuxt app, however I'm attempting to customize labels for .fromNow() to be shorter. To do this many people recommend making use of custom locale's, like below.

Fails:

When using .fromNow( updateLocale(...

I get an error:

updateLocale is not defined

Works: When using .fromNow() as is, there's no issue, however there's no point as no customization occurs!

Vue template:

{{ getDateFrom(conv.lastMessage.editedAt ? conv.lastMessage.editedAt : conv.lastMessage.createdAt) }}

Custom function:

getDateFrom(givenDate) {
            return this.$moment(givenDate)
            .fromNow(
                updateLocale("en", {
                    relativeTime: {
                        future: "in %s",
                        past: "%s ",
                        s: "sec",
                        m: "%d m",
                        mm: "%d m",
                        h: "%d h",
                        hh: "%d h",
                        d: "%d d",
                        dd: "%d d",
                        M: "a mth",
                        MM: "%d mths",
                        y: "y",
                        yy: "%d y"
                    }
                })
            )
        }

kalnode avatar Nov 09 '22 15:11 kalnode