Translations
Webperf Core can write its reports in several languages. The translations live in locales/, one directory per language.
Available languages
| Code | Language |
|---|---|
en |
English (default) |
sv |
Swedish |
da |
Danish |
fi |
Finnish |
is |
Icelandic |
no |
Norwegian |
gov |
A separate set for the public sector |
Pick a language at run time:
python default.py -u https://example.com -t 22 -r -L sv
or permanently in settings.json:
{ "general": { "language": "sv" } }
How the files are organised
locales/
sv/
LC_MESSAGES/
webperf-core.po # shared strings and help texts
webperf-core.mo # the compiled version
http_validator.po # a pair of files per test
...
The format is gettext. You edit the .po file; the .mo file is the compiled one the program reads.
Improving a translation
- Find the right
.pofile underlocales/<language>/LC_MESSAGES/ - Change the
msgstrline. Leavemsgidalone: it's the key - Run the validation:
python default.py --update-translations
This checks that the language files line up and updates them.
Adding a new language
- Create
locales/<code>/LC_MESSAGES/ - Copy the
.pofiles fromenas a starting point - Translate each
msgstr - Run
python default.py --update-translations - Test it:
python default.py -u https://example.com -t 22 -r -L <code>
Things to keep in mind
The placeholders must come along. {0} and {1} are replaced with values at run time. Leaving one out loses information, and swapping their order can make the result nonsense.
Line breaks matter. Many strings start with - or end with \n because they're assembled into a bullet list in the terminal.
Test names are more than help text. The TEXT_TEST_VALID_ARGUMENTS_* strings are the canonical names of the tests. Other systems read them, including this documentation and the /v1/tests endpoint on api.webperf.se. Changing one changes what a test is called everywhere.