From 70411332af1e6d5a06fdca25e54b5eed920f80e7 Mon Sep 17 00:00:00 2001 From: Artem Chepurnoy Date: Fri, 29 Mar 2024 12:58:01 +0200 Subject: [PATCH] improvement: Localize Failed open a URI error message --- .../com/artemchep/keyguard/ui/markdown/Markdown.kt | 9 +++++++-- common/src/commonMain/resources/MR/base/strings.xml | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/common/src/commonMain/kotlin/com/artemchep/keyguard/ui/markdown/Markdown.kt b/common/src/commonMain/kotlin/com/artemchep/keyguard/ui/markdown/Markdown.kt index dc989a07..39e22b6c 100644 --- a/common/src/commonMain/kotlin/com/artemchep/keyguard/ui/markdown/Markdown.kt +++ b/common/src/commonMain/kotlin/com/artemchep/keyguard/ui/markdown/Markdown.kt @@ -9,6 +9,9 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalUriHandler import com.artemchep.keyguard.common.model.ToastMessage import com.artemchep.keyguard.common.usecase.ShowMessage +import com.artemchep.keyguard.feature.localization.textResource +import com.artemchep.keyguard.platform.LocalLeContext +import com.artemchep.keyguard.res.Res import com.halilibo.richtext.commonmark.Markdown import com.halilibo.richtext.markdown.BasicMarkdown import com.halilibo.richtext.markdown.node.AstNode @@ -52,16 +55,18 @@ fun MarkdownText( @Composable private fun rememberGracefulLinkClickHandler(): LinkClickHandler { val showMessage by rememberInstance() + + val updatedContext by rememberUpdatedState(LocalLeContext) val updatedUriHandler by rememberUpdatedState(LocalUriHandler.current) return remember { LinkClickHandler { uri -> try { updatedUriHandler.openUri(uri) } catch (e: Exception) { - val title = e.message - ?: "Could not open a URI" + val title = textResource(Res.strings.error_failed_open_uri, updatedContext) val msg = ToastMessage( title = title, + text = e.message, type = ToastMessage.Type.ERROR, ) showMessage.copy(msg) diff --git a/common/src/commonMain/resources/MR/base/strings.xml b/common/src/commonMain/resources/MR/base/strings.xml index 3082e0e4..77eeb391 100644 --- a/common/src/commonMain/resources/MR/base/strings.xml +++ b/common/src/commonMain/resources/MR/base/strings.xml @@ -455,6 +455,7 @@ Failed to generate OTP code Failed to create a passkey Failed to authorize a request + Failed to open a URI Failed to format the placeholder