134a21158e
commit3008b45a89
Author: Dessalines <happydooby@gmail.com> Date: Thu Aug 15 14:11:02 2019 -0700 Adding moment translation, and to i18next.ts file. commit620be4ecd8
Author: Autom <40275136+AutomCoding@users.noreply.github.com> Date: Thu Aug 15 19:08:57 2019 +0200 Minor tweaks Line 74: Change grammatical gender to neutrum for undefined target. Line 126: Possibly a more accurate translation. commite053040c58
Author: Autom <40275136+AutomCoding@users.noreply.github.com> Date: Thu Aug 15 18:55:32 2019 +0200 Translate remaining Swedish commitb126b59e15
Author: Autom <40275136+AutomCoding@users.noreply.github.com> Date: Thu Aug 15 18:38:20 2019 +0200 Typo (missing apostrophe in contraction) commit50a0c6b590
Author: Autom <40275136+AutomCoding@users.noreply.github.com> Date: Thu Aug 15 18:36:22 2019 +0200 Create sv.ts First half translated
44 lines
1 KiB
TypeScript
44 lines
1 KiB
TypeScript
import { Component } from 'inferno';
|
|
import * as moment from 'moment';
|
|
// import 'moment/locale/de';
|
|
import 'moment/locale/zh-cn';
|
|
import 'moment/locale/fr';
|
|
import 'moment/locale/sv';
|
|
import { getLanguage } from '../utils';
|
|
import { i18n } from '../i18next';
|
|
|
|
interface MomentTimeProps {
|
|
data: {
|
|
published?: string;
|
|
when_?: string;
|
|
updated?: string;
|
|
}
|
|
}
|
|
|
|
export class MomentTime extends Component<MomentTimeProps, any> {
|
|
|
|
constructor(props: any, context: any) {
|
|
super(props, context);
|
|
|
|
// Moment doesnt have zh, only zh-cn
|
|
let lang = getLanguage();
|
|
if (lang == 'zh') {
|
|
lang = 'zh-cn';
|
|
}
|
|
|
|
moment.locale(lang);
|
|
}
|
|
|
|
render() {
|
|
if (this.props.data.updated) {
|
|
return (
|
|
<span title={this.props.data.updated} className="font-italics">{i18n.t('modified')} {moment.utc(this.props.data.updated).fromNow()}</span>
|
|
)
|
|
} else {
|
|
let str = this.props.data.published || this.props.data.when_;
|
|
return (
|
|
<span title={str}>{moment.utc(str).fromNow()}</span>
|
|
)
|
|
}
|
|
}
|
|
}
|