use locale for dates too
This commit is contained in:
@@ -71,6 +71,7 @@
|
||||
"enter_confirmation_code_prompt": "Enter confirmation code sent to you by {method}:",
|
||||
"numeric_confirmation_code_prompt": "Numbers only",
|
||||
"button_confirm": "Confirm",
|
||||
"save_attachment": "save",
|
||||
"invalid_content": "invalid content",
|
||||
"user_not_found": "Not found",
|
||||
"badge_you": "you",
|
||||
|
||||
+2
-1
@@ -121,5 +121,6 @@
|
||||
"update_available": "Есть новая версия приложения. <a href=\"\">Обновить</a>.",
|
||||
"user_not_found": "Не найден",
|
||||
"reconnect_countdown": "Нет связи. Подключение через {seconds}с…",
|
||||
"reconnect_now": "Подключить сейчас."
|
||||
"reconnect_now": "Подключить сейчас.",
|
||||
"save_attachment": "сохранить"
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Short representation of time in the past.
|
||||
export function shortDateFormat(then) {
|
||||
var locale = window.navigator.userLanguage || window.navigator.language;
|
||||
var now = new Date();
|
||||
export function shortDateFormat(then, locale) {
|
||||
locale = locale || window.navigator.userLanguage || window.navigator.language;
|
||||
const now = new Date();
|
||||
if (then.getFullYear() == now.getFullYear()) {
|
||||
if (then.getMonth() == now.getMonth() && then.getDate() == now.getDate()) {
|
||||
return then.toLocaleTimeString(locale, {hour12: false, hour: '2-digit', minute: '2-digit'});
|
||||
@@ -20,19 +20,19 @@ export function bytesToHumanSize(bytes) {
|
||||
return '0 Bytes';
|
||||
}
|
||||
|
||||
var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB'];
|
||||
var bucket = Math.min(Math.floor(Math.log2(bytes) / 10) | 0, sizes.length-1);
|
||||
var count = bytes / Math.pow(1024, bucket);
|
||||
var round = bucket > 0 ? (count < 3 ? 2 : (count < 30 ? 1 : 0)) : 0;
|
||||
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB'];
|
||||
const bucket = Math.min(Math.floor(Math.log2(bytes) / 10) | 0, sizes.length-1);
|
||||
const count = bytes / Math.pow(1024, bucket);
|
||||
const round = bucket > 0 ? (count < 3 ? 2 : (count < 30 ? 1 : 0)) : 0;
|
||||
return count.toFixed(round) + ' ' + sizes[bucket];
|
||||
}
|
||||
|
||||
// Get 32 bit integer hash value for a string. Ideally it should produce the same value
|
||||
// as Java's String#hash().
|
||||
export function stringHash(value) {
|
||||
var hash = 0;
|
||||
let hash = 0;
|
||||
value = '' + value;
|
||||
for (var i = 0; i < value.length; i++) {
|
||||
for (let i = 0; i < value.length; i++) {
|
||||
hash = ((hash << 5) - hash) + value.charCodeAt(i);
|
||||
hash = hash & hash; // Convert to 32bit integer
|
||||
}
|
||||
|
||||
+3
-1
@@ -72,6 +72,7 @@
|
||||
"enter_confirmation_code_prompt": "Enter confirmation code sent to you by {method}:",
|
||||
"numeric_confirmation_code_prompt": "Numbers only",
|
||||
"button_confirm": "Confirm",
|
||||
"save_attachment": "save",
|
||||
"invalid_content": "invalid content",
|
||||
"user_not_found": "Not found",
|
||||
"badge_you": "you",
|
||||
@@ -247,6 +248,7 @@
|
||||
"update_available": "Есть новая версия приложения. <a href=\"\">Обновить</a>.",
|
||||
"user_not_found": "Не найден",
|
||||
"reconnect_countdown": "Нет связи. Подключение через {seconds}с…",
|
||||
"reconnect_now": "Подключить сейчас."
|
||||
"reconnect_now": "Подключить сейчас.",
|
||||
"save_attachment": "сохранить"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -471,7 +471,8 @@ class MessagesView extends React.Component {
|
||||
if (cont.online) {
|
||||
lastSeen = formatMessage(messages.online_now);
|
||||
} else if (cont.seen) {
|
||||
lastSeen = formatMessage(messages.last_seen) + ": " + shortDateFormat(cont.seen.when);
|
||||
lastSeen = formatMessage(messages.last_seen) + ": " +
|
||||
shortDateFormat(cont.seen.when, this.props.intl.locale);
|
||||
// TODO: also handle user agent in c.seen.ua
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React from 'react';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
|
||||
import FileProgress from './file-progress.jsx';
|
||||
import { bytesToHumanSize } from '../lib/strformat.js';
|
||||
@@ -73,7 +74,8 @@ export default class Attachment extends React.Component {
|
||||
onCancel={this.handleCancel} />
|
||||
:
|
||||
<div><a href={url} download={this.props.filename} onClick={helperFunc} >
|
||||
<i className="material-icons">file_download</i> save
|
||||
<i className="material-icons">file_download</i> <FormattedMessage id="save_attachment"
|
||||
defaultMessage="save" description="Call to save an attachment" />
|
||||
</a></div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -28,7 +28,7 @@ class ReceivedMarker extends React.PureComponent {
|
||||
} else if (this.props.received == Tinode.MESSAGE_STATUS_FAILED) {
|
||||
timestamp = formatMessage(messages.failed);
|
||||
} else {
|
||||
timestamp = shortDateFormat(this.props.timestamp);
|
||||
timestamp = shortDateFormat(this.props.timestamp, this.props.intl.locale);
|
||||
}
|
||||
|
||||
let marker = null;
|
||||
|
||||
Reference in New Issue
Block a user