Repository navigation
Conversation
PR Summary by QodoLocalize the modern speedtest page in four languages
AI Description
Diagram
High-Level Assessment
Files changed (14)
|
Code Review by Qodo
1.
|
…anish A small i18n.js loads flat JSON catalogs (frontend/locales/<language>.json) and fills the elements marked with data-i18n and data-i18n-attr. The language is the saved choice, then the browser language, then English; a selector in the footer changes it and saves the choice. The texts that index.js draws go through LibreSpeedI18n.t and are drawn again when the language changes. Scope is the modern page only. It builds on the catalog format of the localization proposed by yeager in librespeed#860, without the ?lang= parameter, the link rewriting, the catalog timeout or the sponsor markup rework. The entrypoint seds for TITLE and TAGLINE match the new markup. Co-authored-by: Daniel Nylander <1206564+yeager@users.noreply.github.com>
- Docker: leave the translated title, heading and tagline alone when TITLE and TAGLINE have their default values, which the images always set; only a custom value replaces them. - A catalog that never answers no longer hides the page: the page shows in English after 3 s and still translates if the catalog arrives later. - The latest choice of language wins when the catalogs arrive out of order. - When a change of language fails, the selector goes back to the language shown. - A key missing from a catalog falls back to the English text of the page, not to the previous language. Co-authored-by: Daniel Nylander <1206564+yeager@users.noreply.github.com>
dd2fda2 to
b3e773f
Compare
…er selector The selector used the native arrow, a light font and no spacing. It now uses the bold accent color of the footer links, the rounded border and the chevron of the server selector, and turns pink on hover like the links. Co-authored-by: Daniel Nylander <1206564+yeager@users.noreply.github.com>
Localization of the modern page (English, Swedish, Portuguese, Spanish)
Follow-up to the discussion in #863 and to the Swedish localization in #860 by @yeager. @sstidl found the localization
worth having but kept it apart from theming, and #860 bigger than the purpose needs. This is a smaller version of the
same idea, with @yeager's catalog format (flat JSON, dotted keys,
data-i18nbindings, English text kept in the HTML asthe fallback). Theming stays out of this PR.
What it does
frontend/javascript/i18n.js(about 85 lines of code) loadsfrontend/locales/<language>.jsonand fills the elements markeddata-i18n/data-i18n-attr. Scripts useLibreSpeedI18n.t(key, fallback, { name: value }).choice in
localStorage, so there is a way to pick a language without a URL parameter.index.jsdraws its own texts (start button, sponsor, "connected through", the alert, copy link) throught(), anddraws them again on the
i18nchangeevent.en,sv,pt,es, with the strings of the modern page and its privacy policy.What was left out on purpose, compared to #860
?lang=parameter and no rewriting of links (the language is the browser's or the saved choice).the dynamic texts are drawn from
t()on every frame, so a slow catalog cannot hold the test.index-modern.htmlandfrontend/index.html). The classic page and the stability page canfollow with the same files if this shape is acceptable.
<a>) instead ofinnerHTML, which was needed anyway toput a translated label in front of the link.
Docker
TITLEandTAGLINEreplace the translated title, heading and tagline by plain text, as before; thesedpatterns indocker/entrypoint.shwere updated for the newdata-i18nattributes.Tests
tests/e2e/i18n.spec.js(browser language, selector, saved choice, back to English, unsupported language, failedcatalog, alert, and that every catalog has the keys of the English one and the pages only use keys that exist). The
existing
title-special-chars,modes,design-switch,static-repository-assetsandmobile-gauge-visibilityspecs pass with the Docker setup (26 tests).