Skip to content

Commit 9d0e8ed

Browse files
committed
i18n(profile): Externalize hardcoded strings to resource files
This commit replaces hardcoded UI strings in the profile feature with localized string resources to support internationalization. - **i18n(profile)**: Replaced hardcoded text in `AccountSection` with `Res.string` references for sign-in titles, descriptions, login buttons, and user stats (repos, followers, following). - **i18n(profile)**: Updated `Options` section to use string resources for "Stars" and "Favourites" labels and descriptions. - **chore**: Added necessary imports for Compose Multiplatform resources in the profile presentation module.
1 parent ba84ade commit 9d0e8ed

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

feature/profile/presentation/src/commonMain/kotlin/zed/rainxch/profile/presentation/components/sections/AccountSection.kt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ import androidx.compose.ui.text.style.TextAlign
3333
import androidx.compose.ui.text.style.TextOverflow
3434
import androidx.compose.ui.unit.dp
3535
import org.jetbrains.compose.ui.tooling.preview.Preview
36+
import org.jetbrains.compose.resources.stringResource
3637
import zed.rainxch.core.presentation.components.GitHubStoreImage
3738
import zed.rainxch.core.presentation.components.GithubStoreButton
3839
import zed.rainxch.core.presentation.theme.GithubStoreTheme
40+
import zed.rainxch.githubstore.core.presentation.res.*
3941
import zed.rainxch.profile.domain.model.UserProfile
4042
import zed.rainxch.profile.presentation.ProfileAction
4143
import zed.rainxch.profile.presentation.ProfileState
@@ -105,7 +107,7 @@ fun LazyListScope.accountSection(
105107
Spacer(Modifier.height(8.dp))
106108

107109
Text(
108-
text = "Sign in to GitHub",
110+
text = stringResource(Res.string.profile_sign_in_title),
109111
style = MaterialTheme.typography.titleLarge,
110112
color = MaterialTheme.colorScheme.onBackground,
111113
textAlign = TextAlign.Center
@@ -114,7 +116,7 @@ fun LazyListScope.accountSection(
114116
Spacer(Modifier.height(4.dp))
115117

116118
Text(
117-
text = "Unlock the full experience. Manage your apps, sync your preference, and browser faster.",
119+
text = stringResource(Res.string.profile_sign_in_description),
118120
style = MaterialTheme.typography.bodyLarge,
119121
color = MaterialTheme.colorScheme.onSurfaceVariant,
120122
textAlign = TextAlign.Center
@@ -130,19 +132,19 @@ fun LazyListScope.accountSection(
130132
horizontalArrangement = Arrangement.spacedBy(12.dp)
131133
) {
132134
StatCard(
133-
label = "Repos",
135+
label = stringResource(Res.string.profile_repos),
134136
value = state.userProfile.repositoryCount.toString(),
135137
modifier = Modifier.weight(1f)
136138
)
137139

138140
StatCard(
139-
label = "Followers",
141+
label = stringResource(Res.string.followers),
140142
value = state.userProfile.followers.toString(),
141143
modifier = Modifier.weight(1f)
142144
)
143145

144146
StatCard(
145-
label = "Following",
147+
label = stringResource(Res.string.following),
146148
value = state.userProfile.following.toString(),
147149
modifier = Modifier.weight(1f)
148150
)
@@ -153,7 +155,7 @@ fun LazyListScope.accountSection(
153155
Spacer(Modifier.height(8.dp))
154156

155157
GithubStoreButton(
156-
text = "Login",
158+
text = stringResource(Res.string.profile_login),
157159
onClick = {
158160
onAction(ProfileAction.OnLoginClick)
159161
},

feature/profile/presentation/src/commonMain/kotlin/zed/rainxch/profile/presentation/components/sections/Options.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ import androidx.compose.ui.graphics.Brush
2929
import androidx.compose.ui.graphics.vector.ImageVector
3030
import androidx.compose.ui.text.style.TextOverflow
3131
import androidx.compose.ui.unit.dp
32+
import org.jetbrains.compose.resources.stringResource
33+
import zed.rainxch.githubstore.core.presentation.res.*
3234
import zed.rainxch.profile.presentation.ProfileAction
3335

3436
fun LazyListScope.options(
@@ -38,8 +40,8 @@ fun LazyListScope.options(
3840
item {
3941
OptionCard(
4042
icon = Icons.Default.Star,
41-
label = "Stars",
42-
description = "Your Starred Repositories from GitHub",
43+
label = stringResource(Res.string.stars),
44+
description = stringResource(Res.string.profile_stars_description),
4345
onClick = {
4446
onAction(ProfileAction.OnStarredReposClick)
4547
},
@@ -50,8 +52,8 @@ fun LazyListScope.options(
5052

5153
OptionCard(
5254
icon = Icons.Default.Favorite,
53-
label = "Favourites",
54-
description = "Your Favourite Repositories saved locally",
55+
label = stringResource(Res.string.favourites),
56+
description = stringResource(Res.string.profile_favourites_description),
5557
onClick = {
5658
onAction(ProfileAction.OnFavouriteReposClick)
5759
}

0 commit comments

Comments
 (0)