commit a1b1ce949b75f679d8f7f9883061cae48cce6549
parent 902e8c3950de17de94f7d4e93b3731eef6468d3f
Author: Terry Yiu <git@tyiu.xyz>
Date: Mon, 9 Dec 2024 20:42:45 -0500
Fix right-to-left localization issues
Changelog-Fixed: Fixed right-to-left localization issues
Signed-off-by: Terry Yiu <git@tyiu.xyz>
Diffstat:
2 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/damus/Util/LocalizationUtil.swift b/damus/Util/LocalizationUtil.swift
@@ -7,16 +7,12 @@
import Foundation
-func bundleForLocale(locale: Locale?) -> Bundle {
- if locale == nil {
- return Bundle.main
- }
-
- let path = Bundle.main.path(forResource: locale!.identifier, ofType: "lproj")
+func bundleForLocale(locale: Locale) -> Bundle {
+ let path = Bundle.main.path(forResource: locale.identifier, ofType: "lproj")
return path != nil ? (Bundle(path: path!) ?? Bundle.main) : Bundle.main
}
-func localizedStringFormat(key: String, locale: Locale?) -> String {
+func localizedStringFormat(key: String, locale: Locale) -> String {
let bundle = bundleForLocale(locale: locale)
let fallback = bundleForLocale(locale: Locale(identifier: "en-US")).localizedString(forKey: key, value: nil, table: nil)
return bundle.localizedString(forKey: key, value: fallback, table: nil)
diff --git a/damus/Views/Notifications/EventGroupView.swift b/damus/Views/Notifications/EventGroupView.swift
@@ -143,7 +143,7 @@ func event_group_unique_pubkeys(profiles: Profiles, group: EventGroupType) -> [P
"zapped_your_profile_2" - returned when 2 zaps occurred to the current user's profile
"zapped_your_profile_3" - returned when 3 or more zaps occurred to the current user's profile
*/
-func reacting_to_text(profiles: Profiles, our_pubkey: Pubkey, group: EventGroupType, ev: NostrEvent?, pubkeys: [Pubkey], locale: Locale? = nil) -> String {
+func reacting_to_text(profiles: Profiles, our_pubkey: Pubkey, group: EventGroupType, ev: NostrEvent?, pubkeys: [Pubkey], locale: Locale = Locale.current) -> String {
if group.events.count == 0 {
return "??"
}
@@ -188,7 +188,8 @@ struct EventGroupView: View {
let group: EventGroupType
func GroupDescription(_ pubkeys: [Pubkey]) -> some View {
- Text(verbatim: "\(reacting_to_text(profiles: state.profiles, our_pubkey: state.pubkey, group: group, ev: event, pubkeys: pubkeys))")
+ let text = reacting_to_text(profiles: state.profiles, our_pubkey: state.pubkey, group: group, ev: event, pubkeys: pubkeys)
+ return Text(text)
}
func ZapIcon(_ zapgrp: ZapGroup) -> some View {