mirror of
https://github.com/tobspr/shapez.io.git
synced 2024-10-27 20:34:29 +00:00
Put suffixes in base-en.yaml under the key global.suffix.
This commit is contained in:
parent
4409dbf17f
commit
2781d531a1
@ -24,7 +24,7 @@ export const BOTTOM = new Vector(0, 1);
|
|||||||
export const LEFT = new Vector(-1, 0);
|
export const LEFT = new Vector(-1, 0);
|
||||||
export const ALL_DIRECTIONS = [TOP, RIGHT, BOTTOM, LEFT];
|
export const ALL_DIRECTIONS = [TOP, RIGHT, BOTTOM, LEFT];
|
||||||
|
|
||||||
const bigNumberSuffixes = ["k", "M", "B", "T"];
|
const bigNumberSuffixTranslationKeys = ["thousands", "millions", "billions", "trillions"];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the build id
|
* Returns the build id
|
||||||
@ -436,15 +436,14 @@ export function formatBigNumber(num, divider = ".") {
|
|||||||
} else {
|
} else {
|
||||||
let leadingDigits = num;
|
let leadingDigits = num;
|
||||||
let suffix = "";
|
let suffix = "";
|
||||||
for (let suffixIndex = 0; suffixIndex < bigNumberSuffixes.length; ++suffixIndex) {
|
for (let suffixIndex = 0; suffixIndex < bigNumberSuffixTranslationKeys.length; ++suffixIndex) {
|
||||||
leadingDigits = leadingDigits / 1000;
|
leadingDigits = leadingDigits / 1000;
|
||||||
suffix = bigNumberSuffixes[suffixIndex];
|
suffix = T.global.suffix[bigNumberSuffixTranslationKeys[suffixIndex]];
|
||||||
if (leadingDigits < 1000) {
|
if (leadingDigits < 1000) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// round down to nearest 0.1
|
const leadingDigitsRounded = round1Digit(leadingDigits);
|
||||||
const leadingDigitsRounded = Math_floor(leadingDigits * 10) / 10;
|
|
||||||
const leadingDigitsNoTrailingDecimal = leadingDigitsRounded.toString().replace(".0", "");
|
const leadingDigitsNoTrailingDecimal = leadingDigitsRounded.toString().replace(".0", "");
|
||||||
return sign + leadingDigitsNoTrailingDecimal + suffix;
|
return sign + leadingDigitsNoTrailingDecimal + suffix;
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,13 @@ global:
|
|||||||
# How big numbers are rendered, e.g. "10,000"
|
# How big numbers are rendered, e.g. "10,000"
|
||||||
thousandsDivider: ","
|
thousandsDivider: ","
|
||||||
|
|
||||||
|
# The suffix for large numbers, e.g. 1.3k, 400.2M, etc.
|
||||||
|
suffix:
|
||||||
|
thousands: k
|
||||||
|
millions: M
|
||||||
|
billions: B
|
||||||
|
trillions: T
|
||||||
|
|
||||||
# Shown for infinitely big numbers
|
# Shown for infinitely big numbers
|
||||||
infinite: inf
|
infinite: inf
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user