hustcc / timeago.js

:clock8: :hourglass: timeago.js is a tiny(2.0 kb) library used to format date with `*** time ago` statement.
https://timeago.org
MIT License
5.29k stars 411 forks source link

Documentation for importing languages #252

Open tacman opened 2 years ago

tacman commented 2 years ago

I'm trying to render in Spanish, and am not sure how to configure timeago.

import { register, format, render, cancel } from 'timeago.js';
import {esLocal} from 'timeago.js/lib/lang/es';
register('es', esLocal);

                    const nodes = document.querySelectorAll('.timeago');
                    // use render method to render nodes in real time
                    render(nodes, 'es');

I imagine I'm not registering it correctly, but I can't find the documentation on how to do that. Thanks.

ernestwisniewski commented 1 year ago
import es from 'timeago.js/lib/lang/es';
register('es', es);