aboutsummaryrefslogtreecommitdiff
path: root/modern/src/common/formatter.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-09-03 09:41:20 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2021-09-03 09:41:20 -0700
commit6ac6ceaed16b2ae5ef58ba599d24a868ac2f816a (patch)
treeedd24c732d6439e6fb3c03f021d9f0842468d474 /modern/src/common/formatter.js
parent105e4ec887e249ec47db83095504012bad22df80 (diff)
downloadtrackermap-web-6ac6ceaed16b2ae5ef58ba599d24a868ac2f816a.tar.gz
trackermap-web-6ac6ceaed16b2ae5ef58ba599d24a868ac2f816a.tar.bz2
trackermap-web-6ac6ceaed16b2ae5ef58ba599d24a868ac2f816a.zip
Finish migrations
Diffstat (limited to 'modern/src/common/formatter.js')
-rw-r--r--modern/src/common/formatter.js16
1 files changed, 6 insertions, 10 deletions
diff --git a/modern/src/common/formatter.js b/modern/src/common/formatter.js
index 5db7a420..7a18d1af 100644
--- a/modern/src/common/formatter.js
+++ b/modern/src/common/formatter.js
@@ -1,8 +1,7 @@
import moment from 'moment';
import { useTranslation } from '../LocalizationProvider';
-export const formatBoolean = (value) => {
- const t = useTranslation();
+export const formatBoolean = (value, t) => {
return value ? t('sharedYes') : t('sharedNo');
}
@@ -10,7 +9,7 @@ export const formatNumber = (value, precision = 1) => Number(value.toFixed(preci
export const formatDate = (value, format = 'YYYY-MM-DD HH:mm') => moment(value).format(format);
-export const formatPosition = (value, key) => {
+export const formatPosition = (value, key, t) => {
if (value != null && typeof value === 'object') {
value = value[key];
}
@@ -32,14 +31,13 @@ export const formatPosition = (value, key) => {
if (typeof value === 'number') {
return formatNumber(value);
} if (typeof value === 'boolean') {
- return formatBoolean(value);
+ return formatBoolean(value, t);
}
return value;
}
};
-export const formatDistance = (value, unit) => {
- const t = useTranslation();
+export const formatDistance = (value, unit, t) => {
switch (unit) {
case 'mi':
return `${(value * 0.000621371).toFixed(2)} ${t('sharedMi')}`;
@@ -51,8 +49,7 @@ export const formatDistance = (value, unit) => {
}
};
-export const formatSpeed = (value, unit) => {
- const t = useTranslation();
+export const formatSpeed = (value, unit, t) => {
switch (unit) {
case 'kmh':
return `${(value * 1.852).toFixed(2)} ${t('sharedKmh')}`;
@@ -64,8 +61,7 @@ export const formatSpeed = (value, unit) => {
}
};
-export const formatVolume = (value, unit) => {
- const t = useTranslation();
+export const formatVolume = (value, unit, t) => {
switch (unit) {
case 'impGal':
return `${(value / 4.546).toFixed(2)} ${t('sharedGallonAbbreviation')}`;