Skip to content

Commit

Permalink
timeago i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
twd2 committed Sep 16, 2016
1 parent d1c20e8 commit a9bdd6f
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions vj4/locale/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ domain_edit: Domain Edit
domain_role: Domain Role
domain_user: Domain User
domain_permission: Domain Permission
timeago_locale: en
1 change: 1 addition & 0 deletions vj4/locale/zh_CN.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -436,3 +436,4 @@ View training: 查看训练
Have ALL PERMISSIONS in this domain: 在此域中拥有全部权限
Select User: 选择用户
Submitted: 已递交
timeago_locale: zh_CN
1 change: 1 addition & 0 deletions vj4/locale/zh_TW.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -416,3 +416,4 @@ Create contests: 創建比賽
Attend contests: 參加比賽
View training: 檢視訓練
Have ALL PERMISSIONS in this domain: 在此域中擁有全部許可權
timeago_locale: zh_CN
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import moment from 'moment';
import 'jquery-scroll-lock';
import 'jquery.easing';

import i18n from '../../utils/i18n';

const mapStateToProps = (state) => ({
activeId: state.activeId,
item: state.activeId !== null
Expand All @@ -32,7 +34,7 @@ export default class MessagePadDialogueContentContainer extends React.PureCompon
>
<div>{reply.content}</div>
<time data-tooltip={moment(reply.at).format('YYYY-MM-DD HH:mm:ss')}>
<TimeAgo date={reply.at} />
<TimeAgo date={reply.at} locale={i18n('timeago_locale')} />
</time>
</Message>
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default class ScratchpadRecordsRowContainer extends React.PureComponent {
</td>
<td className="col--at">
<time data-tooltip={moment(submitAt).format('YYYY-MM-DD HH:mm:ss')}>
<TimeAgo date={submitAt} />
<TimeAgo date={submitAt} locale={i18n('timeago_locale')} />
</time>
</td>
</tr>
Expand Down
2 changes: 2 additions & 0 deletions vj4/ui/components/time/time.page.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { AutoloadPage } from '../../misc/PageLoader';
import libTimeago from 'timeago.js';
import i18n from '../../utils/i18n';

const timeago = libTimeago();
timeago.setLocale(i18n('timeago_locale'));

function runRelativeTime($container) {
for (const element of $container.find('span.time[data-timestamp]')) {
Expand Down

0 comments on commit a9bdd6f

Please sign in to comment.