mirror of
https://github.com/librespeed/speedtest.git
synced 2026-11-22 16:14:56 +00:00
feat: localize the modern page in English, Swedish, Portuguese and Spanish
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 #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>
This commit is contained in:
parent
06524abd22
commit
5fc8442598
14 changed files with 647 additions and 100 deletions
|
|
@ -124,7 +124,7 @@ if [[ "$MODE" == "frontend" || "$MODE" == "dual" || "$MODE" == "standalone" ]];
|
|||
TITLE_ESCAPED=$(sed_escape "$TITLE_HTML_ESCAPED")
|
||||
sed -i "s/<title>LibreSpeed<\\/title>/<title>$TITLE_ESCAPED<\\/title>/g; s/<h1>LibreSpeed<\\/h1>/<h1>$TITLE_ESCAPED<\\/h1>/g" /var/www/html/index-classic.html
|
||||
sed -i "s/<title>LibreSpeed<\\/title>/<title>$TITLE_ESCAPED<\\/title>/g" /var/www/html/index.html
|
||||
sed -i "s/<title>LibreSpeed - Free and Open Source Speedtest<\\/title>/<title>$TITLE_ESCAPED - Free and Open Source Speedtest<\\/title>/g; s/<h1>Free and Open Source Speedtest\\.<\\/h1>/<h1>$TITLE_ESCAPED<\\/h1>/g" /var/www/html/index-modern.html
|
||||
sed -i "s/<title data-i18n=\"page.title\">LibreSpeed - Free and Open Source Speedtest<\\/title>/<title>$TITLE_ESCAPED - Free and Open Source Speedtest<\\/title>/g; s/<h1 data-i18n=\"brand.title\">Free and Open Source Speedtest\\.<\\/h1>/<h1>$TITLE_ESCAPED<\\/h1>/g" /var/www/html/index-modern.html
|
||||
fi
|
||||
|
||||
# Replace modern page tagline if TAGLINE is set
|
||||
|
|
@ -133,7 +133,7 @@ if [[ "$MODE" == "frontend" || "$MODE" == "dual" || "$MODE" == "standalone" ]];
|
|||
TAGLINE_ONE_LINE=${TAGLINE_ONE_LINE//$'\n'/ }
|
||||
TAGLINE_HTML_ESCAPED=$(html_escape "$TAGLINE_ONE_LINE")
|
||||
TAGLINE_ESCAPED=$(sed_escape "$TAGLINE_HTML_ESCAPED")
|
||||
sed -i "s/<p class=\"tagline\">No Flash, No Java, No Websockets, No Bullsh\\*t<\\/p>/<p class=\"tagline\">$TAGLINE_ESCAPED<\\/p>/g" /var/www/html/index-modern.html
|
||||
sed -i "s/<p class=\"tagline\" data-i18n=\"brand.tagline\">No Flash, No Java, No Websockets, No Bullsh\\*t<\\/p>/<p class=\"tagline\">$TAGLINE_ESCAPED<\\/p>/g" /var/www/html/index-modern.html
|
||||
fi
|
||||
|
||||
# Support legacy EMAIL env var as fallback for GDPR_EMAIL
|
||||
|
|
|
|||
|
|
@ -18,6 +18,20 @@ page fetches them relative to itself:
|
|||
- `../settings.json` overrides selected `speedtest_worker.js` settings.
|
||||
- `index.html` and `../index-modern.html` show how the frontend is wired up.
|
||||
|
||||
## Localization
|
||||
|
||||
The modern page ships with English, Swedish, Portuguese and Spanish. The language is the saved choice, then the first
|
||||
supported language of the browser, then English; the selector in the footer changes it and saves the choice in the
|
||||
browser.
|
||||
|
||||
- `javascript/i18n.js` loads `locales/<language>.json` (flat JSON, dotted keys) and fills the elements marked with
|
||||
`data-i18n="key"` (text) or `data-i18n-attr="attribute:key"` (attributes). The English text stays in the HTML as the
|
||||
fallback.
|
||||
- Texts written by `javascript/index.js` go through `LibreSpeedI18n.t(key, fallback, { name: value })`.
|
||||
- To add a language, copy `locales/en.json` to `locales/<id>.json`, translate it and add `{ id, name }` to `LANGUAGES` in
|
||||
`javascript/i18n.js`. `tests/e2e/i18n.spec.js` checks that every catalog has the same keys as the English one.
|
||||
- Setting `TITLE` or `TAGLINE` in the Docker image replaces the translated title, heading and tagline with that text.
|
||||
|
||||
## Notes
|
||||
|
||||
- The modern frontend expects modern browser features and does not support old
|
||||
|
|
|
|||
|
|
@ -8,13 +8,14 @@
|
|||
/>
|
||||
<meta
|
||||
name="description"
|
||||
content="Free and Open Source Speedtest. Run it right now in your browser, or self-host on a PHP, Golang, Rust or Node server. License: LGPL."
|
||||
content="Free and Open Source Speedtest. Run it right now in your browser, or self-host on a PHP, Golang, Rust or Node server. License: LGPL." data-i18n-attr="content:page.description"
|
||||
/>
|
||||
<link rel="shortcut icon" href="images/favicon.svg" />
|
||||
<script type="text/javascript" src="speedtest.js"></script>
|
||||
<script type="text/javascript" src="javascript/i18n.js"></script>
|
||||
<script type="text/javascript" src="javascript/index.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="styling/index.css" />
|
||||
<title>LibreSpeed - Free and Open Source Speedtest</title>
|
||||
<title data-i18n="page.title">LibreSpeed - Free and Open Source Speedtest</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
|
@ -22,30 +23,30 @@
|
|||
<img src="images/logo.svg" alt="LibreSpeed" />
|
||||
</header>
|
||||
<main>
|
||||
<h1>Free and Open Source Speedtest.</h1>
|
||||
<p class="tagline">No Flash, No Java, No Websockets, No Bullsh*t</p>
|
||||
<h1 data-i18n="brand.title">Free and Open Source Speedtest.</h1>
|
||||
<p class="tagline" data-i18n="brand.tagline">No Flash, No Java, No Websockets, No Bullsh*t</p>
|
||||
|
||||
<div class="server-selector">
|
||||
<div class="chosen">
|
||||
<div class="chevron">
|
||||
<img src="images/chevron.svg" alt="select..." />
|
||||
<img src="images/chevron.svg" alt="select..." data-i18n-attr="alt:server.select-alt" />
|
||||
</div>
|
||||
<p>current server</p>
|
||||
<h2 id="selected-server">searching nearest server...</h2>
|
||||
<p data-i18n="server.current">current server</p>
|
||||
<h2 id="selected-server" data-i18n="server.searching">searching nearest server...</h2>
|
||||
</div>
|
||||
<ul class="servers"></ul>
|
||||
<p class="sponsor" id="sponsor"> </p>
|
||||
</div>
|
||||
|
||||
<p id="privacy-warning" class="hidden">
|
||||
by clicking the start button you agree to our privacy policy<br />
|
||||
<a href="#" id="choose-privacy">or choose your privacy options</a>
|
||||
<span class="agreement" data-i18n="privacy.warning">by clicking the start button you agree to our privacy policy</span><br />
|
||||
<a href="#" id="choose-privacy" data-i18n="privacy.choose">or choose your privacy options</a>
|
||||
</p>
|
||||
<button class="disabled" id="start-button"></button>
|
||||
|
||||
<div class="gauge-layout">
|
||||
<div class="ping hidden">
|
||||
<span class="label">Ping</span>:
|
||||
<span class="label" data-i18n="metric.ping">Ping</span>:
|
||||
<span class="value" id="ping">00</span>ms
|
||||
</div>
|
||||
|
||||
|
|
@ -53,100 +54,103 @@
|
|||
<div class="progress"></div>
|
||||
<div class="speed"></div>
|
||||
<h1><span id="download-speed">00</span> Mbps</h1>
|
||||
<h2>Download</h2>
|
||||
<h2 data-i18n="metric.download">Download</h2>
|
||||
</div>
|
||||
|
||||
<div class="gauge upload" id="upload-gauge">
|
||||
<div class="progress"></div>
|
||||
<div class="speed"></div>
|
||||
<h1><span id="upload-speed">00</span> Mbps</h1>
|
||||
<h2>Upload</h2>
|
||||
<h2 data-i18n="metric.upload">Upload</h2>
|
||||
</div>
|
||||
|
||||
<div class="jitter hidden">
|
||||
<span class="label">Jitter</span>:
|
||||
<span class="label" data-i18n="metric.jitter">Jitter</span>:
|
||||
<span class="value" id="jitter">00</span>ms
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button class="small inverted hidden" id="share-results">
|
||||
<button class="small inverted hidden" id="share-results" data-i18n="share.button">
|
||||
Share results
|
||||
</button>
|
||||
</main>
|
||||
<footer>
|
||||
<p class="source">
|
||||
<a href="stability.html">stability test</a> |
|
||||
<a href="https://github.com/librespeed/speedtest">source code</a>
|
||||
<a href="stability.html" data-i18n="footer.stability">stability test</a> |
|
||||
<a href="https://github.com/librespeed/speedtest" data-i18n="footer.source">source code</a>
|
||||
</p>
|
||||
<p class="source">
|
||||
<select data-language-select aria-label="Language" data-i18n-attr="aria-label:language.label"></select>
|
||||
</p>
|
||||
</footer>
|
||||
|
||||
<dialog id="share">
|
||||
<div class="close-dialog">
|
||||
<img src="images/close-button.svg" alt="Close" />
|
||||
<img src="images/close-button.svg" alt="Close" data-i18n-attr="alt:dialog.close" />
|
||||
</div>
|
||||
<img id="results" src="" alt="Test results in graphical form" />
|
||||
<button id="copy-link">Copy link</button>
|
||||
<img id="results" src="" alt="Test results in graphical form" data-i18n-attr="alt:share.image-alt" />
|
||||
<button id="copy-link" data-i18n="share.copy">Copy link</button>
|
||||
</dialog>
|
||||
|
||||
<dialog id="privacy">
|
||||
<div class="close-dialog">
|
||||
<img src="images/close-button.svg" alt="Close" />
|
||||
<img src="images/close-button.svg" alt="Close" data-i18n-attr="alt:dialog.close" />
|
||||
</div>
|
||||
<section>
|
||||
<h1>Privacy Policy</h1>
|
||||
<p>
|
||||
<h1 data-i18n="privacy.title">Privacy Policy</h1>
|
||||
<p data-i18n="privacy.telemetry">
|
||||
This HTML5 speed test server is configured with telemetry enabled.
|
||||
</p>
|
||||
|
||||
<h2>What data we collect</h2>
|
||||
<p>
|
||||
<h2 data-i18n="privacy.collect-title">What data we collect</h2>
|
||||
<p data-i18n="privacy.collect-intro">
|
||||
At the end of the test, the following data is collected and stored:
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li>Test ID</li>
|
||||
<li>Time of testing</li>
|
||||
<li>Test results (download and upload speed, ping and jitter)</li>
|
||||
<li>IP address</li>
|
||||
<li>ISP information</li>
|
||||
<li>Approximate location (inferred from IP address, not GPS)</li>
|
||||
<li>User agent and browser locale</li>
|
||||
<li>Test log (contains no personal information)</li>
|
||||
<li data-i18n="privacy.item.test-id">Test ID</li>
|
||||
<li data-i18n="privacy.item.time">Time of testing</li>
|
||||
<li data-i18n="privacy.item.results">Test results (download and upload speed, ping and jitter)</li>
|
||||
<li data-i18n="privacy.item.ip">IP address</li>
|
||||
<li data-i18n="privacy.item.isp">ISP information</li>
|
||||
<li data-i18n="privacy.item.location">Approximate location (inferred from IP address, not GPS)</li>
|
||||
<li data-i18n="privacy.item.locale">User agent and browser locale</li>
|
||||
<li data-i18n="privacy.item.log">Test log (contains no personal information)</li>
|
||||
</ul>
|
||||
|
||||
<h2>How we use the data</h2>
|
||||
<p>Data collected through this service is used to:</p>
|
||||
<h2 data-i18n="privacy.use-title">How we use the data</h2>
|
||||
<p data-i18n="privacy.use-intro">Data collected through this service is used to:</p>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<li data-i18n="privacy.use.share">
|
||||
Allow sharing of test results (sharable image for forums, etc.)
|
||||
</li>
|
||||
<li>
|
||||
<li data-i18n="privacy.use.improve">
|
||||
To improve the service offered to you (for instance, to detect
|
||||
problems on our side)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<p>No personal information is disclosed to third parties.</p>
|
||||
<p data-i18n="privacy.no-disclosure">No personal information is disclosed to third parties.</p>
|
||||
|
||||
<h2>Your consent</h2>
|
||||
<p>
|
||||
<h2 data-i18n="privacy.consent-title">Your consent</h2>
|
||||
<p data-i18n="privacy.consent">
|
||||
By starting the test, you consent to the terms of this privacy policy.
|
||||
</p>
|
||||
|
||||
<h2>Data removal</h2>
|
||||
<p>
|
||||
<h2 data-i18n="privacy.removal-title">Data removal</h2>
|
||||
<p data-i18n="privacy.removal">
|
||||
If you want to have your information deleted, you need to provide
|
||||
either the ID of the test or your IP address. This is the only way to
|
||||
identify your data, without this information we won't be able to
|
||||
comply with your request.
|
||||
</p>
|
||||
<p>
|
||||
Contact this email address for all deletion requests:
|
||||
<span data-i18n="privacy.contact">Contact this email address for all deletion requests:</span>
|
||||
<a href="mailto:PUT@YOUR_EMAIL.HERE">TO BE FILLED BY DEVELOPER</a>.
|
||||
</p>
|
||||
</section>
|
||||
<button id="close-privacy">Close</button>
|
||||
<button id="close-privacy" data-i18n="dialog.close">Close</button>
|
||||
</dialog>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
110
frontend/javascript/i18n.js
Normal file
110
frontend/javascript/i18n.js
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
/**
|
||||
* Localization for the modern page
|
||||
*
|
||||
* Flat JSON catalogs with dotted keys in ../locales/<language>.json. The text of the page in English stays in the HTML
|
||||
* as the fallback, so a missing key or a failed request leaves the page readable.
|
||||
* data-i18n="key" sets the text of the element
|
||||
* data-i18n-attr="attribute:key,..." sets attributes of the element
|
||||
* LibreSpeedI18n.t(key, fallback, { name: value }) for the text written by scripts, with {name} placeholders
|
||||
*
|
||||
* The language is the saved choice (localStorage), then the first supported language of the browser, then English.
|
||||
* A <select data-language-select> is filled with the languages and changes the language of the open page.
|
||||
* "i18nchange" is fired on window after every change of language, for the texts that scripts draw.
|
||||
*/
|
||||
(() => {
|
||||
const DEFAULT_LANGUAGE = "en";
|
||||
const LANGUAGES = [
|
||||
{ id: "en", name: "English" },
|
||||
{ id: "sv", name: "Svenska" },
|
||||
{ id: "pt", name: "Português" },
|
||||
{ id: "es", name: "Español" }
|
||||
];
|
||||
const STORAGE_KEY = "librespeed-language";
|
||||
const localesURL = new URL("../locales/", document.currentScript.src);
|
||||
let language = DEFAULT_LANGUAGE;
|
||||
let messages = {};
|
||||
|
||||
const supported = id => LANGUAGES.some(item => item.id === id);
|
||||
const normalize = value =>
|
||||
String(value || "")
|
||||
.toLowerCase()
|
||||
.split("-")[0];
|
||||
|
||||
function initialLanguage() {
|
||||
try {
|
||||
const saved = normalize(window.localStorage.getItem(STORAGE_KEY));
|
||||
if (supported(saved)) return saved;
|
||||
} catch (error) {
|
||||
// Storage can be blocked; the browser language is used then
|
||||
}
|
||||
const browser = navigator.languages || [navigator.language];
|
||||
return browser.map(normalize).find(supported) || DEFAULT_LANGUAGE;
|
||||
}
|
||||
|
||||
function translate(key, fallback = key, parameters = {}) {
|
||||
return (messages[key] || fallback).replace(/\{(\w+)\}/g, (match, name) =>
|
||||
Object.prototype.hasOwnProperty.call(parameters, name) ? parameters[name] : match
|
||||
);
|
||||
}
|
||||
|
||||
function translateDocument() {
|
||||
document.querySelectorAll("[data-i18n]").forEach(element => {
|
||||
element.textContent = translate(element.dataset.i18n, element.textContent.trim());
|
||||
});
|
||||
document.querySelectorAll("[data-i18n-attr]").forEach(element => {
|
||||
element.dataset.i18nAttr.split(",").forEach(binding => {
|
||||
const [attribute, key] = binding.split(":");
|
||||
element.setAttribute(attribute, translate(key, element.getAttribute(attribute)));
|
||||
});
|
||||
});
|
||||
document.querySelectorAll("[data-language-select]").forEach(select => {
|
||||
select.value = language;
|
||||
});
|
||||
}
|
||||
|
||||
function set(id, save) {
|
||||
if (!supported(id)) return Promise.resolve();
|
||||
return fetch(new URL(`${id}.json`, localesURL))
|
||||
.then(response => {
|
||||
if (!response.ok) throw new Error(`Unable to load the ${id} translations`);
|
||||
return response.json();
|
||||
})
|
||||
.then(catalog => {
|
||||
language = id;
|
||||
messages = catalog;
|
||||
if (save) {
|
||||
try {
|
||||
window.localStorage.setItem(STORAGE_KEY, id);
|
||||
} catch (error) {
|
||||
// The choice then only lasts until the page is closed
|
||||
}
|
||||
}
|
||||
document.documentElement.lang = id;
|
||||
translateDocument();
|
||||
window.dispatchEvent(new Event("i18nchange"));
|
||||
})
|
||||
.catch(error => console.warn("LibreSpeed localization unavailable:", error))
|
||||
.finally(() => document.documentElement.removeAttribute("data-i18n-pending"));
|
||||
}
|
||||
|
||||
const initial = initialLanguage();
|
||||
// The page waits for a catalog other than English, so it does not flash in English first
|
||||
if (initial !== DEFAULT_LANGUAGE) document.documentElement.setAttribute("data-i18n-pending", "");
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
document.querySelectorAll("[data-language-select]").forEach(select => {
|
||||
LANGUAGES.forEach(item => select.add(new Option(item.name, item.id)));
|
||||
select.value = language;
|
||||
select.addEventListener("change", () => set(select.value, true));
|
||||
});
|
||||
if (initial !== DEFAULT_LANGUAGE) set(initial, false);
|
||||
});
|
||||
|
||||
window.LibreSpeedI18n = {
|
||||
get language() {
|
||||
return language;
|
||||
},
|
||||
set,
|
||||
t: translate
|
||||
};
|
||||
})();
|
||||
|
|
@ -11,6 +11,9 @@ const READY = 1;
|
|||
const RUNNING = 2;
|
||||
const FINISHED = 3;
|
||||
|
||||
// Text of the interface in the language of the page, see i18n.js
|
||||
const t = (key, fallback, parameters) => window.LibreSpeedI18n.t(key, fallback, parameters);
|
||||
|
||||
// Keep some global state here
|
||||
const testState = {
|
||||
state: INITIALIZING,
|
||||
|
|
@ -33,6 +36,17 @@ window.addEventListener("DOMContentLoaded", async () => {
|
|||
applyServerListJSON();
|
||||
});
|
||||
|
||||
// The texts that renderUI draws are drawn again in the new language
|
||||
window.addEventListener("i18nchange", () => {
|
||||
try {
|
||||
testState.speedtest.getSelectedServer();
|
||||
testState.selectedServerDirty = true;
|
||||
} catch (error) {
|
||||
// No server is selected yet
|
||||
}
|
||||
if (testState.testData) testState.testDataDirty = true;
|
||||
});
|
||||
|
||||
/**
|
||||
* Create a new Speedtest and hook it into the global state
|
||||
*/
|
||||
|
|
@ -127,10 +141,10 @@ async function copyLinkButtonClickHandler() {
|
|||
await navigator.clipboard.writeText(link);
|
||||
const button = document.querySelector("#copy-link");
|
||||
button.classList.add("active");
|
||||
button.textContent = "Copied!";
|
||||
button.textContent = t("share.copied", "Copied!");
|
||||
setTimeout(() => {
|
||||
button.classList.remove("active");
|
||||
button.textContent = "Copy link";
|
||||
button.textContent = t("share.copy", "Copy link");
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
|
|
@ -212,7 +226,10 @@ async function applyServerListJSON() {
|
|||
selectServer(bestServer);
|
||||
} else {
|
||||
alert(
|
||||
"Can't reach any of the speedtest servers! But you're on this page. Something weird is going on with your network."
|
||||
t(
|
||||
"error.no-servers",
|
||||
"Can't reach any of the speedtest servers! But you're on this page. Something weird is going on with your network."
|
||||
)
|
||||
);
|
||||
}
|
||||
});
|
||||
|
|
@ -333,19 +350,19 @@ function startRenderingLoop() {
|
|||
const copyLink = document.querySelector("#copy-link");
|
||||
const resultsImage = document.querySelector("#results");
|
||||
|
||||
const buttonTexts = {
|
||||
[INITIALIZING]: "Loading...",
|
||||
[READY]: "Let's start",
|
||||
[RUNNING]: "Abort",
|
||||
[FINISHED]: "Restart",
|
||||
};
|
||||
const buttonTexts = () => ({
|
||||
[INITIALIZING]: t("button.loading", "Loading..."),
|
||||
[READY]: t("button.start", "Let's start"),
|
||||
[RUNNING]: t("button.abort", "Abort"),
|
||||
[FINISHED]: t("button.restart", "Restart"),
|
||||
});
|
||||
|
||||
// Show copy link button only if navigator.clipboard is available
|
||||
copyLink.classList.toggle("hidden", !navigator.clipboard);
|
||||
|
||||
function renderUI() {
|
||||
// Make the main button reflect the current state
|
||||
startButton.textContent = buttonTexts[testState.state];
|
||||
startButton.textContent = buttonTexts()[testState.state];
|
||||
startButton.classList.toggle("disabled", testState.state === INITIALIZING);
|
||||
startButton.classList.toggle("active", testState.state === RUNNING);
|
||||
|
||||
|
|
@ -357,10 +374,14 @@ function startRenderingLoop() {
|
|||
const server = testState.speedtest.getSelectedServer();
|
||||
selectedServer.textContent = server.name;
|
||||
if (server.sponsorName) {
|
||||
sponsor.textContent = `${t("server.sponsor", "Sponsor:")} `;
|
||||
if (server.sponsorURL) {
|
||||
sponsor.innerHTML = `Sponsor: <a href="${server.sponsorURL}">${server.sponsorName}</a>`;
|
||||
const link = document.createElement("a");
|
||||
link.href = server.sponsorURL;
|
||||
link.textContent = server.sponsorName;
|
||||
sponsor.appendChild(link);
|
||||
} else {
|
||||
sponsor.textContent = `Sponsor: ${server.sponsorName}`;
|
||||
sponsor.append(server.sponsorName);
|
||||
}
|
||||
} else {
|
||||
sponsor.innerHTML = " ";
|
||||
|
|
@ -442,7 +463,7 @@ function startRenderingLoop() {
|
|||
privacyWarning.innerHTML = '';
|
||||
|
||||
const connectedThrough = document.createElement('span');
|
||||
connectedThrough.textContent = 'You are connected through:';
|
||||
connectedThrough.textContent = t("connection.through", "You are connected through:");
|
||||
|
||||
const ipAddress = document.createTextNode(testState.testData.clientIp);
|
||||
|
||||
|
|
|
|||
52
frontend/locales/en.json
Normal file
52
frontend/locales/en.json
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
{
|
||||
"page.title": "LibreSpeed - Free and Open Source Speedtest",
|
||||
"page.description": "Free and Open Source Speedtest. Run it right now in your browser, or self-host on a PHP, Golang, Rust or Node server. License: LGPL.",
|
||||
"brand.title": "Free and Open Source Speedtest.",
|
||||
"brand.tagline": "No Flash, No Java, No Websockets, No Bullsh*t",
|
||||
"server.select-alt": "select...",
|
||||
"server.current": "current server",
|
||||
"server.searching": "searching nearest server...",
|
||||
"server.sponsor": "Sponsor:",
|
||||
"privacy.warning": "by clicking the start button you agree to our privacy policy",
|
||||
"privacy.choose": "or choose your privacy options",
|
||||
"button.loading": "Loading...",
|
||||
"button.start": "Let's start",
|
||||
"button.abort": "Abort",
|
||||
"button.restart": "Restart",
|
||||
"metric.ping": "Ping",
|
||||
"metric.jitter": "Jitter",
|
||||
"metric.download": "Download",
|
||||
"metric.upload": "Upload",
|
||||
"connection.through": "You are connected through:",
|
||||
"error.no-servers": "Can't reach any of the speedtest servers! But you're on this page. Something weird is going on with your network.",
|
||||
"share.button": "Share results",
|
||||
"share.copy": "Copy link",
|
||||
"share.copied": "Copied!",
|
||||
"share.image-alt": "Test results in graphical form",
|
||||
"footer.stability": "stability test",
|
||||
"footer.source": "source code",
|
||||
"language.label": "Language",
|
||||
"dialog.close": "Close",
|
||||
"privacy.title": "Privacy Policy",
|
||||
"privacy.telemetry": "This HTML5 speed test server is configured with telemetry enabled.",
|
||||
"privacy.collect-title": "What data we collect",
|
||||
"privacy.collect-intro": "At the end of the test, the following data is collected and stored:",
|
||||
"privacy.item.test-id": "Test ID",
|
||||
"privacy.item.time": "Time of testing",
|
||||
"privacy.item.results": "Test results (download and upload speed, ping and jitter)",
|
||||
"privacy.item.ip": "IP address",
|
||||
"privacy.item.isp": "ISP information",
|
||||
"privacy.item.location": "Approximate location (inferred from IP address, not GPS)",
|
||||
"privacy.item.locale": "User agent and browser locale",
|
||||
"privacy.item.log": "Test log (contains no personal information)",
|
||||
"privacy.use-title": "How we use the data",
|
||||
"privacy.use-intro": "Data collected through this service is used to:",
|
||||
"privacy.use.share": "Allow sharing of test results (sharable image for forums, etc.)",
|
||||
"privacy.use.improve": "To improve the service offered to you (for instance, to detect problems on our side)",
|
||||
"privacy.no-disclosure": "No personal information is disclosed to third parties.",
|
||||
"privacy.consent-title": "Your consent",
|
||||
"privacy.consent": "By starting the test, you consent to the terms of this privacy policy.",
|
||||
"privacy.removal-title": "Data removal",
|
||||
"privacy.removal": "If you want to have your information deleted, you need to provide either the ID of the test or your IP address. This is the only way to identify your data, without this information we won't be able to comply with your request.",
|
||||
"privacy.contact": "Contact this email address for all deletion requests:"
|
||||
}
|
||||
52
frontend/locales/es.json
Normal file
52
frontend/locales/es.json
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
{
|
||||
"page.title": "LibreSpeed - Test de velocidad libre y de código abierto",
|
||||
"page.description": "Test de velocidad libre y de código abierto. Ejecútalo ahora en tu navegador o instálalo en tu propio servidor PHP, Golang, Rust o Node. Licencia: LGPL.",
|
||||
"brand.title": "Test de velocidad libre y de código abierto.",
|
||||
"brand.tagline": "Sin Flash, sin Java, sin Websockets, sin tonterías",
|
||||
"server.select-alt": "seleccionar...",
|
||||
"server.current": "servidor actual",
|
||||
"server.searching": "buscando el servidor más cercano...",
|
||||
"server.sponsor": "Patrocinador:",
|
||||
"privacy.warning": "al pulsar el botón de iniciar aceptas nuestra política de privacidad",
|
||||
"privacy.choose": "o elige tus opciones de privacidad",
|
||||
"button.loading": "Cargando...",
|
||||
"button.start": "Empecemos",
|
||||
"button.abort": "Abortar",
|
||||
"button.restart": "Reiniciar",
|
||||
"metric.ping": "Ping",
|
||||
"metric.jitter": "Jitter",
|
||||
"metric.download": "Descarga",
|
||||
"metric.upload": "Subida",
|
||||
"connection.through": "Estás conectado a través de:",
|
||||
"error.no-servers": "¡No se puede llegar a ningún servidor de prueba! Pero estás en esta página. Algo raro pasa con tu red.",
|
||||
"share.button": "Compartir resultados",
|
||||
"share.copy": "Copiar enlace",
|
||||
"share.copied": "¡Copiado!",
|
||||
"share.image-alt": "Resultados de la prueba en forma gráfica",
|
||||
"footer.stability": "prueba de estabilidad",
|
||||
"footer.source": "código fuente",
|
||||
"language.label": "Idioma",
|
||||
"dialog.close": "Cerrar",
|
||||
"privacy.title": "Política de Privacidad",
|
||||
"privacy.telemetry": "Este servidor de prueba de velocidad HTML5 está configurado con telemetría activada.",
|
||||
"privacy.collect-title": "Qué datos recopilamos",
|
||||
"privacy.collect-intro": "Al final de la prueba, se recopilan y almacenan los siguientes datos:",
|
||||
"privacy.item.test-id": "ID de la prueba",
|
||||
"privacy.item.time": "Hora de la prueba",
|
||||
"privacy.item.results": "Resultados de la prueba (velocidad de descarga y subida, ping y jitter)",
|
||||
"privacy.item.ip": "Dirección IP",
|
||||
"privacy.item.isp": "Información del proveedor de internet (ISP)",
|
||||
"privacy.item.location": "Ubicación aproximada (inferida a partir de la dirección IP, no es GPS)",
|
||||
"privacy.item.locale": "User agent e idioma del navegador",
|
||||
"privacy.item.log": "Registro de la prueba (no contiene información personal)",
|
||||
"privacy.use-title": "Cómo usamos los datos",
|
||||
"privacy.use-intro": "Los datos recopilados a través de este servicio se usan para:",
|
||||
"privacy.use.share": "Permitir compartir los resultados de la prueba (imagen compartible para foros, etc.)",
|
||||
"privacy.use.improve": "Mejorar el servicio que se te ofrece (por ejemplo, detectar problemas de nuestro lado)",
|
||||
"privacy.no-disclosure": "Ninguna información personal se divulga a terceros.",
|
||||
"privacy.consent-title": "Tu consentimiento",
|
||||
"privacy.consent": "Al iniciar la prueba, aceptas los términos de esta política de privacidad.",
|
||||
"privacy.removal-title": "Eliminación de datos",
|
||||
"privacy.removal": "Si quieres que se eliminen tus datos, debes indicar el ID de la prueba o tu dirección IP. Es la única forma de identificar tus datos; sin esa información no podremos atender tu solicitud.",
|
||||
"privacy.contact": "Usa este correo para todas las solicitudes de eliminación:"
|
||||
}
|
||||
52
frontend/locales/pt.json
Normal file
52
frontend/locales/pt.json
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
{
|
||||
"page.title": "LibreSpeed - Teste de velocidade livre e de código aberto",
|
||||
"page.description": "Teste de velocidade livre e de código aberto. Execute agora no navegador ou hospede você mesmo em um servidor PHP, Golang, Rust ou Node. Licença: LGPL.",
|
||||
"brand.title": "Teste de velocidade livre e de código aberto.",
|
||||
"brand.tagline": "Sem Flash, sem Java, sem Websockets, sem enrolação",
|
||||
"server.select-alt": "selecionar...",
|
||||
"server.current": "servidor atual",
|
||||
"server.searching": "procurando o servidor mais próximo...",
|
||||
"server.sponsor": "Patrocinador:",
|
||||
"privacy.warning": "ao clicar no botão de iniciar você concorda com a nossa política de privacidade",
|
||||
"privacy.choose": "ou escolha as suas opções de privacidade",
|
||||
"button.loading": "Carregando...",
|
||||
"button.start": "Vamos começar",
|
||||
"button.abort": "Abortar",
|
||||
"button.restart": "Reiniciar",
|
||||
"metric.ping": "Ping",
|
||||
"metric.jitter": "Jitter",
|
||||
"metric.download": "Download",
|
||||
"metric.upload": "Upload",
|
||||
"connection.through": "Você está conectado através de:",
|
||||
"error.no-servers": "Não foi possível alcançar nenhum dos servidores de teste! Mas você está nesta página. Algo estranho está acontecendo com a sua rede.",
|
||||
"share.button": "Compartilhar resultados",
|
||||
"share.copy": "Copiar link",
|
||||
"share.copied": "Copiado!",
|
||||
"share.image-alt": "Resultados do teste em forma gráfica",
|
||||
"footer.stability": "teste de estabilidade",
|
||||
"footer.source": "código-fonte",
|
||||
"language.label": "Idioma",
|
||||
"dialog.close": "Fechar",
|
||||
"privacy.title": "Política de Privacidade",
|
||||
"privacy.telemetry": "Este servidor de teste de velocidade HTML5 está configurado com telemetria ativada.",
|
||||
"privacy.collect-title": "Quais dados coletamos",
|
||||
"privacy.collect-intro": "Ao final do teste, os seguintes dados são coletados e armazenados:",
|
||||
"privacy.item.test-id": "ID do teste",
|
||||
"privacy.item.time": "Horário do teste",
|
||||
"privacy.item.results": "Resultados do teste (velocidade de download e upload, ping e jitter)",
|
||||
"privacy.item.ip": "Endereço IP",
|
||||
"privacy.item.isp": "Informações do provedor de internet (ISP)",
|
||||
"privacy.item.location": "Localização aproximada (inferida a partir do endereço IP, não é GPS)",
|
||||
"privacy.item.locale": "User agent e idioma do navegador",
|
||||
"privacy.item.log": "Log do teste (não contém informação pessoal)",
|
||||
"privacy.use-title": "Como usamos os dados",
|
||||
"privacy.use-intro": "Os dados coletados por este serviço são usados para:",
|
||||
"privacy.use.share": "Permitir o compartilhamento de resultados (imagem compartilhável para fóruns, etc.)",
|
||||
"privacy.use.improve": "Melhorar o serviço oferecido a você (por exemplo, detectar problemas do nosso lado)",
|
||||
"privacy.no-disclosure": "Nenhuma informação pessoal é divulgada a terceiros.",
|
||||
"privacy.consent-title": "Seu consentimento",
|
||||
"privacy.consent": "Ao iniciar o teste, você concorda com os termos desta política de privacidade.",
|
||||
"privacy.removal-title": "Remoção de dados",
|
||||
"privacy.removal": "Se quiser que suas informações sejam removidas, forneça o ID do teste ou seu endereço IP. Essa é a única forma de identificar seus dados; sem essa informação não é possível atender ao pedido.",
|
||||
"privacy.contact": "Use este e-mail para todos os pedidos de remoção:"
|
||||
}
|
||||
52
frontend/locales/sv.json
Normal file
52
frontend/locales/sv.json
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
{
|
||||
"page.title": "LibreSpeed - Gratis hastighetstest med öppen källkod",
|
||||
"page.description": "Gratis hastighetstest med öppen källkod. Kör det direkt i webbläsaren eller drifta det själv på en PHP-, Golang-, Rust- eller Node-server. Licens: LGPL.",
|
||||
"brand.title": "Gratis hastighetstest med öppen källkod.",
|
||||
"brand.tagline": "Ingen Flash, ingen Java, inga Websockets, inget trams",
|
||||
"server.select-alt": "välj...",
|
||||
"server.current": "aktuell server",
|
||||
"server.searching": "söker efter närmaste server...",
|
||||
"server.sponsor": "Sponsor:",
|
||||
"privacy.warning": "genom att klicka på startknappen godkänner du vår integritetspolicy",
|
||||
"privacy.choose": "eller välj dina integritetsalternativ",
|
||||
"button.loading": "Laddar...",
|
||||
"button.start": "Låt oss börja",
|
||||
"button.abort": "Avbryt",
|
||||
"button.restart": "Starta om",
|
||||
"metric.ping": "Ping",
|
||||
"metric.jitter": "Jitter",
|
||||
"metric.download": "Hämtning",
|
||||
"metric.upload": "Sändning",
|
||||
"connection.through": "Du är ansluten via:",
|
||||
"error.no-servers": "Det går inte att nå någon av hastighetstestets servrar! Men du är på den här sidan. Något konstigt är på gång med ditt nätverk.",
|
||||
"share.button": "Dela resultat",
|
||||
"share.copy": "Kopiera länk",
|
||||
"share.copied": "Kopierat!",
|
||||
"share.image-alt": "Testresultat i grafisk form",
|
||||
"footer.stability": "stabilitetstest",
|
||||
"footer.source": "källkod",
|
||||
"language.label": "Språk",
|
||||
"dialog.close": "Stäng",
|
||||
"privacy.title": "Integritetspolicy",
|
||||
"privacy.telemetry": "Den här HTML5-hastighetstestservern är konfigurerad med telemetri aktiverad.",
|
||||
"privacy.collect-title": "Vilka data vi samlar in",
|
||||
"privacy.collect-intro": "När testet är klart samlas följande data in och lagras:",
|
||||
"privacy.item.test-id": "Test-id",
|
||||
"privacy.item.time": "Tidpunkt för testet",
|
||||
"privacy.item.results": "Testresultat (hämtnings- och sändningshastighet, ping och jitter)",
|
||||
"privacy.item.ip": "IP-adress",
|
||||
"privacy.item.isp": "Information om internetleverantör",
|
||||
"privacy.item.location": "Ungefärlig plats (härledd från IP-adress, inte GPS)",
|
||||
"privacy.item.locale": "Webbläsaragent och språkinställning",
|
||||
"privacy.item.log": "Testlogg (innehåller inga personuppgifter)",
|
||||
"privacy.use-title": "Så använder vi data",
|
||||
"privacy.use-intro": "Data som samlas in via tjänsten används för att:",
|
||||
"privacy.use.share": "möjliggöra delning av testresultat (delbar bild för forum med mera)",
|
||||
"privacy.use.improve": "förbättra tjänsten vi erbjuder dig (till exempel för att upptäcka problem hos oss)",
|
||||
"privacy.no-disclosure": "Inga personuppgifter lämnas ut till tredje part.",
|
||||
"privacy.consent-title": "Ditt samtycke",
|
||||
"privacy.consent": "Genom att starta testet samtycker du till villkoren i den här integritetspolicyn.",
|
||||
"privacy.removal-title": "Radering av data",
|
||||
"privacy.removal": "Om du vill få dina uppgifter raderade behöver du ange antingen testets id eller din IP-adress. Det är det enda sättet att identifiera dina uppgifter; utan den informationen kan vi inte uppfylla din begäran.",
|
||||
"privacy.contact": "Kontakta den här e-postadressen för alla begäranden om radering:"
|
||||
}
|
||||
|
|
@ -79,7 +79,28 @@ footer {
|
|||
}
|
||||
}
|
||||
|
||||
& > p.source select {
|
||||
padding: 0.4rem 0.8rem;
|
||||
font: inherit;
|
||||
font-size: 1.6rem;
|
||||
color: var(--secondary-text-color);
|
||||
background: var(--server-selector-background-color);
|
||||
border: 1px solid var(--server-selector-border-color);
|
||||
border-radius: 0.4rem;
|
||||
|
||||
&:hover,
|
||||
&:focus-visible {
|
||||
border-color: var(--server-selector-hover-border-color);
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 800px) {
|
||||
padding: 4rem;
|
||||
}
|
||||
}
|
||||
|
||||
/* Keep the page hidden while a translation other than English loads, so it does not flash in English */
|
||||
|
||||
html[data-i18n-pending] body {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,10 @@ main {
|
|||
font-weight: 700;
|
||||
color: var(--theme-green);
|
||||
}
|
||||
& > span.agreement {
|
||||
font-weight: inherit;
|
||||
color: inherit;
|
||||
}
|
||||
&.hidden {
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
|
||||
<meta name="description"
|
||||
content="Free and Open Source Speedtest. Run it right now in your browser, or self-host on a PHP, Golang, Rust or Node server. License: LGPL." />
|
||||
content="Free and Open Source Speedtest. Run it right now in your browser, or self-host on a PHP, Golang, Rust or Node server. License: LGPL." data-i18n-attr="content:page.description" />
|
||||
<link rel="shortcut icon" href="frontend/images/favicon.svg" />
|
||||
<link rel="manifest" href="manifest.webmanifest" />
|
||||
<link rel="apple-touch-icon" href="images/icon-192.png" />
|
||||
|
|
@ -15,9 +15,10 @@
|
|||
// Set this to a different URL to load the server list from another location.
|
||||
var SPEEDTEST_SERVERS = "server-list.json";
|
||||
</script>
|
||||
<script type="text/javascript" src="frontend/javascript/i18n.js"></script>
|
||||
<script type="text/javascript" src="frontend/javascript/index.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="frontend/styling/index.css" />
|
||||
<title>LibreSpeed - Free and Open Source Speedtest</title>
|
||||
<title data-i18n="page.title">LibreSpeed - Free and Open Source Speedtest</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
|
@ -25,30 +26,30 @@
|
|||
<img src="frontend/images/logo.svg" alt="LibreSpeed" />
|
||||
</header>
|
||||
<main>
|
||||
<h1>Free and Open Source Speedtest.</h1>
|
||||
<p class="tagline">No Flash, No Java, No Websockets, No Bullsh*t</p>
|
||||
<h1 data-i18n="brand.title">Free and Open Source Speedtest.</h1>
|
||||
<p class="tagline" data-i18n="brand.tagline">No Flash, No Java, No Websockets, No Bullsh*t</p>
|
||||
|
||||
<div class="server-selector">
|
||||
<div class="chosen">
|
||||
<div class="chevron">
|
||||
<img src="frontend/images/chevron.svg" alt="select..." />
|
||||
<img src="frontend/images/chevron.svg" alt="select..." data-i18n-attr="alt:server.select-alt" />
|
||||
</div>
|
||||
<p>current server</p>
|
||||
<h2 id="selected-server">searching nearest server...</h2>
|
||||
<p data-i18n="server.current">current server</p>
|
||||
<h2 id="selected-server" data-i18n="server.searching">searching nearest server...</h2>
|
||||
</div>
|
||||
<ul class="servers"></ul>
|
||||
<p class="sponsor" id="sponsor"> </p>
|
||||
</div>
|
||||
|
||||
<p id="privacy-warning" class="hidden">
|
||||
by clicking the start button you agree to our privacy policy<br />
|
||||
<a href="#" id="choose-privacy">or choose your privacy options</a>
|
||||
<span class="agreement" data-i18n="privacy.warning">by clicking the start button you agree to our privacy policy</span><br />
|
||||
<a href="#" id="choose-privacy" data-i18n="privacy.choose">or choose your privacy options</a>
|
||||
</p>
|
||||
<button class="disabled" id="start-button"></button>
|
||||
|
||||
<div class="gauge-layout">
|
||||
<div class="ping hidden">
|
||||
<span class="label">Ping</span>:
|
||||
<span class="label" data-i18n="metric.ping">Ping</span>:
|
||||
<span class="value" id="ping">00</span>ms
|
||||
</div>
|
||||
|
||||
|
|
@ -56,99 +57,102 @@
|
|||
<div class="progress"></div>
|
||||
<div class="speed"></div>
|
||||
<h1><span id="download-speed">00</span> Mbps</h1>
|
||||
<h2>Download</h2>
|
||||
<h2 data-i18n="metric.download">Download</h2>
|
||||
</div>
|
||||
|
||||
<div class="gauge upload" id="upload-gauge">
|
||||
<div class="progress"></div>
|
||||
<div class="speed"></div>
|
||||
<h1><span id="upload-speed">00</span> Mbps</h1>
|
||||
<h2>Upload</h2>
|
||||
<h2 data-i18n="metric.upload">Upload</h2>
|
||||
</div>
|
||||
|
||||
<div class="jitter hidden">
|
||||
<span class="label">Jitter</span>:
|
||||
<span class="label" data-i18n="metric.jitter">Jitter</span>:
|
||||
<span class="value" id="jitter">00</span>ms
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button class="small inverted hidden" id="share-results">
|
||||
<button class="small inverted hidden" id="share-results" data-i18n="share.button">
|
||||
Share results
|
||||
</button>
|
||||
</main>
|
||||
<footer>
|
||||
<p class="source">
|
||||
<a href="stability.html">stability test</a> | <a href="https://github.com/librespeed/speedtest">source code</a>
|
||||
<a href="stability.html" data-i18n="footer.stability">stability test</a> | <a href="https://github.com/librespeed/speedtest" data-i18n="footer.source">source code</a>
|
||||
</p>
|
||||
<p class="source">
|
||||
<select data-language-select aria-label="Language" data-i18n-attr="aria-label:language.label"></select>
|
||||
</p>
|
||||
</footer>
|
||||
|
||||
<dialog id="share">
|
||||
<div class="close-dialog">
|
||||
<img src="frontend/images/close-button.svg" alt="Close" />
|
||||
<img src="frontend/images/close-button.svg" alt="Close" data-i18n-attr="alt:dialog.close" />
|
||||
</div>
|
||||
<img id="results" src="" alt="Test results in graphical form" />
|
||||
<button id="copy-link">Copy link</button>
|
||||
<img id="results" src="" alt="Test results in graphical form" data-i18n-attr="alt:share.image-alt" />
|
||||
<button id="copy-link" data-i18n="share.copy">Copy link</button>
|
||||
</dialog>
|
||||
|
||||
<dialog id="privacy">
|
||||
<div class="close-dialog">
|
||||
<img src="frontend/images/close-button.svg" alt="Close" />
|
||||
<img src="frontend/images/close-button.svg" alt="Close" data-i18n-attr="alt:dialog.close" />
|
||||
</div>
|
||||
<section>
|
||||
<h1>Privacy Policy</h1>
|
||||
<p>
|
||||
<h1 data-i18n="privacy.title">Privacy Policy</h1>
|
||||
<p data-i18n="privacy.telemetry">
|
||||
This HTML5 speed test server is configured with telemetry enabled.
|
||||
</p>
|
||||
|
||||
<h2>What data we collect</h2>
|
||||
<p>
|
||||
<h2 data-i18n="privacy.collect-title">What data we collect</h2>
|
||||
<p data-i18n="privacy.collect-intro">
|
||||
At the end of the test, the following data is collected and stored:
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li>Test ID</li>
|
||||
<li>Time of testing</li>
|
||||
<li>Test results (download and upload speed, ping and jitter)</li>
|
||||
<li>IP address</li>
|
||||
<li>ISP information</li>
|
||||
<li>Approximate location (inferred from IP address, not GPS)</li>
|
||||
<li>User agent and browser locale</li>
|
||||
<li>Test log (contains no personal information)</li>
|
||||
<li data-i18n="privacy.item.test-id">Test ID</li>
|
||||
<li data-i18n="privacy.item.time">Time of testing</li>
|
||||
<li data-i18n="privacy.item.results">Test results (download and upload speed, ping and jitter)</li>
|
||||
<li data-i18n="privacy.item.ip">IP address</li>
|
||||
<li data-i18n="privacy.item.isp">ISP information</li>
|
||||
<li data-i18n="privacy.item.location">Approximate location (inferred from IP address, not GPS)</li>
|
||||
<li data-i18n="privacy.item.locale">User agent and browser locale</li>
|
||||
<li data-i18n="privacy.item.log">Test log (contains no personal information)</li>
|
||||
</ul>
|
||||
|
||||
<h2>How we use the data</h2>
|
||||
<p>Data collected through this service is used to:</p>
|
||||
<h2 data-i18n="privacy.use-title">How we use the data</h2>
|
||||
<p data-i18n="privacy.use-intro">Data collected through this service is used to:</p>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<li data-i18n="privacy.use.share">
|
||||
Allow sharing of test results (sharable image for forums, etc.)
|
||||
</li>
|
||||
<li>
|
||||
<li data-i18n="privacy.use.improve">
|
||||
To improve the service offered to you (for instance, to detect
|
||||
problems on our side)
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<p>No personal information is disclosed to third parties.</p>
|
||||
<p data-i18n="privacy.no-disclosure">No personal information is disclosed to third parties.</p>
|
||||
|
||||
<h2>Your consent</h2>
|
||||
<p>
|
||||
<h2 data-i18n="privacy.consent-title">Your consent</h2>
|
||||
<p data-i18n="privacy.consent">
|
||||
By starting the test, you consent to the terms of this privacy policy.
|
||||
</p>
|
||||
|
||||
<h2>Data removal</h2>
|
||||
<p>
|
||||
<h2 data-i18n="privacy.removal-title">Data removal</h2>
|
||||
<p data-i18n="privacy.removal">
|
||||
If you want to have your information deleted, you need to provide
|
||||
either the ID of the test or your IP address. This is the only way to
|
||||
identify your data, without this information we won't be able to
|
||||
comply with your request.
|
||||
</p>
|
||||
<p>
|
||||
Contact this email address for all deletion requests:
|
||||
<span data-i18n="privacy.contact">Contact this email address for all deletion requests:</span>
|
||||
<a href="mailto:PUT@YOUR_EMAIL.HERE">TO BE FILLED BY DEVELOPER</a>.
|
||||
</p>
|
||||
</section>
|
||||
<button id="close-privacy">Close</button>
|
||||
<button id="close-privacy" data-i18n="dialog.close">Close</button>
|
||||
</dialog>
|
||||
</body>
|
||||
|
||||
|
|
|
|||
156
tests/e2e/i18n.spec.js
Normal file
156
tests/e2e/i18n.spec.js
Normal file
|
|
@ -0,0 +1,156 @@
|
|||
const fs = require("node:fs");
|
||||
const path = require("node:path");
|
||||
const { test, expect } = require("@playwright/test");
|
||||
|
||||
const staticRepositoryUrl = "http://127.0.0.1:18184";
|
||||
const pageUrl = `${staticRepositoryUrl}/index-modern.html`;
|
||||
const languages = ["en", "sv", "pt", "es"];
|
||||
const root = path.resolve(__dirname, "../..");
|
||||
|
||||
const singleServerList = [
|
||||
{
|
||||
name: "Test server",
|
||||
server: "//127.0.0.1:18184/",
|
||||
dlURL: "garbage.php",
|
||||
ulURL: "empty.php",
|
||||
pingURL: "empty.php",
|
||||
getIpURL: "getIP.php",
|
||||
sponsorName: "Test sponsor",
|
||||
sponsorURL: "https://example.com/"
|
||||
}
|
||||
];
|
||||
|
||||
// A single server is shown without reachability checks, so the page reaches the READY state offline
|
||||
async function openPage(page) {
|
||||
await page.route("**/server-list.json", route => route.fulfill({ json: singleServerList }));
|
||||
await page.goto(pageUrl);
|
||||
await expect(page.locator("#start-button")).not.toHaveText("Loading...");
|
||||
}
|
||||
|
||||
test.describe("Localization of the modern page", () => {
|
||||
test.describe("English browser", () => {
|
||||
test.use({ locale: "en-US" });
|
||||
|
||||
test("shows the English text of the page and lists the four languages", async ({ page }) => {
|
||||
await openPage(page);
|
||||
await expect(page.locator("main > h1")).toHaveText("Free and Open Source Speedtest.");
|
||||
await expect(page.locator("#start-button")).toHaveText("Let's start");
|
||||
await expect(page.locator("html")).toHaveAttribute("lang", "en");
|
||||
await expect(page.locator("[data-language-select] option")).toHaveText([
|
||||
"English",
|
||||
"Svenska",
|
||||
"Português",
|
||||
"Español"
|
||||
]);
|
||||
});
|
||||
|
||||
test("changes language from the selector, keeps it after a reload and goes back to English", async ({ page }) => {
|
||||
await openPage(page);
|
||||
const select = page.locator("[data-language-select]");
|
||||
|
||||
await select.selectOption("pt");
|
||||
await expect(page.locator("main > h1")).toHaveText("Teste de velocidade livre e de código aberto.");
|
||||
await expect(page.locator("html")).toHaveAttribute("lang", "pt");
|
||||
await expect(page).toHaveTitle(/código aberto/);
|
||||
await expect(page.locator("#start-button")).toHaveText("Vamos começar");
|
||||
await expect(page.locator("#sponsor")).toHaveText("Patrocinador: Test sponsor");
|
||||
await expect(page.locator("#sponsor a")).toHaveAttribute("href", "https://example.com/");
|
||||
await expect(page.locator("#selected-server")).toHaveText("Test server");
|
||||
|
||||
await page.reload();
|
||||
await expect(page.locator("main > h1")).toHaveText("Teste de velocidade livre e de código aberto.");
|
||||
await expect(select).toHaveValue("pt");
|
||||
|
||||
await select.selectOption("en");
|
||||
await expect(page.locator("main > h1")).toHaveText("Free and Open Source Speedtest.");
|
||||
await expect(page.locator("#start-button")).toHaveText("Let's start");
|
||||
await expect(page.locator("#sponsor")).toHaveText("Sponsor: Test sponsor");
|
||||
});
|
||||
|
||||
test("translates the privacy policy, the alt texts and the label of the selector", async ({ page }) => {
|
||||
await openPage(page);
|
||||
await page.locator("[data-language-select]").selectOption("es");
|
||||
await expect(page.locator("#privacy h1")).toHaveText("Política de Privacidad");
|
||||
await expect(page.locator("#close-privacy")).toHaveText("Cerrar");
|
||||
await expect(page.locator("#privacy a[href^='mailto:']")).toHaveText("TO BE FILLED BY DEVELOPER");
|
||||
await expect(page.locator("#share .close-dialog img")).toHaveAttribute("alt", "Cerrar");
|
||||
await expect(page.locator("[data-language-select]")).toHaveAttribute("aria-label", "Idioma");
|
||||
});
|
||||
|
||||
test("keeps the page in English when the translation cannot be loaded", async ({ page }) => {
|
||||
await page.route("**/frontend/locales/sv.json", route => route.abort());
|
||||
await openPage(page);
|
||||
await page.locator("[data-language-select]").selectOption("sv");
|
||||
await expect(page.locator("main > h1")).toHaveText("Free and Open Source Speedtest.");
|
||||
await expect(page.locator("#start-button")).toHaveText("Let's start");
|
||||
});
|
||||
});
|
||||
|
||||
test.describe("Swedish browser", () => {
|
||||
test.use({ locale: "sv-SE" });
|
||||
|
||||
test("uses the language of the browser, without a flash of English", async ({ page }) => {
|
||||
await openPage(page);
|
||||
await expect(page.locator("main > h1")).toHaveText("Gratis hastighetstest med öppen källkod.");
|
||||
await expect(page.locator("html")).toHaveAttribute("lang", "sv");
|
||||
await expect(page.locator("html")).not.toHaveAttribute("data-i18n-pending", "");
|
||||
await expect(page.locator("#start-button")).toHaveText("Låt oss börja");
|
||||
await expect(page.locator("[data-language-select]")).toHaveValue("sv");
|
||||
});
|
||||
|
||||
test("translates the alert when no server can be reached", async ({ page }) => {
|
||||
const dialogs = [];
|
||||
page.on("dialog", dialog => {
|
||||
dialogs.push(dialog.message());
|
||||
dialog.dismiss();
|
||||
});
|
||||
// Two servers that cannot be reached
|
||||
await page.route("**/server-list.json", route =>
|
||||
route.fulfill({ json: [singleServerList[0], { ...singleServerList[0], name: "Other server" }] })
|
||||
);
|
||||
// The servers fail only once the Swedish catalog is in, as they would after the seconds a real ping takes
|
||||
await page.route("**/empty.php*", async route => {
|
||||
await page.waitForFunction(() => document.documentElement.lang === "sv");
|
||||
await route.abort();
|
||||
});
|
||||
await page.goto(pageUrl);
|
||||
await expect.poll(() => dialogs.length).toBeGreaterThan(0);
|
||||
expect(dialogs[0]).toContain("Det går inte att nå någon av hastighetstestets servrar");
|
||||
});
|
||||
});
|
||||
|
||||
test.describe("Browser in a language without a catalog", () => {
|
||||
test.use({ locale: "de-DE" });
|
||||
|
||||
test("falls back to English", async ({ page }) => {
|
||||
await openPage(page);
|
||||
await expect(page.locator("main > h1")).toHaveText("Free and Open Source Speedtest.");
|
||||
await expect(page.locator("html")).toHaveAttribute("lang", "en");
|
||||
await expect(page.locator("[data-language-select]")).toHaveValue("en");
|
||||
});
|
||||
});
|
||||
|
||||
test("every catalog has the keys of the English one, and the pages only use keys that exist", () => {
|
||||
const catalog = id => JSON.parse(fs.readFileSync(path.join(root, `frontend/locales/${id}.json`), "utf8"));
|
||||
const english = Object.keys(catalog("en"));
|
||||
|
||||
for (const id of languages) {
|
||||
expect(Object.keys(catalog(id)), `${id}.json`).toEqual(english);
|
||||
}
|
||||
|
||||
const sources = ["index-modern.html", "frontend/index.html", "frontend/javascript/index.js"]
|
||||
.map(file => fs.readFileSync(path.join(root, file), "utf8"))
|
||||
.join("\n");
|
||||
const used = [
|
||||
...[...sources.matchAll(/data-i18n="([^"]+)"/g)].map(match => match[1]),
|
||||
...[...sources.matchAll(/data-i18n-attr="([^"]+)"/g)].flatMap(match =>
|
||||
match[1].split(",").map(binding => binding.split(":")[1])
|
||||
),
|
||||
...[...sources.matchAll(/\bt\(\s*"([\w.-]+)"/g)].map(match => match[1])
|
||||
];
|
||||
expect(used.length).toBeGreaterThan(40);
|
||||
for (const key of used) {
|
||||
expect(english, key).toContain(key);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
@ -8,6 +8,11 @@ const expectedAssets = [
|
|||
"/server-list.json",
|
||||
"/frontend/styling/index.css",
|
||||
"/frontend/javascript/index.js",
|
||||
"/frontend/javascript/i18n.js",
|
||||
"/frontend/locales/en.json",
|
||||
"/frontend/locales/sv.json",
|
||||
"/frontend/locales/pt.json",
|
||||
"/frontend/locales/es.json",
|
||||
"/frontend/images/logo.svg",
|
||||
"/frontend/images/favicon.svg",
|
||||
"/frontend/images/close-button.svg",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue