Skip to content

Commit

Permalink
CoreModule v2.6.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
maksimn committed Nov 8, 2023
1 parent 5a5b9be commit a8f9514
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Source/Foundation+Core/String+Core.swift
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)
}
}
36 changes: 36 additions & 0 deletions Source/LocalizableStringKey.swift
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))"
}
}

0 comments on commit a8f9514

Please sign in to comment.