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

updateLocale is not defined #92

Open
kalnode opened this issue Nov 9, 2022 · 0 comments
Open

updateLocale is not defined #92

kalnode opened this issue Nov 9, 2022 · 0 comments

Comments

@kalnode
Copy link

kalnode commented Nov 9, 2022

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"
                    }
                })
            )
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant