From d2b7262aad165fdf8248fd3e2ca9f9bd4d9798bb Mon Sep 17 00:00:00 2001 From: Rainer Simon Date: Fri, 30 Oct 2020 14:59:03 +0100 Subject: [PATCH] Enabled supported locales for TimeAgo (cf. https://github.com/recogito/annotorious/issues/64) --- package-lock.json | 8 ++++---- package.json | 2 +- src/editor/widgets/comment/Comment.jsx | 5 ++++- src/i18n/index.js | 23 +++++++++++++++++++++++ 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2d3c5b8..eed2613 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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" } diff --git a/package.json b/package.json index 32ad3ed..e93574b 100644 --- a/package.json +++ b/package.json @@ -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" } diff --git a/src/editor/widgets/comment/Comment.jsx b/src/editor/widgets/comment/Comment.jsx index cf17846..4830b13 100644 --- a/src/editor/widgets/comment/Comment.jsx +++ b/src/editor/widgets/comment/Comment.jsx @@ -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 => { {props.body.creator.name || props.body.creator.id} { props.body.created && - + } diff --git a/src/i18n/index.js b/src/i18n/index.js index 4df2baa..74819f5 100644 --- a/src/i18n/index.js +++ b/src/i18n/index.js @@ -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; \ No newline at end of file