Skip to content

Commit 7041133

Browse files
committedMar 30, 2024
improvement: Localize Failed open a URI error message
1 parent 7670a04 commit 7041133

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed
 

‎common/src/commonMain/kotlin/com/artemchep/keyguard/ui/markdown/Markdown.kt

+7-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import androidx.compose.ui.Modifier
99
import androidx.compose.ui.platform.LocalUriHandler
1010
import com.artemchep.keyguard.common.model.ToastMessage
1111
import com.artemchep.keyguard.common.usecase.ShowMessage
12+
import com.artemchep.keyguard.feature.localization.textResource
13+
import com.artemchep.keyguard.platform.LocalLeContext
14+
import com.artemchep.keyguard.res.Res
1215
import com.halilibo.richtext.commonmark.Markdown
1316
import com.halilibo.richtext.markdown.BasicMarkdown
1417
import com.halilibo.richtext.markdown.node.AstNode
@@ -52,16 +55,18 @@ fun MarkdownText(
5255
@Composable
5356
private fun rememberGracefulLinkClickHandler(): LinkClickHandler {
5457
val showMessage by rememberInstance<ShowMessage>()
58+
59+
val updatedContext by rememberUpdatedState(LocalLeContext)
5560
val updatedUriHandler by rememberUpdatedState(LocalUriHandler.current)
5661
return remember {
5762
LinkClickHandler { uri ->
5863
try {
5964
updatedUriHandler.openUri(uri)
6065
} catch (e: Exception) {
61-
val title = e.message
62-
?: "Could not open a URI"
66+
val title = textResource(Res.strings.error_failed_open_uri, updatedContext)
6367
val msg = ToastMessage(
6468
title = title,
69+
text = e.message,
6570
type = ToastMessage.Type.ERROR,
6671
)
6772
showMessage.copy(msg)

‎common/src/commonMain/resources/MR/base/strings.xml

+1
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@
455455
<string name="error_failed_generate_otp_code">Failed to generate OTP code</string>
456456
<string name="error_failed_create_passkey">Failed to create a passkey</string>
457457
<string name="error_failed_use_passkey">Failed to authorize a request</string>
458+
<string name="error_failed_open_uri">Failed to open a URI</string>
458459
<string name="error_failed_format_placeholder">Failed to format the placeholder</string>
459460

460461
<!-- Title of the 'Show as Barcode' dialog -->

0 commit comments

Comments
 (0)
Please sign in to comment.