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 dc989a0..39e22b6 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 3082e0e..77eeb39 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