{
  "id": 22327628,
  "title": "One calculator, 12 languages: the number-format bugs we hit (and the small helpers that fixed them)",
  "url": "https://urgent.news/2026/11/28/one-calculator-12-languages-the-number-format-bugs-we-hit-and-the",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-28T08:19:09.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/casinokit/one-calculator-12-languages-the-number-format-bugs-we-hit-and-the-small-helpers-that-fixed-them-2jnf"
  },
  "original_language": null,
  "account": "Our team maintains a collection of small calculators that operate in twelve different languages, including English, Czech, German, Greek, Spanish, Finnish, French, Hungarian, Norwegian, Polish, Portuguese, and Romanian. While translating labels was straightforward, we encountered numerous issues with numbers - separators, currency symbols, and amounts stuck in the wrong currency. This post outlines the rules we established and the small helpers that resolved these problems. The primary technology stack used is React 18 combined with Vite and i18next; however, the solutions presented here are language-independent.\n\nFirstly, the URL determines the language, nothing else. Previously, our systems mixed signals such as browser language, saved settings, and URL paths. This led to confusion with German text on English URLs, which was confusing for users and search engines alike. Now, the first path segment is the language, and an unprefixed URL defaults to English. The browser language is still considered, but only when a user lands on an English URL; their language preference is then applied (with nb/nn mapped to no). A manually selected language in the menu takes precedence, and crawlers are not redirected, ensuring each language maintains its own indexable URL.\n\nSecondly, we avoid manually constructing number strings. For instance, \"5,000\" means five thousand in English and simply five in German. To prevent errors, we now pass numbers through Intl.NumberFormat with an explicit locale per language. The LOCALE object maps each language to its corresponding locale code. For example, the formatNumber function converts the number 5000 to \"5.000\" in German and \"5 000\" in French, using the appropriate decimal separator. To handle edge cases, we set a threshold where numbers within 0.5/10^maxDigits of zero are rounded to zero, removing \"-0,00\" formatting. Additionally, negative signs are handled correctly, ensuring values like -0.001 become \"0\" rather than \"-0,00\".\n\nThirdly, the positioning of currency symbols varies by currency. For instance, \"€40\" and \"40 €\" are both valid representations depending on the locale, whereas \"Ft 15 000\" is incorrect because the \"Ft\" symbol should not follow the number. We maintain a list of currencies whose symbols are placed after the number, such as HUF, PLN, CZK, and NOK. The sign always precedes the number, whether in front of or behind the symbol, depending on the currency type.",
  "summary": "We maintain a set of small free calculators (wagering, odds, expected value, withdrawal times and a few more) that run in 12 languages: English, Czech, German, Greek, Spanish, Finnish, French, Hungarian, Norwegian, Polish, Portuguese and Romanian. Translating the labels was the easy part. The bugs that actually reached users were about numbers: separators, currency symbols, and amounts that…",
  "summary_source": "publisher",
  "key_points": [
    "URL determines language, simplifying translations",
    "Number formatting handled via Intl.NumberFormat",
    "Currency symbols placed before numbers for consistency"
  ],
  "editors_take": "Standardizing how number formats and currency symbols are displayed prevents user confusion and ensures that different languages receive the correct mathematical notation.",
  "opinion": false,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "machine_translated": false,
  "ai_generated": true,
  "disclaimer": "Accounts, briefs, key points, the editor’s take and translations are written by software from other outlets’ reporting and may contain errors. A summary whose summary_source is \"publisher\" is the outlet’s own feed text. Always check the linked original."
}