[REFACTOR/#283] 하드코딩된 문자열 리소스를 추출하여 i18n 적용 준비 합니다.#284
Conversation
WalkthroughThis update removes hardcoded UI strings throughout the codebase, replacing them with references to localized string resources to support internationalization. It introduces utility functions for localized year/month labels, adds a Changes
Sequence Diagram(s)sequenceDiagram
participant UI as Composable UI
participant Resources as String Resources
participant Utils as Extension/Enum Utils
UI->>Resources: Fetch localized string via stringResource()
UI->>Utils: Call TimePeriod.getLabel() or toLocalizedYearLabel()
Utils->>Resources: Fetch corresponding string resource
UI->>UI: Display localized text in UI components
Assessment against linked issues
Assessment against linked issues: Out-of-scope changes
Suggested labels
Poem
✨ 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: 1
📜 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/component/button/NextButton.kt(0 hunks)app/src/main/java/com/sopt/clody/presentation/ui/auth/component/timepicker/BottomSheetTimePicker.kt(5 hunks)app/src/main/java/com/sopt/clody/presentation/ui/auth/signup/page/NicknamePage.kt(3 hunks)app/src/main/java/com/sopt/clody/presentation/ui/auth/timereminder/TimeReminderScreen.kt(4 hunks)app/src/main/java/com/sopt/clody/presentation/ui/auth/timereminder/TimeReminderViewModel.kt(2 hunks)app/src/main/java/com/sopt/clody/presentation/ui/component/bottomsheet/DiaryDeleteSheet.kt(2 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/home/calendar/component/DailyDiaryListItem.kt(4 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/CloverCount.kt(1 hunks)app/src/main/java/com/sopt/clody/presentation/ui/home/component/DiaryStateButton.kt(6 hunks)app/src/main/java/com/sopt/clody/presentation/ui/home/component/YearAndMonthTitle.kt(3 hunks)app/src/main/java/com/sopt/clody/presentation/ui/home/screen/HomeScreen.kt(8 hunks)app/src/main/java/com/sopt/clody/presentation/ui/replyloading/component/QuickReplyAdButton.kt(2 hunks)app/src/main/java/com/sopt/clody/presentation/ui/splash/SplashScreen.kt(3 hunks)app/src/main/java/com/sopt/clody/presentation/ui/writediary/component/bottomsheet/DeleteWriteDiaryBottomSheet.kt(2 hunks)app/src/main/java/com/sopt/clody/presentation/ui/writediary/component/button/AddDiaryEntryFAB.kt(2 hunks)app/src/main/java/com/sopt/clody/presentation/ui/writediary/component/button/SendButton.kt(2 hunks)app/src/main/java/com/sopt/clody/presentation/ui/writediary/component/textfield/WriteDiaryTextField.kt(3 hunks)app/src/main/java/com/sopt/clody/presentation/utils/extension/TimePeriod.kt(1 hunks)app/src/main/java/com/sopt/clody/presentation/utils/extension/YearMonthLabelUtil.kt(1 hunks)app/src/main/res/values/strings.xml(5 hunks)
💤 Files with no reviewable changes (1)
- app/src/main/java/com/sopt/clody/presentation/ui/auth/component/button/NextButton.kt
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build
🔇 Additional comments (67)
app/src/main/java/com/sopt/clody/presentation/utils/extension/TimePeriod.kt (2)
8-11: Use of enum with resource IDs is correct
TheTimePeriodenum centralizes AM/PM labels and ensures type safety via@StringRes.
13-15: Composable label retrieval is appropriate
UsingstringResource(labelResId)in a@Composablefunction cleanly abstracts localization.app/src/main/java/com/sopt/clody/presentation/ui/writediary/component/button/AddDiaryEntryFAB.kt (2)
26-26: Import forstringResourceadded
Required import to support localized string lookups in Compose.
89-89: Localized FAB label applied
Replacing the hardcoded"추가하기"withstringResource(R.string.write_diary_add_entry_fab)aligns with i18n goals.Ensure that
R.string.write_diary_add_entry_fabis defined across all relevantstrings.xmllocales.app/src/main/java/com/sopt/clody/presentation/ui/writediary/component/bottomsheet/DeleteWriteDiaryBottomSheet.kt (2)
21-21: Import forstringResourceadded
Needed to resolve localized text in the delete button.
64-64: Localized delete button text applied
UsingstringResource(R.string.bottom_sheet_delete_button)removes hardcoded text and supports localization.Confirm that
bottom_sheet_delete_buttonexists in allstrings.xmlvariants.app/src/main/java/com/sopt/clody/presentation/ui/replyloading/component/QuickReplyAdButton.kt (2)
17-17: Import forstringResourceadded
Import aligns with replacing hardcoded button text.
44-44: Localized ad button text applied
Replacing the literal withstringResource(R.string.loading_button_watch_ad_and_get_reply)supports i18n.Verify that
loading_button_watch_ad_and_get_replyis present in all locale files.app/src/main/java/com/sopt/clody/presentation/ui/component/bottomsheet/DiaryDeleteSheet.kt (2)
21-21: Import forstringResourceadded
Enables use of localized resources for delete sheet text.
75-75: Localized delete sheet text applied
stringResource(R.string.bottom_sheet_delete_button)replaces the hardcoded label.Ensure
bottom_sheet_delete_buttonis defined in all required locales.app/src/main/java/com/sopt/clody/presentation/ui/home/component/CloverCount.kt (2)
13-13: Proper imports added for string resource support.Good addition of the necessary imports to support localized string resources.
Also applies to: 16-16
21-21: Excellent string resource implementation with parameter formatting.The hardcoded string concatenation has been properly replaced with a parameterized string resource call, which correctly supports localization and maintains the dynamic clover count value.
app/src/main/java/com/sopt/clody/presentation/ui/home/component/YearAndMonthTitle.kt (3)
15-15: Proper import added for string resource support.Good addition of the stringResource import to support localized strings.
26-26: Excellent parameterized string resource implementation.The hardcoded string interpolation has been properly replaced with a parameterized string resource call that maintains the dynamic year and month values while supporting localization.
45-45: Nice formatting cleanup.Good consolidation of the padding modifier parameters into a single line for better readability.
app/src/main/java/com/sopt/clody/presentation/ui/writediary/component/button/SendButton.kt (2)
14-14: Proper imports added for string resource support.Good addition of the necessary imports to support localized string resources.
Also applies to: 16-16
38-38: Clean string resource implementation.The hardcoded Korean string has been properly replaced with a string resource call, supporting localization without changing the component's functionality.
app/src/main/java/com/sopt/clody/presentation/ui/writediary/component/textfield/WriteDiaryTextField.kt (3)
33-33: Proper import added for string resource support.Good addition of the stringResource import to support localized strings.
134-134: Excellent placeholder text localization.The hardcoded Korean placeholder text has been properly replaced with a string resource, improving localization support for the text field hint.
169-169: Good warning message localization.The hardcoded Korean warning message has been properly replaced with a string resource, ensuring consistent localization support for error messages.
app/src/main/java/com/sopt/clody/presentation/ui/auth/signup/page/NicknamePage.kt (4)
23-23: Proper import added for string resource support.Good addition of the stringResource import to support localized strings.
89-89: Good button text localization.The hardcoded Korean button text has been properly replaced with a string resource, improving localization support for the action button.
102-102: Excellent title text localization.The hardcoded Korean title has been properly replaced with a string resource, ensuring the page title supports localization.
107-107: Good input hint localization.The hardcoded Korean input hint has been properly replaced with a string resource, providing consistent localization support for user guidance text.
app/src/main/java/com/sopt/clody/presentation/ui/home/screen/HomeScreen.kt (6)
26-26: LGTM: Essential import for i18n refactoring.Added stringResource import to support the string externalization throughout the file.
175-213: Excellent i18n implementation for the draft popup.All hardcoded Korean strings in the popup have been systematically replaced with stringResource() calls, maintaining the same functionality while enabling proper localization support.
224-224: Toast message properly externalized.The draft alarm toast message is now using string resources for better i18n support.
240-254: Continue draft dialog properly localized.All dialog text elements (title, description, confirm/dismiss options) have been converted to use string resources consistently.
269-287: Delete diary dialog consistently localized.Dialog text elements follow the same pattern as other dialogs, ensuring consistent i18n implementation across the UI.
378-378: Error messages properly externalized.Both calendar state and delete diary error messages now use string resources, providing fallback for unknown errors where appropriate.
Also applies to: 393-393
app/src/main/java/com/sopt/clody/presentation/ui/home/calendar/component/DailyDiaryListItem.kt (3)
21-21: Import added for string resource support.Essential import for the i18n refactoring changes in this file.
56-59: Excellent use of parameterized string resources.The day of week formatting properly uses a string resource with parameter substitution, demonstrating best practice for localized text formatting.
83-83: User messages properly localized.Both the draft presence message and empty diary list message are now using string resources for proper i18n support.
Also applies to: 99-99
app/src/main/java/com/sopt/clody/presentation/ui/home/component/DiaryStateButton.kt (2)
7-9: Required imports for string resource usage.Added necessary imports to support string externalization throughout the component.
34-34: Complete button text localization.All button text strings across different diary states (draft, invalid draft, reply available, write available) have been systematically converted to use string resources, ensuring consistent i18n support.
Also applies to: 43-43, 54-54, 63-63, 72-72
app/src/main/java/com/sopt/clody/presentation/ui/splash/SplashScreen.kt (3)
20-20: Import added for string localization.Essential import for the dialog string externalization.
124-140: Soft update dialog properly localized.All dialog elements (title, message with version parameter, confirm/dismiss buttons) are now using string resources for proper i18n support.
152-165: Hard update dialog consistently localized.Dialog text elements follow the same localization pattern. Note the reuse of
soft_update_confirmstring resource for the hard update confirm button, which is appropriate if the button text is identical.app/src/main/java/com/sopt/clody/presentation/ui/auth/component/timepicker/BottomSheetTimePicker.kt (5)
31-31: Excellent type safety improvement with TimePeriod enum.The import and callback parameter change from raw String to TimePeriod enum significantly improves type safety and prevents potential AM/PM string-related bugs.
Also applies to: 37-37
79-80: Well-designed enum to label mapping.Creates a clean separation between enum values and their localized display labels, enabling proper i18n while maintaining type safety.
103-103: Proper use of localized labels in picker.The picker now displays localized AM/PM labels instead of hardcoded strings, supporting proper internationalization.
132-137: Robust label-to-enum conversion.The implementation correctly converts selected labels back to TimePeriod enum values with a sensible fallback to TimePeriod.PM, preventing potential crashes from unexpected selections.
140-140: Button text properly localized.Consistent with the overall i18n effort, the button text now uses string resources.
app/src/main/java/com/sopt/clody/presentation/ui/auth/timereminder/TimeReminderViewModel.kt (1)
82-96: Excellent refactoring to improve type safety and localization.The migration from string-based AM/PM handling to the
TimePeriodenum is a significant improvement:
- Type safety prevents runtime errors from invalid period strings
- The time conversion logic correctly handles 12-hour to 24-hour format
- Using
Locale.USensures consistent formatting regardless of device localeapp/src/main/java/com/sopt/clody/presentation/utils/extension/YearMonthLabelUtil.kt (1)
7-16: Well-designed utility for localized date labels.The utility provides a clean API for localized year/month formatting:
- Extension functions offer intuitive usage
- Proper use of
stringResourcefor i18n support- Constants centralize the valid year range
Consider if the 2030 upper limit might need adjustment for long-term usage, but the current range seems appropriate for most use cases.
app/src/main/java/com/sopt/clody/presentation/ui/auth/timereminder/TimeReminderScreen.kt (2)
105-110: Consistent adoption of TimePeriod enum improves type safety.The callback functions correctly use the
TimePeriodenum instead of raw strings, maintaining consistency with the ViewModel changes and improving compile-time safety.
187-192: Proper localization of time display format.The time display now uses
stringResourcewith thegetLabel()method fromTimePeriod, providing proper i18n support while maintaining readable formatting.app/src/main/java/com/sopt/clody/presentation/ui/component/timepicker/YearMonthPicker.kt (2)
42-50: Robust refactoring to integer-based year/month handling.The transition from string-based to integer-based lists is a significant improvement:
- More reliable data handling without string parsing
- Proper bounds checking with
coerceAtLeast(0)- Clean separation between data model (integers) and presentation (localized labels)
91-92: Excellent localization implementation with proper data mapping.The approach correctly:
- Maps integers to localized labels for display
- Maps selected labels back to integers for the callback
- Maintains data integrity throughout the selection process
Also applies to: 131-133
app/src/main/java/com/sopt/clody/presentation/ui/home/calendar/component/WeekHeader.kt (1)
56-72: Approve the dynamic label generation approach.The component structure correctly supports dynamic language selection and provides a clean API for weekday display customization.
app/src/main/res/values/strings.xml (17)
4-9: Soft update dialog strings added for localizationThe new
soft_update_*entries correctly externalize the dialog title, message with placeholder, and button labels. Placeholder syntax and newline escape are valid.
11-14: Hard update dialog strings added for localizationThe
hard_update_*entries mirror the soft-update pattern for forced upgrades. Placeholder usage is correct.
20-24: Onboarding nickname prompt strings extractedThe nickname title, hint, and next-button labels are now localized. Use of
\nfor line breaks aligns with Android conventions.
67-67: Loading screen ad-watch button string added
loading_button_watch_ad_and_get_replyexternalizes the newly introduced ad-watch flow label.
117-117: Diary list reply-check action string addedThe
diarylist_check_replystring covers the new “답장 확인” button in the diary list item.
118-121: Daily diary formatting strings addedNew draft/empty state messages and item/day-of-week formats are correctly parameterized.
123-125: Home screen clover and date format strings addedThe
home_clover_count_formatandhome_year_and_month_formatentries externalize dynamic counts and dates.
127-131: Home action buttons localizedNew keys for continue draft, check reply, and write diary buttons are in place.
132-135: Home error messages externalizedAll three error messages for data-load, unknown, and delete-diary flows are now localized.
137-142: Home draft-popup strings addedTitle, description, guide, and button labels for the draft reminder popup are parameterized correctly.
144-145: Home draft alarm toast string addedThe completion toast message for draft-alarm setup is now in resources.
147-151: Continue-draft dialog strings addedDialog title, description, and button labels for resuming drafts are localized.
153-157: Delete-diary confirmation dialog strings addedThe home screen’s delete-diary dialog entries are now in the string resources.
159-160: Accessibility label for month chooser added
home_icon_choose_monthprovides a content description for the month-picker icon.
206-209: Common component strings for bottom sheet and pickerEntries for delete button and year-month picker labels (
bottom_sheet_delete_button,year_month_picker_*) are correctly extracted.
211-214: Time format strings for AM/PM and reminders added
time_am,time_pm, andtime_reminder_time_formatenable localized time-period labels and formatting.
216-217: Year and month format strings addedStandalone
year_formatandmonth_formatentries support the picker utilities.
| 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() | ||
| } | ||
| } |
There was a problem hiding this comment.
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.
SYAAINN
left a comment
There was a problem hiding this comment.
수고하셨습니다! 이제 남은것은 영어버전 구현뿐 ㅋㅋ
There was a problem hiding this comment.
[p4]
스트링 추출 후에 다국어 지원으로 가는 방향이 아니라 이 방식으로 진행한 이유가 따로 있나요?
한국어, 한자, 영어를 제외하고 다른 방법 쓸 일이 있을까 싶긴한데 다국어 관련해서 추가 사항이 있으면 항상 이렇게 따로 추가해야 하는게 번거로울 수도 있지 않을까하는 생각이 드네요. 스트링 추출해서 언어 지원을 바꾸는 걸로 전부 대응하려는게 너무 딸깍적 사고일까요 ㅋㅋ
There was a problem hiding this comment.
딱히 특별한 이유는 없고, EN/KR 두 가지 label만 가볍게 다룰 목적이었습니다.
중국어나 일본어 같은 건 고려하지 않았고, 기존 구조가 toKoreanShortLabel() 함수를 이미 사용하고 있어서 영어만 extension으로 자연스럽게 추가한 형태입니다.
📌 ISSUE
closed #283
📄 Work Description
TimePeriodenum을 활용하도록 변경하였고, enum 내부에@Composable fun getLabel()을 정의해 리소스를 통해 라벨을 가져오도록 리팩터링했습니다.WeekHeader컴포넌트에WeekLangenum을 도입하여, 요일 라벨을 한글/영어로 선택적으로 보여줄 수 있도록 구조 개선했습니다.YearMonthPicker의 연도와 월 텍스트를 상수(MIN_YEAR,MAX_YEAR)와 확장 함수(toYearLabel(),parseYear()등)를 활용하는 방식으로 재구성했습니다.✨ PR Point
정규식(text\s*=\s*"[^"]+", Text(\s*"[^"]+")을 통한 하드코드 된 파일 탐색 후 제거
📸 ScreenShot/Video
Summary by CodeRabbit
New Features
Bug Fixes
Refactor
Documentation