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

This commit is contained in:
Yu Sung
2025-12-19 14:20:47 +09:00
parent f51fe327e9
commit bea50b0085
5 changed files with 147 additions and 2 deletions

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: "すべて見る") }