0.4.0: interfaccia in italiano e inglese, scelta nelle impostazioni

L'inglese è la lingua sorgente delle stringhe; l'italiano sta nel catalogo
translations/harbour-aira-it.ts (99 stringhe), che lupdate aggiorna e lrelease
compila in build. Di serie la lingua del sistema, con ripiego sull'inglese.

- nuova classe Translator: risolve la lingua prima di createView e allinea
  QLocale::setDefault, così anche i numeri seguono la lingua (23,0 °C in
  italiano, 23.0 °C in inglese) — le temperature passano da formatValue, non
  più dal toFixed() di JavaScript che metteva sempre il punto
- Qt 5.6 non ha QQmlEngine::retranslate(): al cambio di lingua la radice QML
  viene ricaricata (setSource ricrea il componente anche a url invariata)
- le etichette di stato in airajson.cpp usano QCoreApplication::translate per
  esteso: lupdate non riconosce una funzione wrapper e le avrebbe perse
- selettore della lingua in Impostazioni (Sistema / English / Italiano)
- test: 41/41, carica il .qm vero come fa main.cpp e verifica entrambe le
  lingue, il ripiego e i formati numerici
- anteprime bilingui (docs/anteprima/ inglese, it/ italiano), README e PIANO
  aggiornati, spec RPM con i cataloghi in %files
This commit is contained in:
Carlo
2026-10-10 08:19:20 +02:00
parent e0dcf1f830
commit fddd21e16a
29 changed files with 1230 additions and 190 deletions
+51 -9
View File
@@ -21,7 +21,7 @@ Page {
function testAndReport() {
save()
page.testResult = qsTr("verifico…")
page.testResult = qsTr("checking…")
api.testConnection()
}
@@ -47,13 +47,55 @@ Page {
width: parent.width
spacing: Theme.paddingMedium
PageHeader { title: qsTr("Impostazioni") }
PageHeader { title: qsTr("Settings") }
// ---- lingua ---------------------------------------------------- //
SectionHeader { text: qsTr("Language") }
// Le voci si scelgono dal menu: il valore mostrato segue la scelta
// salvata (translator.language), non l'ultimo tocco.
ComboBox {
id: langBox
x: Theme.horizontalPageMargin
width: parent.width - 2 * Theme.horizontalPageMargin
label: qsTr("Language")
value: translator.language === "it" ? "Italiano"
: translator.language === "en" ? "English"
: qsTr("System")
menu: ContextMenu {
MenuItem {
text: qsTr("System")
onClicked: translator.language = ""
}
// I nomi delle lingue restano nella lingua che nominano.
MenuItem {
text: "English"
onClicked: translator.language = "en"
}
MenuItem {
text: "Italiano"
onClicked: translator.language = "it"
}
}
}
Label {
x: Theme.horizontalPageMargin
width: parent.width - 2 * Theme.horizontalPageMargin
text: qsTr("Changing the language reloads the app.")
color: Theme.secondaryColor
font.pixelSize: Theme.fontSizeExtraSmall
wrapMode: Text.Wrap
}
// ---- bridge ---------------------------------------------------- //
SectionHeader { text: qsTr("Bridge") }
TextField {
id: urlField
x: Theme.horizontalPageMargin
width: parent.width - 2 * Theme.horizontalPageMargin
label: qsTr("Indirizzo del bridge")
label: qsTr("Bridge address")
placeholderText: "192.168.2.50:8790"
text: page.urlText
onTextChanged: if (text !== page.urlText) page.urlText = text
@@ -68,7 +110,7 @@ Page {
id: tokenField
x: Theme.horizontalPageMargin
width: parent.width - 2 * Theme.horizontalPageMargin
label: qsTr("Token del bridge")
label: qsTr("Bridge token")
showEchoModeToggle: true
text: page.tokenText
onTextChanged: if (text !== page.tokenText) page.tokenText = text
@@ -80,7 +122,7 @@ Page {
Label {
x: Theme.horizontalPageMargin
width: parent.width - 2 * Theme.horizontalPageMargin
text: qsTr("Indirizzo e token si leggono sul server: il token è in ~/.hermes/profiles/carlo/aira_bridge.json. Senza schema viene usato http://.")
text: qsTr("Address and token live on the server: the token is in aira_bridge.json next to the bridge. Without a scheme, http:// is used.")
color: Theme.secondaryColor
font.pixelSize: Theme.fontSizeExtraSmall
wrapMode: Text.Wrap
@@ -88,17 +130,17 @@ Page {
Button {
anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("Salva")
text: qsTr("Save")
onClicked: {
page.save()
page.testResult = qsTr("impostazioni salvate")
page.testResult = qsTr("settings saved")
page.testOk = true
}
}
Button {
anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("Prova connessione")
text: qsTr("Test connection")
onClicked: page.testAndReport()
}
@@ -113,4 +155,4 @@ Page {
}
}
}
}
}