File tree 1 file changed +15
-1
lines changed
Sources/CoreUsefulSDK/Extensions
1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -58,9 +58,23 @@ public extension String {
58
58
59
59
/// Returns localized string.
60
60
var localized : String {
61
- return NSLocalizedString ( self , comment: self )
61
+ if NSLocalizedString ( self , comment: self ) . isEmpty {
62
+ return enLocalized
63
+ }
64
+ return NSLocalizedString ( self , comment: self )
65
+ }
66
+
67
+ /// returns localized string in english or empty string
68
+ var enLocalized : String {
69
+ if let enPath = Bundle . main. path ( forResource: " en " , ofType: " lproj " ) {
70
+ let enBundle = Bundle ( path: enPath)
71
+ return enBundle? . localizedString ( forKey: self , value: self , table: nil ) ?? " "
72
+ }
73
+ return " "
62
74
}
63
75
76
+
77
+
64
78
/// Returns attributed string
65
79
func attributed( with attributes: [ NSAttributedString . Key : Any ] ) -> NSAttributedString {
66
80
return NSMutableAttributedString ( string: self , attributes: attributes)
You can’t perform that action at this time.
0 commit comments