Skip to content

Commit 167deee

Browse files
oscfdezdzstarry-shivam
authored andcommitted
fix: Add missing translation strings (#179)
Also drops the ending periods from some strings for consistency with the rest.
1 parent e658993 commit 167deee

File tree

14 files changed

+287
-117
lines changed

14 files changed

+287
-117
lines changed

app/src/main/java/com/starry/greenstash/ui/common/CurrencyPicker.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,11 @@ fun CurrencyPicker(
139139
modifier = Modifier
140140
.fillMaxWidth()
141141
.padding(16.dp),
142-
placeholder = { Text("Search currency") },
142+
placeholder = { Text(stringResource(R.string.search_currency)) },
143143
leadingIcon = {
144144
Icon(
145145
imageVector = Icons.Default.Search,
146-
contentDescription = "Search"
146+
contentDescription = stringResource(R.string.search)
147147
)
148148
}, shape = RoundedCornerShape(12.dp)
149149
)

app/src/main/java/com/starry/greenstash/ui/screens/home/composables/HomeScreen.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ import com.starry.greenstash.ui.screens.home.FilterSortType
108108
import com.starry.greenstash.ui.screens.home.HomeViewModel
109109
import com.starry.greenstash.ui.screens.home.SearchBarState
110110
import com.starry.greenstash.ui.theme.greenstashFont
111+
import com.starry.greenstash.utils.displayName
111112
import com.starry.greenstash.utils.getActivity
112113
import com.starry.greenstash.utils.isScrollingUp
113114
import com.starry.greenstash.utils.weakHapticFeedback
@@ -450,15 +451,15 @@ private fun FilterSheetContent(viewModel: HomeViewModel) {
450451
Column(modifier = Modifier.weight(1f), verticalArrangement = Arrangement.Center) {
451452
FilterField.entries.forEach {
452453
FilterButton(
453-
text = it.name,
454+
text = it.displayName(),
454455
isSelected = it == viewModel.filterFlowData.value.filterField,
455456
onClick = { viewModel.updateFilterField(it) })
456457
}
457458
}
458459
Column(modifier = Modifier.weight(1f), verticalArrangement = Arrangement.Center) {
459460
FilterSortType.entries.forEach {
460461
FilterButton(
461-
text = it.name,
462+
text = it.displayName(),
462463
isSelected = viewModel.filterFlowData.value.sortType.name == it.name,
463464
onClick = { viewModel.updateFilterSort(it) })
464465
}

app/src/main/java/com/starry/greenstash/ui/screens/info/composables/GoalInfoScreen.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ import com.starry.greenstash.ui.theme.greenstashFont
100100
import com.starry.greenstash.ui.theme.greenstashNumberFont
101101
import com.starry.greenstash.utils.GoalTextUtils
102102
import com.starry.greenstash.utils.NumberUtils
103+
import com.starry.greenstash.utils.displayName
103104
import com.starry.greenstash.utils.weakHapticFeedback
104105
import kotlinx.coroutines.delay
105106

@@ -364,7 +365,7 @@ fun GoalPriorityCard(goalPriority: GoalPriority, reminders: Boolean) {
364365
}
365366
Text(
366367
modifier = Modifier.padding(start = 12.dp),
367-
text = stringResource(id = R.string.info_goal_priority).format(goalPriority.name),
368+
text = stringResource(id = R.string.info_goal_priority).format(goalPriority.displayName()),
368369
fontWeight = FontWeight.Medium,
369370
fontFamily = greenstashFont
370371
)

app/src/main/java/com/starry/greenstash/ui/screens/input/composables/InputScreen.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ import com.starry.greenstash.ui.screens.input.InputViewModel
143143
import com.starry.greenstash.ui.theme.greenstashFont
144144
import com.starry.greenstash.utils.ImageUtils
145145
import com.starry.greenstash.utils.NumberUtils
146+
import com.starry.greenstash.utils.displayName
146147
import com.starry.greenstash.utils.getActivity
147148
import com.starry.greenstash.utils.hasNotificationPermission
148149
import com.starry.greenstash.utils.toToast
@@ -678,7 +679,7 @@ private fun GoalPriorityMenu(selectedPriority: String, onPriorityChanged: (Strin
678679
shape = RoundedCornerShape(topStart = 14.dp, bottomStart = 14.dp),
679680
label = {
680681
Text(
681-
text = GoalPriority.High.name, fontFamily = greenstashFont
682+
text = GoalPriority.High.displayName(), fontFamily = greenstashFont
682683
)
683684
},
684685
icon = {
@@ -704,7 +705,7 @@ private fun GoalPriorityMenu(selectedPriority: String, onPriorityChanged: (Strin
704705
shape = RectangleShape,
705706
label = {
706707
Text(
707-
text = GoalPriority.Normal.name, fontFamily = greenstashFont
708+
text = GoalPriority.Normal.displayName(), fontFamily = greenstashFont
708709
)
709710
},
710711
icon = {
@@ -730,7 +731,7 @@ private fun GoalPriorityMenu(selectedPriority: String, onPriorityChanged: (Strin
730731
shape = RoundedCornerShape(topEnd = 14.dp, bottomEnd = 14.dp),
731732
label = {
732733
Text(
733-
text = GoalPriority.Low.name, fontFamily = greenstashFont
734+
text = GoalPriority.Low.displayName(), fontFamily = greenstashFont
734735
)
735736
},
736737
icon = {

app/src/main/java/com/starry/greenstash/ui/screens/settings/composables/GoalCardStyle.kt

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ import com.starry.greenstash.ui.screens.home.GoalCardStyle
8787
import com.starry.greenstash.ui.screens.home.composables.GoalItemClassic
8888
import com.starry.greenstash.ui.screens.home.composables.GoalItemCompact
8989
import com.starry.greenstash.ui.theme.greenstashFont
90+
import com.starry.greenstash.utils.NumberUtils
91+
import com.starry.greenstash.utils.PreferenceUtil
9092
import com.starry.greenstash.utils.getActivity
9193
import com.starry.greenstash.utils.weakHapticFeedback
9294
import kotlinx.coroutines.ExperimentalCoroutinesApi
@@ -98,6 +100,7 @@ import kotlinx.coroutines.delay
98100
fun GoalCardStyle(navController: NavController) {
99101
val view = LocalView.current
100102
val context = navController.context
103+
val preferenceUtil = PreferenceUtil(context)
101104

102105
val settingsVM = (context.getActivity() as MainActivity).settingsViewModel
103106
val currentStyle = settingsVM.goalCardStyle.observeAsState().value!!
@@ -147,7 +150,7 @@ fun GoalCardStyle(navController: NavController) {
147150
.animateContentSize()
148151
) {
149152
Text(
150-
text = "Preview",
153+
text = stringResource(R.string.preview),
151154
modifier = Modifier.padding(start = 16.dp, top = 14.dp),
152155
fontFamily = greenstashFont,
153156
fontSize = 17.sp,
@@ -158,12 +161,24 @@ fun GoalCardStyle(navController: NavController) {
158161
targetState = currentStyle,
159162
label = "GoalStyleAnimation"
160163
) { state ->
164+
val currency =
165+
preferenceUtil.getString(PreferenceUtil.DEFAULT_CURRENCY_STR, "")!!
166+
161167
when (state) {
162168
GoalCardStyle.Classic -> {
163169
GoalItemClassic(
164-
title = "Home Decorations",
165-
primaryText = "You're off to a great start!\nCurrently saved $500.00 out of $5,000.00.",
166-
secondaryText = "You have until 26/05/2023 (85) days left.\nYou need to save around $58.83/day, $416.67/week, $2,500.00/month.",
170+
title = stringResource(R.string.preview_example_title),
171+
primaryText = stringResource(R.string.preview_example_primary_text)
172+
.format(
173+
NumberUtils.formatCurrency(500.00, currency),
174+
NumberUtils.formatCurrency(5000.00, currency)
175+
),
176+
secondaryText = stringResource(R.string.preview_example_secondary_text)
177+
.format(
178+
NumberUtils.formatCurrency(58.83, currency),
179+
NumberUtils.formatCurrency(416.67, currency),
180+
NumberUtils.formatCurrency(2500.00, currency)
181+
),
167182
goalProgress = 0.6f,
168183
goalImage = null,
169184
isGoalCompleted = false,
@@ -177,9 +192,9 @@ fun GoalCardStyle(navController: NavController) {
177192

178193
GoalCardStyle.Compact -> {
179194
GoalItemCompact(
180-
title = "Home Decorations",
181-
savedAmount = "$1,000.00",
182-
daysLeftText = "12 days left",
195+
title = stringResource(R.string.preview_example_title),
196+
savedAmount = NumberUtils.formatCurrency(1000.00, currency),
197+
daysLeftText = stringResource(R.string.info_card_remaining_days).format(12),
183198
goalProgress = 0.8f,
184199
goalIcon = ImageVector.vectorResource(id = R.drawable.ic_nav_rating),
185200
isGoalCompleted = false,

app/src/main/java/com/starry/greenstash/utils/Extensions.kt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,12 @@ import androidx.compose.runtime.getValue
4141
import androidx.compose.runtime.mutableIntStateOf
4242
import androidx.compose.runtime.remember
4343
import androidx.compose.runtime.setValue
44+
import androidx.compose.ui.res.stringResource
4445
import androidx.core.content.ContextCompat
46+
import com.starry.greenstash.R
47+
import com.starry.greenstash.database.goal.GoalPriority
48+
import com.starry.greenstash.ui.screens.home.FilterField
49+
import com.starry.greenstash.ui.screens.home.FilterSortType
4550
import java.io.File
4651
import java.io.PrintWriter
4752

@@ -136,4 +141,39 @@ fun View.weakHapticFeedback() {
136141
*/
137142
fun View.strongHapticFeedback() {
138143
this.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)
144+
}
145+
146+
/**
147+
* Translates FilterField enum values
148+
*/
149+
@Composable
150+
fun FilterField.displayName(): String {
151+
return when (this) {
152+
FilterField.Title -> stringResource(R.string.filter_title)
153+
FilterField.Amount -> stringResource(R.string.filter_amount)
154+
FilterField.Priority -> stringResource(R.string.filter_priority)
155+
}
156+
}
157+
158+
/**
159+
* Translates FilterSortType enum values
160+
*/
161+
@Composable
162+
fun FilterSortType.displayName(): String {
163+
return when (this) {
164+
FilterSortType.Ascending -> stringResource(R.string.sort_ascending)
165+
FilterSortType.Descending -> stringResource(R.string.sort_descending)
166+
}
167+
}
168+
169+
/**
170+
* Translates GoalPriority enum values
171+
*/
172+
@Composable
173+
fun GoalPriority.displayName(): String {
174+
return when (this) {
175+
GoalPriority.High -> stringResource(R.string.priority_high)
176+
GoalPriority.Normal -> stringResource(R.string.priority_normal)
177+
GoalPriority.Low -> stringResource(R.string.priority_low)
178+
}
139179
}

0 commit comments

Comments
 (0)