Cosmo
Locale-aware formatting for JavaScript, PHP, Python, Java & C#.
Format money, dates, numbers, units and text using your users' locale conventions. Cosmo provides a shared API in five languages and reads locale data from ICU.
Implemented in — JavaScript · PHP · Python · Java · C#
Locale support from ICU
Cosmo uses ICU and CLDR locale data. Coverage depends on your runtime and ICU version:
From the everyday — US dollars, the Gregorian calendar, New York time, Latin script — to the long tail: the Persian and Ethiopic calendars, Nepal's UTC+5:45, the Adlam and Tifinagh scripts, and Eastern-Arabic numerals (٢٠٢٠).
Zero locale data
Language names, calendars, currencies and formatting rules come from ICU. Cosmo does not maintain its own locale tables.
The same API everywhere
Shared operations across JavaScript, PHP, Python, Java and C#, with naming and parameter types suited to each language. Choose your language in the header to read the relevant examples and guidance.
Formatting and text tools
Money, dates, numbers, units, percentages, plurals, lists, ranges, collation, transliteration and parsing — all in the locale's conventions.
Runtime support
Available features depend on each language's ICU APIs. The platform notes explain which methods are supported and where behaviour differs.