Generating Localised Price Tables From One JSON Source
A pricing page that exists in six languages usually ends up with six slightly different price tables. Someone updates the English plan limits, forgets the Japanese page, and now an AI assistant or a customer quotes the wrong number. The fix is to treat prices as data and render every language version from one source. One source of truth { "currency_by_locale" : { "en" : "USD" , "de" : "EUR" ,…
A single JSON file contains price data for six languages. When updating English plan limits, other language versions may become outdated. The solution is to use price data as source material and generate language-specific tables from it. The file specifies the currency for each locale, such as USD for English and JPY for Japanese, and lists plans with their respective prices and features.
Prices are set explicitly rather than being derived through conversion. Rendering the tables uses Intl data from a separate JSON file. The function takes a locale as input, retrieves the appropriate currency, formats the price using the correct number format, and generates HTML rows for each plan. It also includes the plan name, number of seats, and features.
Finally, it displays an update timestamp in the user's local date format. To ensure data integrity, the code includes a test that checks for missing prices or translations in every locale and plan, halting the build process if any discrepancies are found.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.