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 silently stayed in the wrong currency.
This post collects the rules we ended up with and the short helpers behind them. The stack is React 18 + Vite with i18next, but nothing here depends on it.
Note: the calculators deal with probability and expected value. They are maths tools, not a recommendation to gamble (18+).
1. The URL decides the language, nothing else
Our first version mixed signals: browser language, a saved setting and the path. The result was German text on an English URL, which confuses people and search engines alike. The rule now is simple: the first path segment is the language, an unprefixed URL is English.
const NON_EN = ['no', 'de', 'fr', 'es', 'pt', 'fi', 'pl', 'ro', 'hu', 'cs', 'el']; export function urlLang(pathname = location.pathname) { const first = (pathname.split('/')[1] || '').toLowerCase(); return NON_EN.includes(first) ? first : 'en'; } The browser language is still used, but only once: a human who lands on an English URL is sent to the same page in their language (navigator.languages, with nb/nn mapped to no). A language picked by hand in the menu always wins, and crawlers are never redirected, so every language keeps its own indexable URL.
2. Never build a number string by hand
"5,000" is five thousand in English and five in German. We had text like amount.toFixed(2) glued to a symbol in a few places, and every one of them was wrong somewhere. All numbers now go through Intl.NumberFormat with an explicit locale per language:
const LOCALE = { en: 'en-GB', no: 'nb-NO', de: 'de-DE', fr: 'fr-FR', es: 'es-ES', pt: 'pt-PT', fi: 'fi-FI', pl: 'pl-PL', ro: 'ro-RO', hu: 'hu-HU', cs: 'cs-CZ', el: 'el-GR', }; export function formatNumber(n, lang, maxDigits = 2, minDigits = 0) { if (typeof n !== 'number' || Number.isNaN(n)) return n == null ? '' : String(n); let v = n; if (Math.abs(v) < 0.5 / 10 ** maxDigits) v = 0; // no "-0,00" const text = Math.abs(v).toLocaleString(LOCALE[lang] || 'en-GB', { minimumFractionDigits: minDigits, maximumFractionDigits: maxDigits, }); return (v < 0 && /[1-9]/.test(text) ? '-' : '') + text; } formatNumber(5000, 'de'); // "5.000" formatNumber(5000, 'fr'); // "5 000" (narrow no-break space) formatNumber(12.5, 'cs'); // "12,5" Two details that cost us time:
- Negative zero.
-0.001rounds to"-0"in some locales. The guard above turns tiny values into a clean0. - Spaces are not spaces. French and Norwegian use a narrow no-break space (U+202F), others a normal no-break space (U+00A0). Any regex that parses a formatted number back must accept both, plus
.,,and a plain space.
3. The symbol position belongs to the currency, not the language
"€40" and "40 €" are both correct, depending on where you are. "Ft 15 000" is not. We keep one small list of currencies whose symbol goes after the number, and the sign always goes in front of everything:
const POSTFIX = ['HUF', 'PLN', 'CZK', 'NOK']; function money(amount, currency, symbol, lang) { const num = formatNumber(Math.abs(amount), lang); const body = POSTFIX.includes(currency) ? `${num} ${symbol}` : `${symbol}${num}`; return (amount < 0 ? '-' : '') + body; // "-€40", "-19 200 Ft" } 4. Store one base currency, convert at display time
All example values and limits are stored once, in EUR. Each language has a default display currency (Hungarian pages show forints, Polish pages zloty, Czech koruna, Norwegian krone), and the conversion happens only when the value is rendered:
const fromEur = (v, rate) => (typeof v === 'number' ? Math.round(v * rate * 100) / 100 : v); Anything that is not a number passes through untouched. That matters more than it looks: a missing value must stay missing.
5. "Unknown" is not zero
This was our most embarrassing bug class. When a value was not published, an early version fell back to 0, and the UI proudly showed "€0". Now an unknown value is null all the way down and is rendered as a neutral "?" or a short translated notice, never as a number. We added a build check that fails when an unpublished limit or threshold is stored as 0 instead of null.
6. Free text with amounts needs the same treatment
Labels are easy because they live in translation files. Longer texts are harder: a sentence like "deposits from €20 up to €5,000" is written once per language and the amounts inside it must still follow the visitor's currency. We parse amounts with a regex that understands both symbol positions and all the separators from point 2, convert them, and format them again with the page locale. One rule saved us here: a leading zero means a decimal, never a thousands group ("0,003" is three thousandths, not three).
7. Test the formats, not just the maths
Our unit tests used to check calculate() and stop there. Most real bugs were in the last step, so our browser checks now open the calculators in a non-euro language (Hungarian or Polish) and read the visible string: correct separator, symbol on the right side, no NaN, no undefined, no stray English word. We also keep a build check that rejects English-style thousands ("2,000") inside non-English texts.
Summary
- The URL is the single source of truth for the language.
- Every number goes through
Intl.NumberFormatwith an explicit locale. - Symbol position is a property of the currency, the sign goes first.
- Store one base currency and convert on render.
- Unknown is
nulland is shown as "?", never as 0. - Test the rendered string in a non-euro language.
You can see all of this working in the calculators at casinokit.app/tools/: switch the language in the menu and watch the separators and currencies change.