Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[p4]
스트링 추출 후에 다국어 지원으로 가는 방향이 아니라 이 방식으로 진행한 이유가 따로 있나요?
한국어, 한자, 영어를 제외하고 다른 방법 쓸 일이 있을까 싶긴한데 다국어 관련해서 추가 사항이 있으면 항상 이렇게 따로 추가해야 하는게 번거로울 수도 있지 않을까하는 생각이 드네요. 스트링 추출해서 언어 지원을 바꾸는 걸로 전부 대응하려는게 너무 딸깍적 사고일까요 ㅋㅋ

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

딱히 특별한 이유는 없고, EN/KR 두 가지 label만 가볍게 다룰 목적이었습니다.
중국어나 일본어 같은 건 고려하지 않았고, 기존 구조가 toKoreanShortLabel() 함수를 이미 사용하고 있어서 영어만 extension으로 자연스럽게 추가한 형태입니다.

Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,64 @@ import androidx.compose.ui.unit.dp
import com.sopt.clody.ui.theme.ClodyTheme
import kotlinx.datetime.DayOfWeek

enum class WeekLang {
KOREAN, ENGLISH
}

fun DayOfWeek.toKoreanShortLabel(): String {
return when (this) {
DayOfWeek.SUNDAY -> "일"
DayOfWeek.MONDAY -> "월"
DayOfWeek.TUESDAY -> "화"
DayOfWeek.WEDNESDAY -> "수"
DayOfWeek.THURSDAY -> "목"
DayOfWeek.FRIDAY -> "금"
DayOfWeek.SATURDAY -> "토"
}
}

fun DayOfWeek.toEnglishShortLabel(): String {
return when (this) {
DayOfWeek.SUNDAY -> "Sun"
DayOfWeek.MONDAY -> "Mon"
DayOfWeek.TUESDAY -> "Tue"
DayOfWeek.WEDNESDAY -> "Wed"
DayOfWeek.THURSDAY -> "Thu"
DayOfWeek.FRIDAY -> "Fri"
DayOfWeek.SATURDAY -> "Sat"
}
}

fun DayOfWeek.getLabel(lang: WeekLang): String {
return when (lang) {
WeekLang.KOREAN -> this.toKoreanShortLabel()
WeekLang.ENGLISH -> this.toEnglishShortLabel()
}
}
Comment on lines +24 to +53
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Critical: Hardcoded strings violate i18n principles.

While the WeekLang enum provides language selection flexibility, the extension functions still contain hardcoded Korean and English strings. This approach:

  • Won't support runtime locale changes
  • Prevents proper localization through Android's resource system
  • Is inconsistent with the rest of the PR's i18n approach

Replace the hardcoded strings with string resources:

fun DayOfWeek.toKoreanShortLabel(): String {
    return when (this) {
-        DayOfWeek.SUNDAY -> "일"
-        DayOfWeek.MONDAY -> "월"
+        DayOfWeek.SUNDAY -> stringResource(R.string.weekday_sunday_short_ko)
+        DayOfWeek.MONDAY -> stringResource(R.string.weekday_monday_short_ko)
        // ... continue for all days
    }
}

Or better yet, consider using a single extension function with stringResource and let the Android system handle locale selection automatically.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In
app/src/main/java/com/sopt/clody/presentation/ui/home/calendar/component/WeekHeader.kt
between lines 24 and 53, the DayOfWeek extension functions use hardcoded Korean
and English strings, which breaks i18n best practices and prevents dynamic
locale changes. Refactor these functions to remove hardcoded strings and instead
retrieve the day labels from Android string resources using stringResource or a
similar mechanism. Ideally, consolidate into a single extension function that
uses stringResource to automatically handle localization based on the current
device locale, ensuring proper integration with Android's resource system and
runtime locale changes.


@Composable
fun WeekHeader(modifier: Modifier = Modifier, itemWidth: Dp) {
val itemWidth = (LocalConfiguration.current.screenWidthDp.dp - 40.dp) / 7
fun WeekHeader(
modifier: Modifier = Modifier,
itemWidth: Dp = (LocalConfiguration.current.screenWidthDp.dp - 40.dp) / 7,
lang: WeekLang = WeekLang.KOREAN,
) {
val weekLabelArray = listOf(
DayOfWeek.SUNDAY,
DayOfWeek.MONDAY,
DayOfWeek.TUESDAY,
DayOfWeek.WEDNESDAY,
DayOfWeek.THURSDAY,
DayOfWeek.FRIDAY,
DayOfWeek.SATURDAY,
)

val labels = weekLabelArray.map { it.getLabel(lang) }

Row(
horizontalArrangement = Arrangement.SpaceBetween,
modifier = modifier.fillMaxWidth(),
) {
val weekLabelArray = listOf(
DayOfWeek.SUNDAY,
DayOfWeek.MONDAY,
DayOfWeek.TUESDAY,
DayOfWeek.WEDNESDAY,
DayOfWeek.THURSDAY,
DayOfWeek.FRIDAY,
DayOfWeek.SATURDAY,
)

val koreanWeekLabels = weekLabelArray.map { it.toKoreanShortLabel() }

koreanWeekLabels.forEach { week ->
labels.forEach { week ->
Box(
modifier = Modifier.width(itemWidth),
contentAlignment = Alignment.Center,
Expand All @@ -52,19 +90,14 @@ fun WeekHeader(modifier: Modifier = Modifier, itemWidth: Dp) {
}
}

fun DayOfWeek.toKoreanShortLabel(): String {
return when (this) {
DayOfWeek.SUNDAY -> "일"
DayOfWeek.MONDAY -> "월"
DayOfWeek.TUESDAY -> "화"
DayOfWeek.WEDNESDAY -> "수"
DayOfWeek.THURSDAY -> "목"
DayOfWeek.FRIDAY -> "금"
DayOfWeek.SATURDAY -> "토"
}
@Preview(showBackground = true)
@Composable
fun WeekHeaderKoreanPreview() {
WeekHeader(lang = WeekLang.KOREAN)
}

@Composable
@Preview(showBackground = true)
fun WeekHeaderPreview() {
@Composable
fun WeekHeaderEnglishPreview() {
WeekHeader(lang = WeekLang.ENGLISH)
}