Adjusted Landing page string substitutions to cater for emojis

This commit is contained in:
alansley 2024-08-27 15:33:55 +10:00
parent 4809b5444b
commit a402a1be79
4 changed files with 44 additions and 18 deletions

View File

@ -18,7 +18,9 @@ import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import com.squareup.phrase.Phrase import com.squareup.phrase.Phrase
import network.loki.messenger.R import network.loki.messenger.R
import org.session.libsession.utilities.NonTranslatableStringConstants.WAVING_HAND_EMOJI
import org.session.libsession.utilities.StringSubstitutionConstants.APP_NAME_KEY import org.session.libsession.utilities.StringSubstitutionConstants.APP_NAME_KEY
import org.session.libsession.utilities.StringSubstitutionConstants.EMOJI_KEY
import org.thoughtcrime.securesms.ui.Divider import org.thoughtcrime.securesms.ui.Divider
import org.thoughtcrime.securesms.ui.theme.LocalColors import org.thoughtcrime.securesms.ui.theme.LocalColors
import org.thoughtcrime.securesms.ui.theme.LocalDimensions import org.thoughtcrime.securesms.ui.theme.LocalDimensions
@ -49,7 +51,10 @@ internal fun EmptyView(newAccount: Boolean) {
Text( Text(
stringResource(R.string.onboardingBubbleWelcomeToSession).let { txt -> stringResource(R.string.onboardingBubbleWelcomeToSession).let { txt ->
val c = LocalContext.current val c = LocalContext.current
Phrase.from(txt).put(APP_NAME_KEY, c.getString(R.string.app_name)).format().toString() Phrase.from(txt)
.put(APP_NAME_KEY, c.getString(R.string.app_name))
.put(EMOJI_KEY, WAVING_HAND_EMOJI)
.format().toString()
}, },
style = LocalType.current.base, style = LocalType.current.base,
color = LocalColors.current.primary, color = LocalColors.current.primary,

View File

@ -37,7 +37,10 @@ import androidx.compose.ui.unit.dp
import com.squareup.phrase.Phrase import com.squareup.phrase.Phrase
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import network.loki.messenger.R import network.loki.messenger.R
import org.session.libsession.utilities.NonTranslatableStringConstants.BACKHAND_INDEX_POINTING_DOWN_EMOJI
import org.session.libsession.utilities.NonTranslatableStringConstants.WAVING_HAND_EMOJI
import org.session.libsession.utilities.StringSubstitutionConstants.APP_NAME_KEY import org.session.libsession.utilities.StringSubstitutionConstants.APP_NAME_KEY
import org.session.libsession.utilities.StringSubstitutionConstants.EMOJI_KEY
import org.thoughtcrime.securesms.ui.AlertDialog import org.thoughtcrime.securesms.ui.AlertDialog
import org.thoughtcrime.securesms.ui.DialogButtonModel import org.thoughtcrime.securesms.ui.DialogButtonModel
import org.thoughtcrime.securesms.ui.GetString import org.thoughtcrime.securesms.ui.GetString
@ -132,12 +135,28 @@ internal fun LandingScreen(
key = { it.stringId } key = { it.stringId }
) { item -> ) { item ->
// Perform string substitution only in the bubbles that require it // Perform string substitution only in the bubbles that require it
val bubbleTxt = if (item.stringId == R.string.onboardingBubbleWelcomeToSession || val bubbleTxt = when (item.stringId) {
item.stringId == R.string.onboardingBubbleSessionIsEngineered) { R.string.onboardingBubbleWelcomeToSession -> {
Phrase.from(stringResource(item.stringId)).put(APP_NAME_KEY, stringResource(R.string.app_name)).format().toString() Phrase.from(stringResource(item.stringId))
} else { .put(APP_NAME_KEY, stringResource(R.string.app_name))
.put(EMOJI_KEY, WAVING_HAND_EMOJI)
.format().toString()
}
R.string.onboardingBubbleSessionIsEngineered -> {
Phrase.from(stringResource(item.stringId))
.put(APP_NAME_KEY, stringResource(R.string.app_name))
.format().toString()
}
R.string.onboardingBubbleCreatingAnAccountIsEasy -> {
Phrase.from(stringResource(item.stringId))
.put(EMOJI_KEY, BACKHAND_INDEX_POINTING_DOWN_EMOJI)
.format().toString()
}
else -> {
stringResource(item.stringId) stringResource(item.stringId)
} }
}
AnimateMessageText( AnimateMessageText(
bubbleTxt, bubbleTxt,
item.isOutgoing item.isOutgoing

View File

@ -1,6 +1,6 @@
package org.session.libsession.utilities package org.session.libsession.utilities
// Non-translatable strings for use with the UI // Non-translatable strings for UI substitutions
object NonTranslatableStringConstants { object NonTranslatableStringConstants {
const val APP_NAME = "Session" const val APP_NAME = "Session"
const val ARBISCAN = "Arbiscan" const val ARBISCAN = "Arbiscan"
@ -11,4 +11,6 @@ object NonTranslatableStringConstants {
const val TOKEN_NAME_LONG = "Session Token" const val TOKEN_NAME_LONG = "Session Token"
const val TOKEN_NAME_LONG_PLURAL = "Session Tokens" const val TOKEN_NAME_LONG_PLURAL = "Session Tokens"
const val TOKEN_NAME_SHORT = "SENT" const val TOKEN_NAME_SHORT = "SENT"
const val WAVING_HAND_EMOJI = "\uD83D\uDC4B" // Used on the landing page & substituted into `onboardingBubbleWelcomeToSession`
const val BACKHAND_INDEX_POINTING_DOWN_EMOJI = "\uD83D\uDC47" // Used on the landing page & substituted into `onboardingBubbleCreatingAnAccountIsEasy`
} }

View File

@ -613,11 +613,11 @@ NOTE: Strings with blank lines have manually been replaced with '\n\n' - this wi
<string name="onboardingAccountExists">I have an account</string> <string name="onboardingAccountExists">I have an account</string>
<string name="onboardingBackAccountCreation">You cannot go back further. In order to cancel your account creation, {app_name} needs to quit.</string> <string name="onboardingBackAccountCreation">You cannot go back further. In order to cancel your account creation, {app_name} needs to quit.</string>
<string name="onboardingBackLoadAccount">You cannot go back further. In order to stop loading your account, {app_name} needs to quit.</string> <string name="onboardingBackLoadAccount">You cannot go back further. In order to stop loading your account, {app_name} needs to quit.</string>
<string name="onboardingBubbleCreatingAnAccountIsEasy">Creating an account is instant, free, and anonymous </string> <string name="onboardingBubbleCreatingAnAccountIsEasy">Creating an account is instant, free, and anonymous {emoji}</string>
<string name="onboardingBubbleNoPhoneNumber">You don\'t even need a phone number to sign up.</string> <string name="onboardingBubbleNoPhoneNumber">You don\'t even need a phone number to sign up.</string>
<string name="onboardingBubblePrivacyInYourPocket">Privacy in your pocket.</string> <string name="onboardingBubblePrivacyInYourPocket">Privacy in your pocket.</string>
<string name="onboardingBubbleSessionIsEngineered">{app_name} is engineered to protect your privacy.</string> <string name="onboardingBubbleSessionIsEngineered">{app_name} is engineered to protect your privacy.</string>
<string name="onboardingBubbleWelcomeToSession">Welcome to {app_name}</string> <string name="onboardingBubbleWelcomeToSession">Welcome to {app_name} {emoji}</string>
<string name="onboardingHitThePlusButton">Hit the plus button to start a chat, create a group, or join an official community!</string> <string name="onboardingHitThePlusButton">Hit the plus button to start a chat, create a group, or join an official community!</string>
<string name="onboardingMessageNotificationExplanation">There are two ways {app_name} can notify you of new messages.</string> <string name="onboardingMessageNotificationExplanation">There are two ways {app_name} can notify you of new messages.</string>
<string name="onboardingPrivacy">Privacy Policy</string> <string name="onboardingPrivacy">Privacy Policy</string>