UI: Added new locale-aware and configurable number formatting (#354)

This commit is contained in:
Snarling
2023-02-11 13:18:50 -05:00
committed by GitHub
parent 1f5546b721
commit b4074328ec
1231 changed files with 4233 additions and 11958 deletions
+3 -3
View File
@@ -10,7 +10,7 @@ import { TickerHeaderFormatData } from "../data/TickerHeaderFormatData";
import { Player } from "@player";
import { Settings } from "../../Settings/Settings";
import { numeralWrapper } from "../../ui/numeralFormat";
import { formatMoney, formatPercent } from "../../ui/formatNumber";
import Typography from "@mui/material/Typography";
type IProps = {
@@ -22,7 +22,7 @@ const localesWithLongPriceFormat = ["cs", "lv", "pl", "ru"];
export function StockTickerHeaderText(props: IProps): React.ReactElement {
const stock = props.stock;
const stockPriceFormat = numeralWrapper.formatMoney(stock.price);
const stockPriceFormat = formatMoney(stock.price);
const spacesAllottedForStockPrice = localesWithLongPriceFormat.includes(Settings.Locale) ? 15 : 12;
const spacesAfterStockName = " ".repeat(
1 +
@@ -34,7 +34,7 @@ export function StockTickerHeaderText(props: IProps): React.ReactElement {
let hdrText = `${stock.name}${spacesAfterStockName}${stock.symbol} -${spacesBeforePrice}${stockPriceFormat}`;
if (Player.has4SData) {
hdrText += ` - Volatility: ${numeralWrapper.formatPercentage(stock.mv / 100)} - Price Forecast: `;
hdrText += ` - Volatility: ${formatPercent(stock.mv / 100)} - Price Forecast: `;
let plusOrMinus = stock.b; // True for "+", false for "-"
if (stock.otlkMag < 0) {
plusOrMinus = !plusOrMinus;