weewx-celestial

Translating the Celestial page

Home · Installation · Configuration · The Geocentric in your skin · GitHub project


As of 7.2 the page is translatable, entirely through WeeWX’s own mechanisms — lang files, [Texts]/$gettext, and the [Almanac] section — the same machinery as weewx-skyfield’s Sky page. There are no invented conventions to learn: if you have translated a WeeWX skin before, this works the same way.

How it works

Every string the page renders is a gettext-style [Texts] key: the English string is the key. A report falls back to English one string at a time, so a partial translation is fine — a missing key never breaks the page, it just renders in English.

The words come from four core-standard sources:

What Where it is translated
Page title, captions, badge states, roster value strings, the footer [Texts]
Body names (the dial labels and roster rows) [Almanac], keyed by tag name (moon = Mond), beside moon_phases
Compass cardinals on the dial rim [Units] [[Ordinates]] directions
Hemisphere letters in the header’s coordinates [Labels] hemispheres

The live-page twist: this page is not static — javascript rewrites the badge, the roster and the dial labels from loop data on every packet. Everything the javascript composes is translated once, at report-generation time, and fed to the script as data (body names, cardinals, and the [Texts] strings it needs), so the page stays in one language end to end with no translation machinery in the browser. A consequence worth knowing: changing the report’s lang takes effect on the next report cycle, when the page is regenerated — not on the next loop packet.

Times (the clock and the last-update stamp) are not in the dictionary at all: they format per the report’s lang through the browser’s own locale rules.

Translating

German, French, Danish, Dutch and Spanish ship with the skinlang/de.conf and lang/fr.conf are complete, native-speaker-reviewed translations; lang/da.conf was contributed by native speaker Gert Andersen; lang/nl.conf and lang/es.conf are complete Betas awaiting their native-speaker reviews, each kept complete by a test, so new strings cannot ship untranslated. Their shared vocabulary (body names, moon phases, hemisphere letters, compass ordinates, and all 88 constellation names) is identical to weewx-skyfield’s own lang files, and a test keeps the two extensions in step. To use one:

[StdReport]
    [[CelestialReport]]
        lang = de                # or fr, da, nl, or es

For any other language, the skin ships its reference dictionary at skins/Celestial/lang/en.conf — every string the page renders, and nothing else (a test keeps it exact in both directions). To add a language:

  1. Copy en.conf to <code>.conf in the same lang directory (e.g. fr.conf) and translate the values — the keys stay English. Translate as much or as little as you like; anything you drop falls back to English per string.
  2. Point the report at it in weewx.conf:
[StdReport]
    [[CelestialReport]]
        lang = fr

Composed strings keep their {named} placeholders — reorder them freely, but do not rename them (a broken placeholder makes that one string fall back to English). For example:

[Texts]
    "alt {alt}°" = "Höhe {alt}°"

Further languages are welcome as contributions — a lang file is a self-contained, no-code contribution.

One place for the whole station: Defaults

Anything under [StdReport] [[Defaults]] in weewx.conf is merged by WeeWX into every report:

[StdReport]
    [[Defaults]]
        lang = de                      # every skin that ships German goes German

lang = de selects each skin’s own lang/de.conf — Seasons, weewx-skyfield’s Sky page, this page and any other skin that ships German switch together. A skin with no German simply stays English: a missing lang file is a logged no-op, never an error.

[[Defaults]] (or the report’s own section) is also the durable home for local overrides: weectl extension install overwrites skins/Celestial/ — including its lang files — on every upgrade, while [[[Almanac]]]/[[[Texts]]] entries in weewx.conf survive and are merged over them.

Constellations, and loop-data values

The lang files also ship [Almanac] [[Constellations]] — all 88 constellation display names, keyed by IAU abbreviation (Psc = Fische), identical to weewx-skyfield’s. The page itself renders no constellations; the section is there because loop-data values follow the language of loopdata’s target report: weewx-loopdata 5.0+ evaluates almanac fields with the target report’s [Almanac] texts, so fields like almanac.moon.label, almanac.moon_phase or almanac.mars.constellation.label arrive already translated when this report is the target — one language per loopdata instance. (The data-carrying forms never translate: almanac.mars.constellation reports the Latin name in every language.) See weewx-skyfield’s translation manual for the tag-side details.

The dictionary

The [Texts] reference dictionary as shipped in 7.2 (skins/Celestial/lang/en.conf in the installed extension is always the authoritative copy for your version, and also carries the [Labels], [Units] and [Almanac] sections):

[Texts]

    # ── page prose (index.html.tmpl) ─────────────────────────────────────
    "The live sky over {location}." = "The live sky over {location}."
    'Celestial <span class="over">over</span> {location}' = 'Celestial <span class="over">over</span> {location}'
    "updated" = "updated"
    "The geocentric · live" = "The geocentric · live"
    "Install {skyfield} (strongly recommended, and required for Proxima Centauri) or PyEphem so the almanac can serve this panel's positions and distances." = "Install {skyfield} (strongly recommended, and required for Proxima Centauri) or PyEphem so the almanac can serve this panel's positions and distances."
    "Geocentric chart: bodies placed by compass azimuth and log distance from Earth" = "Geocentric chart: bodies placed by compass azimuth and log distance from Earth"
    "plan view  compass bearing, east to the right · rings step ×10 in distance · solid&nbsp;=&nbsp;above the horizon, dashed&nbsp;=&nbsp;below · trails show the last hour of motion" = "plan view — compass bearing, east to the right · rings step ×10 in distance · solid&nbsp;=&nbsp;above the horizon, dashed&nbsp;=&nbsp;below · trails show the last hour of motion"
    "Calculated with WeeWX's built-in almanac" = "Calculated with WeeWX's built-in almanac"
    "Calculated with the station's extended almanac (weewx-skyfield or PyEphem)" = "Calculated with the station's extended almanac (weewx-skyfield or PyEphem)"
    "Calculated with Skyfield, JPL's DE421 ephemeris and the Hipparcos star catalog (Credit: ESA)" = "Calculated with Skyfield, JPL's DE421 ephemeris and the Hipparcos star catalog (Credit: ESA)"
    "live via weewx-loopdata" = "live via weewx-loopdata"

    # ── live strings (realtime_updater.inc; the roster's first paint in
    #    index.html.tmpl uses the same keys) ────────────────────────────
    "alt {alt}°" = "alt {alt}°"
    "below horizon" = "below horizon"
    "{dist} au" = "{dist} au"
    "receding" = "receding"
    "approaching" = "approaching"
    "LIVE" = "LIVE"
    "{age}s ago" = "{age}s ago"
    "NO DATA (HTTP {status})  check loop_data_file" = "NO DATA (HTTP {status})  check loop_data_file"
    "BAD DATA  check loop_data_file" = "BAD DATA  check loop_data_file"
    "OFFLINE" = "OFFLINE"
    "CLICK-ME" = "CLICK-ME"
    "{ly} ly" = "{ly} ly"
    "Proxima" = "Proxima"