feat(i18n): add batch group switch text to English, Nepali, and Chinese locales
- Updated the English, Nepali, and Chinese locale files to include a new translation for "Toggle batch switch for {{group}}".
- Enhanced internationalization support for the admin interface by adding relevant strings for improved user experience.
This commit is contained in:
@@ -33,3 +33,37 @@ export function formatAdminMinorUnits(
|
||||
maximumFractionDigits: resolvedDecimalPlaces,
|
||||
})}`;
|
||||
}
|
||||
|
||||
export function formatAdminMinorDecimal(
|
||||
minor: number,
|
||||
currencyCode = "NPR",
|
||||
decimalPlaces?: number,
|
||||
): string {
|
||||
const resolvedDecimalPlaces =
|
||||
typeof decimalPlaces === "number" && Number.isFinite(decimalPlaces) && decimalPlaces >= 0
|
||||
? decimalPlaces
|
||||
: getAdminCurrencyDecimalPlaces(currencyCode);
|
||||
const major = minor / 10 ** resolvedDecimalPlaces;
|
||||
return major.toLocaleString(undefined, {
|
||||
minimumFractionDigits: resolvedDecimalPlaces,
|
||||
maximumFractionDigits: resolvedDecimalPlaces,
|
||||
});
|
||||
}
|
||||
|
||||
export function parseAdminMajorToMinor(
|
||||
raw: string,
|
||||
currencyCode = "NPR",
|
||||
decimalPlaces?: number,
|
||||
): number | null {
|
||||
const resolvedDecimalPlaces =
|
||||
typeof decimalPlaces === "number" && Number.isFinite(decimalPlaces) && decimalPlaces >= 0
|
||||
? decimalPlaces
|
||||
: getAdminCurrencyDecimalPlaces(currencyCode);
|
||||
const cleaned = raw.replace(/,/g, "").trim();
|
||||
if (!cleaned) return null;
|
||||
const n = Number(cleaned);
|
||||
if (!Number.isFinite(n) || n < 0) return null;
|
||||
const factor = 10 ** resolvedDecimalPlaces;
|
||||
const minor = Math.round(n * factor);
|
||||
return Number.isSafeInteger(minor) ? minor : null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user