Enabled supported locales for TimeAgo (cf. https://github.com/recogito/annotorious/issues/64)
This commit is contained in:
parent
2e4dcb9e31
commit
d2b7262aad
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@recogito/recogito-client-core",
|
||||
"version": "0.2.3",
|
||||
"version": "0.2.4",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -8402,9 +8402,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"timeago-react": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/timeago-react/-/timeago-react-3.0.0.tgz",
|
||||
"integrity": "sha512-dO7dBjuRqUSoyt7kLc6UJLvfN5F0JbC2qTqIsjpRFaMXu9bK9PKuWQ3/XD/kPZWGVtwpNimKDpQC3Q2ok8MMSA==",
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/timeago-react/-/timeago-react-3.0.1.tgz",
|
||||
"integrity": "sha512-IWSLWO47saoPOplrrLF5JbOW474oXnx+GfTw4SIuskY9yaSbzNnf0Lah2G9AwLuuQ4dQHSu4EgEOSNTPBxdoQA==",
|
||||
"requires": {
|
||||
"timeago.js": "^4.0.0"
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
"preact": "^10.4.1",
|
||||
"react-contenteditable": "^3.3.3",
|
||||
"react-transition-group": "^4.3.0",
|
||||
"timeago-react": "^3.0.0",
|
||||
"timeago-react": "^3.0.1",
|
||||
"tiny-emitter": "^2.1.0",
|
||||
"uuid": "^8.3.0"
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import TimeAgo from 'timeago-react';
|
|||
import DropdownMenu from './DropdownMenu';
|
||||
import TextEntryField from './TextEntryField';
|
||||
import { ChevronDownIcon } from '../../../Icons';
|
||||
import i18n from '../../../i18n';
|
||||
|
||||
/** A single comment inside the CommentWidget **/
|
||||
const Comment = props => {
|
||||
|
@ -31,7 +32,9 @@ const Comment = props => {
|
|||
<span className="r6o-lastmodified-by">{props.body.creator.name || props.body.creator.id}</span>
|
||||
{ props.body.created &&
|
||||
<span className="r6o-lastmodified-at">
|
||||
<TimeAgo datetime={props.env.toClientTime(props.body.created)} />
|
||||
<TimeAgo
|
||||
datetime={props.env.toClientTime(props.body.created)}
|
||||
locale={i18n.locale()} />
|
||||
</span>
|
||||
}
|
||||
</div>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import * as Polyglot from 'node-polyglot';
|
||||
import * as timeago from 'timeago.js';
|
||||
|
||||
const i18n = new Polyglot({ allowMissing: true });
|
||||
|
||||
|
@ -7,4 +8,26 @@ i18n.init = lang => {
|
|||
i18n.extend(require(`./messages_${lang}.json`));
|
||||
}
|
||||
|
||||
/** Load and register TimeAgo locales **/
|
||||
import ar from 'timeago.js/lib/lang/ar';
|
||||
import cs from 'timeago.js/lib/lang/cs';
|
||||
import de from 'timeago.js/lib/lang/de';
|
||||
import es from 'timeago.js/lib/lang/es';
|
||||
import gl from 'timeago.js/lib/lang/gl';
|
||||
import hi from 'timeago.js/lib/lang/hi_IN';
|
||||
import it from 'timeago.js/lib/lang/it';
|
||||
import pt from 'timeago.js/lib/lang/pt_BR';
|
||||
import sv from 'timeago.js/lib/lang/sv';
|
||||
// import ur from 'timeago.js/lib/lang/ur'; // Not currently supported by TimeAgo
|
||||
|
||||
timeago.register('ar', ar);
|
||||
timeago.register('cs', cs);
|
||||
timeago.register('de', de);
|
||||
timeago.register('es', es);
|
||||
timeago.register('gl', gl);
|
||||
timeago.register('hi', hi);
|
||||
timeago.register('it', it);
|
||||
timeago.register('pt', pt);
|
||||
timeago.register('sv', sv);
|
||||
|
||||
export default i18n;
|
Loading…
Reference in New Issue