커뮤니티 게시글 상대 시간 표기 다국어 지원

This commit is contained in:
Yu Sung
2025-12-19 16:02:09 +09:00
parent f51fe327e9
commit bea50b0085
5 changed files with 147 additions and 2 deletions
+45
View File
@@ -11,6 +11,51 @@ import Foundation
// String Catalog를 사용하지 않는 컨텍스트에서 사용할 하드코딩 맵 기반 i18n.
// 기준 언어 선택은 LanguageHeaderProvider.current("ko"|"en"|"ja").
enum I18n {
enum Time {
static var justNow: String {
pick(ko: "방금 전", en: "Just now", ja: "たった今")
}
static func minutesAgo(_ minutes: Int) -> String {
pick(
ko: "\(minutes)분 전",
en: "\(minutes) minute\(minutes == 1 ? "" : "s") ago",
ja: "\(minutes)分前"
)
}
static func hoursAgo(_ hours: Int) -> String {
pick(
ko: "\(hours)시간 전",
en: "\(hours) hour\(hours == 1 ? "" : "s") ago",
ja: "\(hours)時間前"
)
}
static func daysAgo(_ days: Int) -> String {
pick(
ko: "\(days)일 전",
en: "\(days) day\(days == 1 ? "" : "s") ago",
ja: "\(days)日前"
)
}
static func monthsAgo(_ months: Int) -> String {
pick(
ko: "\(months)개월 전",
en: "\(months) month\(months == 1 ? "" : "s") ago",
ja: "\(months)か月前"
)
}
static func yearsAgo(_ years: Int) -> String {
pick(
ko: "\(years)년 전",
en: "\(years) year\(years == 1 ? "" : "s") ago",
ja: "\(years)年前"
)
}
}
enum Common {
static var viewAll: String { pick(ko: "전체보기", en: "View all", ja: "すべて見る") }