Home · Installation · Configuration · Tags in your skin · GitHub project
As of 3.0 the sample tide page is translatable, entirely through WeeWX’s
own mechanisms — lang files and [Texts]/$gettext. There are no
invented conventions to learn: if you have translated a WeeWX skin before,
this works the same way.
Nine languages ship with the skin: English, plus complete Beta translations (pending native-speaker review) for Danish, Dutch, French, German, Italian, Norwegian (Bokmål), Spanish and Swedish. Corrections are welcome as GitHub issues.
Set lang on the report’s stanza in weewx.conf:
[StdReport]
[[XTideReport]]
lang = de
For the full effect, use a complete locale name — lang = de_DE.UTF-8 —
when that locale is installed on the station. WeeWX strips the country
and encoding when it looks up the lang file (de.conf), but hands the
whole string to the system locale, which is where strftime’s month and
weekday names come from. A bare de translates every string the skin
owns; de_DE.UTF-8 also turns “Mon, Aug 3” into “Mo., 3. Aug”.
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 the
page, it just renders that one string in English.
Dates split two ways. Their order and punctuation are in the
dictionary — the strftime formats the page uses are themselves [Texts]
keys, so a language reorders them ("%b %d" = "%-d. %b" turns “Aug 03”
into “3. Aug”). The month and weekday names (%a, %b) come from
strftime, i.e. the locale, as described above.
Times follow the same principle. On a system whose locale has no AM/PM designators (most of continental Europe), the page uses 24-hour labels automatically; the shipped translations also map the 12-hour format keys to 24-hour forms, so a translated report reads 24-hour on any host. The tooltip on the graph localizes in the browser: it uses the visitor’s own locale, whatever the report language.
Two things never translate, deliberately. The station name renders as
the harmonics file spells it, and the extension’s parsing of the tide
program’s output is locale-independent — the $xtide.events() tag’s
eventType value stays High Tide/Low Tide as data (format the
display yourself, or use the sample skin, whose display strings are
translated).
Copy skins/xtide/lang/en.conf to <code>.conf, translate the
right-hand sides, and open a pull request or issue. Keep the {named}
placeholders (reorder freely, never rename), and keep values quoted. The
whole dictionary is about twenty strings — the test suite enforces that
every language file carries exactly the keys the page renders.