ernestdefoe / astrolabe
Astrolabe: show the whole forum in another calendar and in native numerals. Persian (Jalali), Hijri, Hebrew, Japanese or Buddhist dates and Persian, Arabic, Bengali or Devanagari digits on every date, relative time, count and date picker, for core and every extension, with user posts left untouched.
Package info
github.com/ernestdefoe/astrolabe
Language:TypeScript
Type:flarum-extension
pkg:composer/ernestdefoe/astrolabe
Fund package maintenance!
Requires
- php: ^8.3
- flarum/core: ^2.0
Requires (Dev)
- flarum/phpstan: ^2.0
- flarum/testing: ^2.0
- phpstan/phpstan-strict-rules: ^2.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Show your whole Flarum forum in another calendar and in native digits.
Pick a calendar and a set of digits in the admin, and every date on the forum follows: relative times ("۳ روز پیش"), post and discussion dates, tooltips, profile join dates, notification times, the post scrubber, and the dates other extensions show. Counts and other interface numbers use the chosen digits too. What members write never changes: posts, titles, names and code keep their own digits. Dates are still stored as Gregorian/UTC, so nothing else about the forum changes.
Calendars: Gregorian, Persian (Solar Hijri / Jalali), Islamic (Hijri, Umm al-Qura), Hebrew, Japanese (imperial eras), Buddhist (Thai solar). Digits: Western, Persian (۰۱۲۳), Arabic (٠١٢٣), Bengali (০১২৩), Devanagari (०१२३).
Features
-
Forum-wide, core and extensions. Astrolabe hooks the date and number formatting that core and extensions already use, so most extensions are covered without changes.

-
Date pickers in your calendar. A browser's own date picker only knows the Gregorian calendar. Astrolabe replaces every date and date-and-time field on the forum with a month grid in the chosen calendar, with keyboard support (arrows, Page Up/Down by month, Home/End, Enter, Escape) and screen-reader labels. The value it saves is the same Gregorian date the field always saved.

-
A second calendar. Optionally shows the date in a second calendar in every date's tooltip, e.g. "۷ آذر ۱۴۰۵ (November 28, 2026)".
-
Members choose their own. When allowed, each member can pick their own calendar and digits under Settings, "Dates and numbers", or keep the forum's.
-
Quiet fallback. If a visitor's browser can't show the calendar or digits, they see Gregorian dates or Western digits instead, never a mix.
-
Nothing to pay on a Gregorian forum. With the Gregorian calendar and Western digits, Astrolabe installs nothing on the page.
Installation
composer require ernestdefoe/astrolabe php flarum cache:clear
Enable Astrolabe in the admin, then choose the calendar and digits on its settings page.
Updating
composer update ernestdefoe/astrolabe php flarum cache:clear
Notes
- Astrolabe doesn't make the page right-to-left. Use an RTL extension for that; the date picker follows the page's direction.
- If Jalali Calendar is also enabled, the admin page says so. Astrolabe covers what it does, so don't run both.
- Dates written by the server (for example in emails) are only converted by extensions that use Astrolabe's
Formatter, which needs PHP's intl extension (without it, it writes Gregorian dates with Western digits).
For extension developers
Most extensions need nothing. Dates from humanTime, fullTime, dayjs and Intl/toLocale*String, numbers printed as numbers, numbers passed to translations (also through extractText), ICU plurals, and <input type="date"> / datetime-local are already covered. Some code needs a hand:
- A number you turn into text yourself (
count + ' items',"3:05",abbreviateNumber):number()fromext:ernestdefoe/astrolabe/common/apiswaps the digits and leaves separators alone. - A decimal or a grouped number (
rating.toFixed(1)):format(value, options)writes it the way the page's language does, decimal mark included (۴٫۵), and returnsnullon a page with Western digits so you keep your own:api.format(4.5, { maximumFractionDigits: 1 }) ?? (4.5).toFixed(1)(1.1+). - Optional Astrolabe: look it up when you show a number, not at load:
flarum.reg.checkModule('ernestdefoe-astrolabe', 'common/api')isfalsewithout it (no warning), and addernestdefoe/astrolabetooptional-dependencies. - A date input that must stay native: add
data-astrolabe="native". - A dayjs label that must stay Gregorian:
dayjs(x).formatGregorian('LL'). - Formatters that are never touched: machine formats (
format(),YYYY-MM-DD,HH:mm), a hard-coded other locale ('en-CA'), an explicit-u-ca-/-u-nu-, andformatToParts(). - Server side: inject
ErnestDefoe\Astrolabe\Formatterin a class you bind only insideExtend\Conditionaland calldate(),number()oryear()(1.1+, e.g. "Member since"). - Reading the choice: the forum attributes
ernestdefoe-astrolabe.calendar,ernestdefoe-astrolabe.numerals,ernestdefoe-astrolabe.secondCalendarandernestdefoe-astrolabe.memberChoice, and the member preferencesastrolabeCalendar/astrolabeNumerals(null = the forum's).
Links
License
MIT

