Translating the sample report

As of 6.4 the sample report is translatable, entirely through WeeWX’s own mechanisms — lang files, [Texts]/$gettext, and the [Almanac] section. There are no invented conventions to learn: if you have translated a WeeWX skin before, this works the same way. (Language support needs WeeWX 4.6 or later.)

German, French, Dutch and Spanish ship with the skinskins/LoopData/lang/de.conf and lang/fr.conf (both native-speaker reviewed) and lang/nl.conf and lang/es.conf (Beta awaiting their reviews) are complete translations whose shared vocabulary is copied verbatim from the lang files of weewx-skyfield and weewx-celestial, and a test keeps the three extensions in step. Select one in weewx.conf:

[StdReport]
    [[LoopDataReport]]
        lang = de

Two languages meet on the page

This is the one thing unique to a loopdata page, so it comes first: the sample report mixes two sources with independent language settings.

  1. The page’s own labels — the gauge headings, the LIVE badge, the readout lines under the dials — follow the sample report’s lang, via its lang files, as on any WeeWX skin.
  2. The live values in loop-data.txt follow the language of loopdata’s [LoopData] target report: loopdata renders every field with the target report’s formatter and texts, so .ordinal_compass fields take that report’s compass ordinates, moon_phase its moon_phases, and almanac.<body>.label / almanac.<body>.constellation.label its [Almanac] names — one language per loopdata instance, regardless of which page displays them.

Out of the box the two are the same report (target_report = LoopDataReport), so lang = de on [[LoopDataReport]] switches labels and values together, and the shipped lang files carry the value-side sections (compass ordinates, moon phases, body and all 88 constellation names, hemisphere letters) so a German target report serves German values.

If your target report is a different report (say, Seasons), a coherent German page needs both: lang = de on the sample report’s stanza and a German target report. The simplest route sets every report at once:

[StdReport]
    [[Defaults]]
        lang = de

A skin with no German lang file simply stays English — a missing language is a logged no-op, never an error.

trend.barometer.desc follows the same rule: each English description (Falling Slowly, Steady, …) is a gettext-style key into the target report’s [Texts], the shipped lang files carry all nine, and a missing key falls back to the English. (Before 6.4 these came from a [LoopData] [[BarometerTrendDescriptions]] section in weewx.conf; that section is gone and now ignored — delete it, and put any custom wording in the target report’s [[[Texts]]] instead.)

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 blanks a gauge, it just renders in English.

The live javascript composes strings too (the badge, the readout lines, the cardinal letters on the wind dial and windrose). Those are translated at generation time and fed to the script as globals through json.dumps, so translations need nothing beyond the lang file — there are no strings to edit in the javascript.

Adding a language

The reference dictionary is skins/LoopData/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]
    [[LoopDataReport]]
        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]
    "today {min} to {max}" = "heute {min} bis {max}"

Note that weectl extension install overwrites skins/LoopData/ — including its lang files — on every upgrade. A new language is durable as a pull request (welcome — a lang file is a self-contained, no-code contribution), or keep your own copy elsewhere and re-copy it after upgrades; local overrides of shipped strings survive upgrades as [[[Texts]]] entries on the report’s stanza in weewx.conf.


weewx-loopdata is Copyright © 2020–2026 John A Kline and is licensed under the GNU Public License v3.

This site uses Just the Docs, a documentation theme for Jekyll.