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