Search by

ernestdefoe / astrolabe

ernestdefoe

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

Forum

Language:TypeScript

Type:flarum-extension

pkg:composer/ernestdefoe/astrolabe

Fund package maintenance!

Buy Me A Coffee

Statistics

Installs: 8

Dependents: 0

Suggesters: 4

Stars: 0

Open Issues: 0

1.1.0 2026-11-30 20:58 UTC

This package is auto-updated.

Last update: 2026-12-01 13:37:25 UTC


README

Floxum code review

Show your whole Flarum forum in another calendar and in native digits.

The discussion list in the Persian calendar with Persian 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. A post's date in the Persian calendar, with the Gregorian date beside it; the post itself keeps its own digits

  • 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. The date picker in another extension's form

  • 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.

Astrolabe's settings

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() from ext:ernestdefoe/astrolabe/common/api swaps 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 returns null on 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') is false without it (no warning), and add ernestdefoe/astrolabe to optional-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-, and formatToParts().
  • Server side: inject ErnestDefoe\Astrolabe\Formatter in a class you bind only inside Extend\Conditional and call date(), number() or year() (1.1+, e.g. "Member since").
  • Reading the choice: the forum attributes ernestdefoe-astrolabe.calendar, ernestdefoe-astrolabe.numerals, ernestdefoe-astrolabe.secondCalendar and ernestdefoe-astrolabe.memberChoice, and the member preferences astrolabeCalendar / astrolabeNumerals (null = the forum's).

Links

License

MIT