diff --git a/apps/readest-app/src/app/user/components/PlanCard.tsx b/apps/readest-app/src/app/user/components/PlanCard.tsx index 13a3d834..2c8ed916 100644 --- a/apps/readest-app/src/app/user/components/PlanCard.tsx +++ b/apps/readest-app/src/app/user/components/PlanCard.tsx @@ -29,9 +29,10 @@ const PlanCard: React.FC = ({ }) => { const _ = useTranslation(); const { price, currency } = plan; - const formattedPrice = new Intl.NumberFormat(getLocale(), { style: 'currency', currency }).format( - price / 100, - ); + const formattedPrice = new Intl.NumberFormat(getLocale(), { + style: 'currency', + currency, + }).format(price / 100); return (
{ }; export const getLocale = () => { - return localStorage?.getItem('i18nextLng') || navigator?.language || ''; + const locale = localStorage?.getItem('i18nextLng') || navigator?.language || ''; + // POSIX locale values (e.g. 'C', 'C.UTF-8', 'POSIX') are not valid BCP 47 + // tags and would cause Intl/toLocaleString to throw — fall back to en-US + if (!locale || /^(C|POSIX)(\..*)?$/i.test(locale)) return 'en-US'; + return locale; }; export const getUserLang = () => {