Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
60 changes: 30 additions & 30 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 13 additions & 4 deletions Sources/FOSMVVM/Localization/LocalizableDate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@ public struct LocalizableDate: Codable, Hashable, Comparable, LocalizableValue,
timeStyle: DateFormatter.Style? = nil,
dateFormat: String? = nil
) {
let defaultStyle: DateFormatter.Style? = (dateStyle == nil && timeStyle == nil && dateFormat == nil)
? DateFormatter.Style.medium
: nil

self.init(
value: value,
dateStyle: dateStyle,
dateStyle: dateStyle ?? defaultStyle,
timeStyle: timeStyle,
dateFormat: dateFormat,
localizedString: nil
Expand Down Expand Up @@ -91,9 +95,14 @@ public extension LocalizableDate {
try container.encodeIfPresent(timeStyle?.rawValue, forKey: .timeStyle)
try container.encodeIfPresent(dateFormat, forKey: .dateFormat)

// REVIEWED: DGH - The RHS of this ternary will never be executed, so a block
// will never be covered
try container.encode(encoder.localizeString(self) ?? "", forKey: .localizedString)
// If we've already been localized, just send that
if let _localizedString {
try container.encode(_localizedString, forKey: .localizedString)
} else {
// REVIEWED: DGH - The RHS of this ternary will never be executed, so a block
// will never be covered
try container.encode(encoder.localizeString(self) ?? "", forKey: .localizedString)
}
}

// MARK: Identifiable Protocol
Expand Down
11 changes: 8 additions & 3 deletions Sources/FOSMVVM/Localization/LocalizableInt.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,14 @@ public extension LocalizableInt {
try container.encode(showGroupingSeparator, forKey: .showGroupingSeparator)
try container.encode(groupingSize, forKey: .groupingSize)

// REVIEWED: DGH - The RHS of this ternary will never be executed, so a block
// will never be covered
try container.encode(encoder.localizeString(self) ?? "", forKey: .localizedString)
// If we've already been localized, just send that
if let _localizedString {
try container.encode(_localizedString, forKey: .localizedString)
} else {
// REVIEWED: DGH - The RHS of this ternary will never be executed, so a block
// will never be covered
try container.encode(encoder.localizeString(self) ?? "", forKey: .localizedString)
}
}

// MARK: Identifiable Protocol
Expand Down
Loading