From 105e4ec887e249ec47db83095504012bad22df80 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 3 Sep 2021 00:21:33 -0700 Subject: More translation migrations --- modern/src/common/formatter.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'modern/src/common/formatter.js') diff --git a/modern/src/common/formatter.js b/modern/src/common/formatter.js index e937165..5db7a42 100644 --- a/modern/src/common/formatter.js +++ b/modern/src/common/formatter.js @@ -1,7 +1,10 @@ import moment from 'moment'; -import t from '../LocalizationProvider'; +import { useTranslation } from '../LocalizationProvider'; -export const formatBoolean = (value) => (value ? t('sharedYes') : t('sharedNo')); +export const formatBoolean = (value) => { + const t = useTranslation(); + return value ? t('sharedYes') : t('sharedNo'); +} export const formatNumber = (value, precision = 1) => Number(value.toFixed(precision)); @@ -36,6 +39,7 @@ export const formatPosition = (value, key) => { }; export const formatDistance = (value, unit) => { + const t = useTranslation(); switch (unit) { case 'mi': return `${(value * 0.000621371).toFixed(2)} ${t('sharedMi')}`; @@ -48,6 +52,7 @@ export const formatDistance = (value, unit) => { }; export const formatSpeed = (value, unit) => { + const t = useTranslation(); switch (unit) { case 'kmh': return `${(value * 1.852).toFixed(2)} ${t('sharedKmh')}`; @@ -60,6 +65,7 @@ export const formatSpeed = (value, unit) => { }; export const formatVolume = (value, unit) => { + const t = useTranslation(); switch (unit) { case 'impGal': return `${(value / 4.546).toFixed(2)} ${t('sharedGallonAbbreviation')}`; @@ -74,8 +80,11 @@ export const formatVolume = (value, unit) => { export const formatHours = (value) => moment.duration(value).humanize(); export const formatCoordinate = (key, value, unit) => { - let hemisphere; let degrees; let minutes; let - seconds; + let hemisphere; + let degrees; + let minutes; + let seconds; + if (key === 'latitude') { hemisphere = value >= 0 ? 'N' : 'S'; } else { -- cgit v1.2.3