-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// String+Core.swift | ||
// CoreModule | ||
// | ||
// Created by Maksim Ivanov on 19.10.2023. | ||
// | ||
|
||
import Foundation | ||
|
||
extension String { | ||
|
||
public func stripOutTags() -> String { | ||
self.replacingOccurrences(of: "<[^>]+>", with: "", options: .regularExpression, range: nil) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// LocalizableStringKey.swift | ||
// CoreModule | ||
// | ||
// Created by Maxim Ivanov on 23.10.2023. | ||
// | ||
|
||
import UIKit | ||
|
||
/* | ||
A type to work with locale-dependent strings. | ||
It accepts a string key (universal for any locale) and allows to get a localized string from module resources. | ||
*/ | ||
public struct LocalizableStringKey: Equatable, CustomStringConvertible { | ||
|
||
public let key: String | ||
|
||
private let bundle: Bundle | ||
|
||
public init(_ key: String, bundle: Bundle) { | ||
self.key = key | ||
self.bundle = bundle | ||
} | ||
|
||
public static func == (_ lhs: LocalizableStringKey, _ rhs: LocalizableStringKey) -> Bool { | ||
lhs.key == rhs.key | ||
} | ||
|
||
public var localizedString: String { | ||
bundle.moduleLocalizedString(key) | ||
} | ||
|
||
public var description: String { | ||
"LocalizableStringKey(\(key))" | ||
} | ||
} |