Skip to content

Commit fc9f33a

Browse files
aanorbelagrabeli
andauthored
feat(desktop): use string resources for update notifications (#960)
* feat(desktop): use string resources for update notifications * Update strings-organization.xml Minor edit --------- Co-authored-by: Maria Xynou <[email protected]>
1 parent b278b2c commit fc9f33a

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

composeApp/src/desktopMain/kotlin/org/ooni/probe/Main.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ fun main(args: Array<String>) {
154154
// Only show update UI on Mac and Windows platforms
155155
if (updateController.supportsUpdates()) {
156156
Item(
157-
text = updateController.getMenuText(),
157+
text = stringResource(updateController.getMenuText()),
158158
enabled = updateState != UpdateState.CHECKING_FOR_UPDATES,
159159
onClick = { updateController.checkNow() },
160160
)

composeApp/src/desktopMain/kotlin/org/ooni/probe/update/DesktopUpdateController.kt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ import kotlinx.coroutines.Dispatchers
77
import kotlinx.coroutines.flow.MutableStateFlow
88
import kotlinx.coroutines.flow.StateFlow
99
import kotlinx.coroutines.launch
10+
import ooniprobe.composeapp.generated.resources.Res
11+
import ooniprobe.composeapp.generated.resources.Tray_Notification_Check_Updates
12+
import ooniprobe.composeapp.generated.resources.Tray_Notification_Checking_Updates
13+
import ooniprobe.composeapp.generated.resources.Tray_Notification_Updates_Available
14+
import org.jetbrains.compose.resources.StringResource
1015
import org.ooni.probe.config.UpdateConfig
1116
import org.ooni.probe.dependencies
1217
import org.ooni.probe.shared.DesktopOS
@@ -118,12 +123,11 @@ class DesktopUpdateController(
118123
updateManager.retryLastOperation()
119124
}
120125

121-
// TODO: add translations after macOS has been finalized
122-
fun getMenuText(): String =
126+
fun getMenuText(): StringResource =
123127
when (_state.value) {
124-
UpdateState.CHECKING_FOR_UPDATES -> "Checking for Updates..."
125-
UpdateState.UPDATE_AVAILABLE -> "Update Available!"
126-
else -> "Check for Updates"
128+
UpdateState.CHECKING_FOR_UPDATES -> Res.string.Tray_Notification_Checking_Updates
129+
UpdateState.UPDATE_AVAILABLE -> Res.string.Tray_Notification_Updates_Available
130+
else -> Res.string.Tray_Notification_Check_Updates
127131
}
128132

129133
suspend fun cleanup() {

composeApp/src/ooniMain/composeResources/values/strings-organization.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,7 @@
5353
<string name="Settings_Donate_Action_Error">Error opening donation page. Please go to %1$s</string>
5454

5555
<string name="Dashboard_Runv2_Overview_Uninstall_Prompt">You will be able to install this link again only from the original link sent by the creator. Measurements from this link will be deleted, but will be accessible from explorer.</string>
56+
<string name="Tray_Notification_Check_Updates">Check for Updates</string>
57+
<string name="Tray_Notification_Updates_Available">Update Available!</string>
58+
<string name="Tray_Notification_Checking_Updates">Checking for updates...</string>
5659
</resources>

0 commit comments

Comments
 (0)