Conversation
- 영어 버전은 월->연 순서, 한국어 버전은 연->월 순서
- 다이얼로그 텍스트 중앙정렬 - 정규식 문법 수정 - 임시저장 바텀시트 텍스트 리소스 수정
WalkthroughThis update implements comprehensive internationalization for date and time formatting across the app. It introduces new localized extension functions for year and month labels, updates string resources to use string placeholders, replaces hardcoded date logic with locale-aware formatting, and removes or refactors components to support dynamic, language-appropriate display of dates and times in both Korean and English. Changes
Sequence Diagram(s)sequenceDiagram
participant UI as User Interface
participant Ext as DateLabelExtension
participant Strings as String Resources
participant Locale as Locale API
UI->>Ext: selectedYear.toLocalizedYearLabel()
Ext->>Strings: get year_format string for locale
Ext->>Locale: get current locale
Ext-->>UI: localized year string
UI->>Ext: selectedMonth.toLocalizedMonthLabel()
Ext->>Locale: get current locale
alt Korean
Ext->>Strings: get month_format string
Ext-->>UI: localized month string
else Other
Ext->>Locale: get English month name
Ext-->>UI: formatted English month string
end
UI->>Strings: Use home_year_month_format with localized year/month
Estimated code review effort4 (~80–100 minutes) Possibly related PRs
Suggested labels
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (5)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 3
🔭 Outside diff range comments (3)
app/src/main/java/com/sopt/clody/presentation/ui/home/calendar/component/WeekHeader.kt (1)
25-33: Excellent architectural improvement!Removing the custom
WeekLangenum and extension functions in favor of standard Java time APIs is a significant improvement. This approach is more maintainable, leverages well-tested standard libraries, and automatically supports all locales without manual mapping.Apply the same safe locale access pattern:
-text = week.getDisplayName(TextStyle.NARROW, LocalConfiguration.current.locales[0]), +text = week.getDisplayName(TextStyle.NARROW, LocalConfiguration.current.locales.let { if (it.isEmpty()) java.util.Locale.getDefault() else it[0] }),Also applies to: 39-52
app/src/main/java/com/sopt/clody/presentation/utils/extension/StringExt.kt (1)
24-32: Hardcoded Korean strings contradict internationalization goals.The
to24HourFormatfunction contains hardcoded Korean strings "오후" and "오전" which defeats the purpose of internationalization. This function should accept localized strings or be made @composable to use string resources.Consider one of these approaches:
- Make it @composable and use string resources:
+@Composable fun Triple<String, String, String>.to24HourFormat(): String { val (amPm, hour, minute) = this + val pmString = stringResource(R.string.time_pm) + val amString = stringResource(R.string.time_am) val hourInt = when { - amPm == "오후" && hour.toInt() != 12 -> hour.toInt() + 12 - amPm == "오전" && hour.toInt() == 12 -> 0 + amPm == pmString && hour.toInt() != 12 -> hour.toInt() + 12 + amPm == amString && hour.toInt() == 12 -> 0 else -> hour.toInt() } return String.format("%02d:%02d", hourInt, minute.toInt()) }
- Pass the localized strings as parameters:
-fun Triple<String, String, String>.to24HourFormat(): String { +fun Triple<String, String, String>.to24HourFormat(amString: String, pmString: String): String { val (amPm, hour, minute) = this val hourInt = when { - amPm == "오후" && hour.toInt() != 12 -> hour.toInt() + 12 - amPm == "오전" && hour.toInt() == 12 -> 0 + amPm == pmString && hour.toInt() != 12 -> hour.toInt() + 12 + amPm == amString && hour.toInt() == 12 -> 0 else -> hour.toInt() } return String.format("%02d:%02d", hourInt, minute.toInt()) }app/src/main/java/com/sopt/clody/presentation/ui/component/timepicker/YearMonthPicker.kt (1)
170-175: Potential IndexOutOfBounds risk when converting labels back to values.The
indexOfcalls on lines 172-173 could return -1 if the localized strings don't match exactly, which would cause an IndexOutOfBoundsException when accessing the lists.val year = yearItems[yearLabelItems.indexOf(yearPickerState.selectedItem)] val month = monthItems[monthLabelItems.indexOf(monthPickerState.selectedItem)] +// Add validation +val yearIndex = yearLabelItems.indexOf(yearPickerState.selectedItem) +val monthIndex = monthLabelItems.indexOf(monthPickerState.selectedItem) +if (yearIndex == -1 || monthIndex == -1) { + // Handle error case + return +} +val year = yearItems[yearIndex] +val month = monthItems[monthIndex]
🧹 Nitpick comments (8)
app/src/main/java/com/sopt/clody/presentation/ui/component/dialog/ClodyDialog.kt (1)
38-40: Typo in parameter names:Massage→Message
The current spelling may confuse contributors and hurts autocomplete/searchability.-fun ClodyDialog( - titleMassage: String, - descriptionMassage: String, +fun ClodyDialog( + titleMessage: String, + descriptionMessage: String,Don’t forget to rename the corresponding usages inside the body.
app/src/main/java/com/sopt/clody/presentation/ui/auth/signup/SignUpViewModel.kt (1)
178-178: LGTM! Regex syntax is now correct.The quantifier closure fix resolves the syntax error and the regex will now properly validate nicknames between 2 and the maximum allowed length.
Minor optimization opportunity - the character class contains
가-힣twice, which is redundant:-val regex = "^[a-zA-Z가-힣0-9ㄱ-ㅎㅏ-ㅣ가-힣]{2,${state.nicknameMaxLength}}$".toRegex() +val regex = "^[a-zA-Z가-힣0-9ㄱ-ㅎㅏ-ㅣ]{2,${state.nicknameMaxLength}}$".toRegex()app/src/main/java/com/sopt/clody/presentation/utils/extension/StringExt.kt (1)
7-22: Consider simplifying the minute formatting logic.The minute formatting on line 19 can be simplified by using
String.formatdirectly with the integer value.- val minuteAfter = if (minuteBefore == 0) "00" else minuteBefore.toString() - - return String.format(stringResource(R.string.notification_setting_selected_time, amPm, hourAfter, minuteAfter)) + return String.format(stringResource(R.string.notification_setting_selected_time, amPm, hourAfter, minuteBefore))app/src/main/java/com/sopt/clody/presentation/utils/extension/IntExtension.kt (1)
1-23: Consider API consistency and simplification.
- You're importing
kotlinx.datetime.Monthbut usingjava.time.format.TextStyle. Consider using consistent APIs.- The locale check only considers the first locale, which might miss user preferences.
- The string manipulation for capitalizing month names can be simplified.
-import kotlinx.datetime.Month -import java.time.format.TextStyle +import java.time.Month +import java.time.format.TextStyle import java.util.Locale @Composable fun Int.toLocalizedYearLabel(): String = stringResource(R.string.year_format, this) @Composable fun Int.toLocalizedMonthLabel(): String { - val locale = LocalContext.current.resources.configuration.locales[0] + val locale = LocalContext.current.resources.configuration.locales.get(0) return if (locale.language == "ko") { stringResource(R.string.month_format, this) } else { Month.of(this).getDisplayName(TextStyle.FULL, Locale.ENGLISH) - .lowercase().replaceFirstChar { it.titlecase() } + .lowercase(Locale.ENGLISH) + .replaceFirstChar { it.uppercase(Locale.ENGLISH) } } }app/src/main/res/values-ko/strings.xml (1)
107-107: Consider zero-padding minutes for consistency
Current pattern%1$s %2$d시 %3$s분will show3분instead of03분.-<string name="notification_setting_selected_time">%1$s %2$d시 %3$s분</string> +<string name="notification_setting_selected_time">%1$s %2$d시 %3$02d분</string>app/src/main/res/values/strings.xml (3)
45-47: Placeholder type is numeric but consumed as string downstream
year_formatandmonth_formatuse%d, yet the resulting strings are later passed as%s. This is fine at runtime, but for stronger type-safety you could make them%sin both locales to keep the contract uniform.
73-74: Minor style inconsistency
reply_titlecapitalises only the first word after the article (“lucky reply”). Consider title case (“Lucky Reply”) to match other headings.
107-107: 12-hour time string: pad minutes for single digits
Same suggestion as for the Korean resource—use%02dto avoid “3:5 PM”.-<string name="notification_setting_selected_time">%2$d:%3$s %1$s</string> +<string name="notification_setting_selected_time">%2$d:%3$02d %1$s</string>
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (22)
app/src/main/java/com/sopt/clody/presentation/ui/auth/signup/SignUpViewModel.kt(1 hunks)app/src/main/java/com/sopt/clody/presentation/ui/component/dialog/ClodyDialog.kt(1 hunks)app/src/main/java/com/sopt/clody/presentation/ui/component/timepicker/YearMonthPicker.kt(5 hunks)app/src/main/java/com/sopt/clody/presentation/ui/component/timepicker/YearMonthPickerItem.kt(0 hunks)app/src/main/java/com/sopt/clody/presentation/ui/diarylist/component/DiaryListTopAppBar.kt(1 hunks)app/src/main/java/com/sopt/clody/presentation/ui/diarylist/screen/DiaryListScreen.kt(2 hunks)app/src/main/java/com/sopt/clody/presentation/ui/diarylist/screen/DiaryListViewModel.kt(2 hunks)app/src/main/java/com/sopt/clody/presentation/ui/home/calendar/component/DailyDiaryListItem.kt(3 hunks)app/src/main/java/com/sopt/clody/presentation/ui/home/calendar/component/WeekHeader.kt(2 hunks)app/src/main/java/com/sopt/clody/presentation/ui/home/component/HomeTopAppBar.kt(2 hunks)app/src/main/java/com/sopt/clody/presentation/ui/home/component/YearAndMonthTitle.kt(0 hunks)app/src/main/java/com/sopt/clody/presentation/ui/home/screen/HomeScreen.kt(3 hunks)app/src/main/java/com/sopt/clody/presentation/ui/replydiary/ReplyDiaryScreen.kt(3 hunks)app/src/main/java/com/sopt/clody/presentation/ui/writediary/component/text/DiaryTitleText.kt(0 hunks)app/src/main/java/com/sopt/clody/presentation/ui/writediary/screen/WriteDiaryScreen.kt(3 hunks)app/src/main/java/com/sopt/clody/presentation/ui/writediary/screen/WriteDiaryViewModel.kt(1 hunks)app/src/main/java/com/sopt/clody/presentation/utils/extension/GetDayOfWeek.kt(1 hunks)app/src/main/java/com/sopt/clody/presentation/utils/extension/IntExtension.kt(1 hunks)app/src/main/java/com/sopt/clody/presentation/utils/extension/StringExt.kt(1 hunks)app/src/main/java/com/sopt/clody/presentation/utils/extension/YearMonthLabelUtil.kt(0 hunks)app/src/main/res/values-ko/strings.xml(3 hunks)app/src/main/res/values/strings.xml(4 hunks)
💤 Files with no reviewable changes (4)
- app/src/main/java/com/sopt/clody/presentation/utils/extension/YearMonthLabelUtil.kt
- app/src/main/java/com/sopt/clody/presentation/ui/home/component/YearAndMonthTitle.kt
- app/src/main/java/com/sopt/clody/presentation/ui/writediary/component/text/DiaryTitleText.kt
- app/src/main/java/com/sopt/clody/presentation/ui/component/timepicker/YearMonthPickerItem.kt
🧰 Additional context used
🧬 Code Graph Analysis (2)
app/src/main/java/com/sopt/clody/presentation/ui/writediary/screen/WriteDiaryScreen.kt (1)
app/src/main/java/com/sopt/clody/presentation/utils/extension/GetDayOfWeek.kt (1)
getDayOfWeek(8-12)
app/src/main/java/com/sopt/clody/presentation/ui/component/timepicker/YearMonthPicker.kt (1)
app/src/main/java/com/sopt/clody/presentation/ui/component/timepicker/PickerState.kt (1)
rememberPickerState(15-16)
🔇 Additional comments (22)
app/src/main/java/com/sopt/clody/presentation/ui/component/dialog/ClodyDialog.kt (2)
78-82: Title centering improves readability – looks good
The newly-addedtextAlign = TextAlign.Centermakes the dialog title consistent with the rest of the centered content.
124-129: Confirm button never dismisses the dialog
confirmAction()is invoked, butonDismiss()isn’t, so the dialog stays visible unless the caller manually closes it. Is that intentional?- confirmAction() + confirmAction() + onDismiss() // ensure the dialog closes after the action succeedsIf
confirmActionsometimes needs the dialog to stay open, consider adding a boolean return or pass a lambda to it so the caller can decide when to dismiss.app/src/main/java/com/sopt/clody/presentation/ui/home/calendar/component/DailyDiaryListItem.kt (1)
53-53: Text style changes improve visual hierarchy.The typography updates from
body3Mediumtobody2Mediumfor the date andbody2Mediumtobody2SemiBoldfor the day of week create better visual distinction and hierarchy.Also applies to: 59-59
app/src/main/java/com/sopt/clody/presentation/ui/diarylist/component/DiaryListTopAppBar.kt (1)
32-33: Good architectural change for internationalization.Changing parameter types from
InttoStringis the right approach for pre-localized year and month labels. This improves separation of concerns by moving formatting logic upstream and allows the component to focus solely on presentation.app/src/main/java/com/sopt/clody/presentation/ui/writediary/screen/WriteDiaryViewModel.kt (1)
162-162: LGTM! Critical regex syntax fix.The missing closing curly brace in the quantifier has been properly fixed, ensuring correct validation of diary entry length. The regex pattern appropriately supports both Korean and English characters for internationalization.
app/src/main/java/com/sopt/clody/presentation/ui/diarylist/screen/DiaryListScreen.kt (2)
28-29: LGTM! Proper localization imports added.The new extension functions for localized year and month labels support the internationalization effort effectively.
135-136: LGTM! Consistent localization implementation.Converting integer values to localized strings before passing to the UI component ensures proper internationalization. This approach aligns well with the broader localization strategy across the app.
app/src/main/java/com/sopt/clody/presentation/ui/replydiary/ReplyDiaryScreen.kt (3)
44-44: LGTM! Localization import added.Adding the
toLocalizedMonthLabelextension supports proper internationalization for month display.
122-122: LGTM! Consistent month localization.Converting the month integer to a localized string ensures proper internationalization and aligns with the app's localization strategy.
146-146: Verify layout impact of modifier change.The Column modifier changed from
fillMaxWidth()tofillMaxSize(), which will make the column expand to fill the entire available space rather than just the width. Ensure this change produces the desired UI layout.app/src/main/java/com/sopt/clody/presentation/ui/writediary/screen/WriteDiaryScreen.kt (3)
22-22: LGTM! Standard component import.Using the standard Material3
Textcomponent instead of a custom component promotes consistency and maintainability.
53-53: LGTM! Localization extension imported.Adding the
toLocalizedMonthLabelextension supports proper internationalization.
246-255: Excellent localization refactor!This change significantly improves internationalization by:
- Replacing the custom
DiaryTitleTextcomponent with a standardTextcomposable- Using the
getDayOfWeekcomposable which properly handles locale-aware day names- Using
toLocalizedMonthLabel()for proper month localization- Leveraging string resources for flexible formatting
This approach aligns perfectly with the PR's objective of completing English version internationalization and provides a solid foundation for supporting multiple locales.
app/src/main/java/com/sopt/clody/presentation/ui/home/screen/HomeScreen.kt (1)
379-381: No null pointer risk with calendarState.messageThe
CalendarState.Erroris instantiated inHomeViewModel.kt(line 133) as:CalendarState.Error(exception.message ?: ErrorMessages.UNKNOWN_ERROR)which guarantees
calendarState.messageis never null at runtime. No fallback change is needed.app/src/main/java/com/sopt/clody/presentation/ui/home/component/HomeTopAppBar.kt (1)
24-89: LGTM! Clean implementation of localized date display.The changes properly implement the localization approach by:
- Accepting pre-localized strings instead of raw integers
- Using a clean inline implementation with proper click handling
- Maintaining consistent styling and behavior
app/src/main/java/com/sopt/clody/presentation/ui/component/timepicker/YearMonthPicker.kt (1)
246-250: Verify the intentional consumption of vertical drag gestures.The
pointerInputmodifier consumes all vertical drag gestures, which prevents parent components from receiving these events. This might interfere with bottom sheet dismissal gestures.Is this intentional to prevent accidental dismissal while scrolling? If not, consider removing this modifier as the LazyColumn already handles its own scrolling.
app/src/main/res/values-ko/strings.xml (4)
45-47: Year / month formats look correct and locale-specific
Placeholders and ordering (년,월) follow Korean conventions and align with the newhome_year_month_format.
59-59: Verify argument order forwrite_diary_month_date_day_of_week
%2$s %3$s일 %1$sexpects(monthLabel, day, dayOfWeek)while the English string expects(dayOfWeek, monthLabel, day).
If the code always callsgetString(id, dayOfWeek, monthLabel, day)the Korean version will render incorrectly.
73-73: LGTM – placeholder swap removes type-mismatch risk
Using two%stokens is safe now that both inputs are already formatted strings.
77-77: Consistent with top-app-bar format
Same argument order ashome_year_month_format; no issues spotted.app/src/main/res/values/strings.xml (2)
59-59: Date string looks good; no ordinal suffix
English usually writes “July 3” or “3 July”; if you plan to add ordinal suffixes (“3rd”), this is the place. Current form is acceptable.
170-170: Escaped newline renders correctly
"\n"is used here, whereas line 68 uses\\n. Ensure both follow the same convention; double-escaped sequence will print “\n” literally.
app/src/main/java/com/sopt/clody/presentation/ui/diarylist/screen/DiaryListViewModel.kt
Show resolved
Hide resolved
| text = dayOfWeek.getDisplayName(TextStyle.FULL, LocalConfiguration.current.locales[0]), | ||
| style = ClodyTheme.typography.body2SemiBold, |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Good localization update with locale-aware day names.
The shift from string resources to Java time API with current locale properly supports internationalization requirements.
Same issue as in GetDayOfWeek.kt - add safe locale access:
-text = dayOfWeek.getDisplayName(TextStyle.FULL, LocalConfiguration.current.locales[0]),
+text = dayOfWeek.getDisplayName(TextStyle.FULL, LocalConfiguration.current.locales.let { if (it.isEmpty()) java.util.Locale.getDefault() else it[0] }),📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| text = dayOfWeek.getDisplayName(TextStyle.FULL, LocalConfiguration.current.locales[0]), | |
| style = ClodyTheme.typography.body2SemiBold, | |
| text = dayOfWeek.getDisplayName( | |
| TextStyle.FULL, | |
| LocalConfiguration.current.locales.let { | |
| if (it.isEmpty()) java.util.Locale.getDefault() | |
| else it[0] | |
| } | |
| ), | |
| style = ClodyTheme.typography.body2SemiBold, |
🤖 Prompt for AI Agents
In
app/src/main/java/com/sopt/clody/presentation/ui/home/calendar/component/DailyDiaryListItem.kt
around lines 58 to 59, the code accesses the locale directly from
LocalConfiguration.current.locales[0], which may cause issues if the locales
list is empty. To fix this, add safe access to the locale by checking if the
locales list is not empty before accessing the first element, and provide a
fallback locale if necessary to ensure robust locale handling.
| @Composable | ||
| fun getDayOfWeek(year: Int, month: Int, day: Int): String { | ||
| val date = LocalDate.of(year, month, day) | ||
| return date.dayOfWeek.getDisplayName(TextStyle.FULL, Locale.KOREAN) | ||
| return date.dayOfWeek.getDisplayName(TextStyle.FULL, LocalConfiguration.current.locales[0]) | ||
| } |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Excellent internationalization improvement!
Converting to locale-aware day of week display aligns perfectly with the PR's internationalization goals. The use of standard Java time APIs and dynamic locale detection is the right approach.
Add safe access to the locale to prevent potential IndexOutOfBoundsException:
@Composable
fun getDayOfWeek(year: Int, month: Int, day: Int): String {
val date = LocalDate.of(year, month, day)
- return date.dayOfWeek.getDisplayName(TextStyle.FULL, LocalConfiguration.current.locales[0])
+ val locale = LocalConfiguration.current.locales.let { if (it.isEmpty()) java.util.Locale.getDefault() else it[0] }
+ return date.dayOfWeek.getDisplayName(TextStyle.FULL, locale)
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| @Composable | |
| fun getDayOfWeek(year: Int, month: Int, day: Int): String { | |
| val date = LocalDate.of(year, month, day) | |
| return date.dayOfWeek.getDisplayName(TextStyle.FULL, Locale.KOREAN) | |
| return date.dayOfWeek.getDisplayName(TextStyle.FULL, LocalConfiguration.current.locales[0]) | |
| } | |
| @Composable | |
| fun getDayOfWeek(year: Int, month: Int, day: Int): String { | |
| val date = LocalDate.of(year, month, day) | |
| val locale = LocalConfiguration.current.locales.let { | |
| if (it.isEmpty()) java.util.Locale.getDefault() else it[0] | |
| } | |
| return date.dayOfWeek.getDisplayName(TextStyle.FULL, locale) | |
| } |
🤖 Prompt for AI Agents
In app/src/main/java/com/sopt/clody/presentation/utils/extension/GetDayOfWeek.kt
between lines 8 and 12, the code accesses the first locale from
LocalConfiguration.current.locales without checking if the locales list is
empty, which can cause an IndexOutOfBoundsException. Fix this by safely
accessing the locale list, for example by checking if the list is not empty
before accessing the first element or providing a default locale fallback to
ensure safe and robust locale retrieval.
There was a problem hiding this comment.
P3
파일명을 좀더 명확하게 했으면 좋겠어요!
ex) DateLabelExtensions?
There was a problem hiding this comment.
타임피커는 대대적으로 개편이 필요할거 같아유.
언젠가.. 날잡고 수리한번 가겠습니다
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
app/src/main/java/com/sopt/clody/presentation/utils/extension/DateLabelExtension.kt (1)
7-9: Consider using consistent date/time libraries.The code mixes
kotlinx.datetime.Monthwithjava.time.format.TextStyleandjava.util.Locale. While this works, consider using a consistent approach - either stick with kotlinx-datetime or java.time throughout for better maintainability.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
app/src/main/java/com/sopt/clody/presentation/utils/extension/DateLabelExtension.kt(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
🔇 Additional comments (3)
app/src/main/java/com/sopt/clody/presentation/utils/extension/DateLabelExtension.kt (3)
11-12: LGTM!Clean and straightforward implementation using string resources for proper localization.
20-20: toLocalizedMonthLabel inputs are always in the valid 1–12 range – exception handling is not neededI checked every call site of
Int.toLocalizedMonthLabel()across the codebase:
- In
YearMonthPicker.kt,monthItemsis defined as(1..12)- In
HomeScreen.kt,DiaryListScreen.kt,WriteDiaryScreen.kt, andReplyDiaryScreen.kt, the month values all come from this picker or from view‐model state initialized by itSince
Month.of(this)only ever receives values 1 through 12, it cannot throw aDateTimeException. You can safely ignore adding extra exception handling here.Likely an incorrect or invalid review comment.
17-17: Improve locale language detection.The current check
locale.language == "ko"is too restrictive and won't handle locale variants like "ko-KR" or "ko-KP".Apply this diff to handle Korean locale variants:
- return if (locale.language == "ko") { + return if (locale.language.startsWith("ko")) {Likely an incorrect or invalid review comment.
| fun Int.toLocalizedMonthLabel(): String { | ||
| val locale = LocalContext.current.resources.configuration.locales[0] |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Add input validation and improve locale detection.
The function lacks input validation for the month parameter and has potential issues with locale detection.
Apply this diff to improve robustness:
@Composable
fun Int.toLocalizedMonthLabel(): String {
+ require(this in 1..12) { "Month must be between 1 and 12, got: $this" }
- val locale = LocalContext.current.resources.configuration.locales[0]
+ val locales = LocalContext.current.resources.configuration.locales
+ val locale = if (locales.isEmpty) Locale.getDefault() else locales[0]📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| fun Int.toLocalizedMonthLabel(): String { | |
| val locale = LocalContext.current.resources.configuration.locales[0] | |
| @Composable | |
| fun Int.toLocalizedMonthLabel(): String { | |
| require(this in 1..12) { "Month must be between 1 and 12, got: $this" } | |
| val locales = LocalContext.current.resources.configuration.locales | |
| val locale = if (locales.isEmpty) Locale.getDefault() else locales[0] | |
| // …rest of the logic… | |
| } |
🤖 Prompt for AI Agents
In
app/src/main/java/com/sopt/clody/presentation/utils/extension/DateLabelExtension.kt
at lines 15-16, the function toLocalizedMonthLabel lacks validation for the
integer input representing the month and may incorrectly detect the locale. Add
input validation to ensure the integer is within the valid month range (1 to
12). Also, improve locale detection by safely accessing the current locale,
considering backward compatibility and potential null values, to avoid runtime
exceptions.
app/src/main/java/com/sopt/clody/presentation/utils/extension/DateLabelExtension.kt
Outdated
Show resolved
Hide resolved
- 로케일을 불러오는 과정에서 안정성을 위한 디폴트값을 설정합니다. - YearMonthPicker 레이아웃을 조정합니다.

📌 ISSUE
closed #305
📄 Work Description
홈 화면 변경사항
일기쓰기 화면 변경사항
답장확인 화면 변경사항
알림설정 화면 변경사항
일기 모아보기 화면 변경사항
✨ PR Point
UI 쪽에서 언어 분기 처리를 진행하려고 하다보니 최대한 strings.xml 리소스를 활용하여 진행하려 했지만, 어쩔 수 없이 locale을 가져오는 부분이 생겼습니다. LaungeProvider로 일원화 하고싶었지만 녹록치가 않네요 ㅜㅜ
📸 ScreenShot/Video
Summary by CodeRabbit
New Features
Bug Fixes
Refactor
Style
Documentation