Skip to content

Commit a8f9514

Browse files
committed
CoreModule v2.6.0.
1 parent 5a5b9be commit a8f9514

2 files changed

Lines changed: 51 additions & 0 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// String+Core.swift
3+
// CoreModule
4+
//
5+
// Created by Maksim Ivanov on 19.10.2023.
6+
//
7+
8+
import Foundation
9+
10+
extension String {
11+
12+
public func stripOutTags() -> String {
13+
self.replacingOccurrences(of: "<[^>]+>", with: "", options: .regularExpression, range: nil)
14+
}
15+
}

Source/LocalizableStringKey.swift

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//
2+
// LocalizableStringKey.swift
3+
// CoreModule
4+
//
5+
// Created by Maxim Ivanov on 23.10.2023.
6+
//
7+
8+
import UIKit
9+
10+
/*
11+
A type to work with locale-dependent strings.
12+
It accepts a string key (universal for any locale) and allows to get a localized string from module resources.
13+
*/
14+
public struct LocalizableStringKey: Equatable, CustomStringConvertible {
15+
16+
public let key: String
17+
18+
private let bundle: Bundle
19+
20+
public init(_ key: String, bundle: Bundle) {
21+
self.key = key
22+
self.bundle = bundle
23+
}
24+
25+
public static func == (_ lhs: LocalizableStringKey, _ rhs: LocalizableStringKey) -> Bool {
26+
lhs.key == rhs.key
27+
}
28+
29+
public var localizedString: String {
30+
bundle.moduleLocalizedString(key)
31+
}
32+
33+
public var description: String {
34+
"LocalizableStringKey(\(key))"
35+
}
36+
}

0 commit comments

Comments
 (0)