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",
|
"name": "@recogito/recogito-client-core",
|
||||||
"version": "0.2.3",
|
"version": "0.2.4",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -8402,9 +8402,9 @@
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"timeago-react": {
|
"timeago-react": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/timeago-react/-/timeago-react-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/timeago-react/-/timeago-react-3.0.1.tgz",
|
||||||
"integrity": "sha512-dO7dBjuRqUSoyt7kLc6UJLvfN5F0JbC2qTqIsjpRFaMXu9bK9PKuWQ3/XD/kPZWGVtwpNimKDpQC3Q2ok8MMSA==",
|
"integrity": "sha512-IWSLWO47saoPOplrrLF5JbOW474oXnx+GfTw4SIuskY9yaSbzNnf0Lah2G9AwLuuQ4dQHSu4EgEOSNTPBxdoQA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"timeago.js": "^4.0.0"
|
"timeago.js": "^4.0.0"
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
"preact": "^10.4.1",
|
"preact": "^10.4.1",
|
||||||
"react-contenteditable": "^3.3.3",
|
"react-contenteditable": "^3.3.3",
|
||||||
"react-transition-group": "^4.3.0",
|
"react-transition-group": "^4.3.0",
|
||||||
"timeago-react": "^3.0.0",
|
"timeago-react": "^3.0.1",
|
||||||
"tiny-emitter": "^2.1.0",
|
"tiny-emitter": "^2.1.0",
|
||||||
"uuid": "^8.3.0"
|
"uuid": "^8.3.0"
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import TimeAgo from 'timeago-react';
|
||||||
import DropdownMenu from './DropdownMenu';
|
import DropdownMenu from './DropdownMenu';
|
||||||
import TextEntryField from './TextEntryField';
|
import TextEntryField from './TextEntryField';
|
||||||
import { ChevronDownIcon } from '../../../Icons';
|
import { ChevronDownIcon } from '../../../Icons';
|
||||||
|
import i18n from '../../../i18n';
|
||||||
|
|
||||||
/** A single comment inside the CommentWidget **/
|
/** A single comment inside the CommentWidget **/
|
||||||
const Comment = props => {
|
const Comment = props => {
|
||||||
|
@ -31,7 +32,9 @@ const Comment = props => {
|
||||||
<span className="r6o-lastmodified-by">{props.body.creator.name || props.body.creator.id}</span>
|
<span className="r6o-lastmodified-by">{props.body.creator.name || props.body.creator.id}</span>
|
||||||
{ props.body.created &&
|
{ props.body.created &&
|
||||||
<span className="r6o-lastmodified-at">
|
<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>
|
</span>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import * as Polyglot from 'node-polyglot';
|
import * as Polyglot from 'node-polyglot';
|
||||||
|
import * as timeago from 'timeago.js';
|
||||||
|
|
||||||
const i18n = new Polyglot({ allowMissing: true });
|
const i18n = new Polyglot({ allowMissing: true });
|
||||||
|
|
||||||
|
@ -7,4 +8,26 @@ i18n.init = lang => {
|
||||||
i18n.extend(require(`./messages_${lang}.json`));
|
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;
|
export default i18n;
|
Loading…
Reference in New Issue