mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
Various UI fixes
This commit is contained in:
@@ -2,18 +2,36 @@ import Foundation
|
||||
|
||||
public enum ArabicNumeralStringType {
|
||||
case western
|
||||
case eastern
|
||||
case arabic
|
||||
case persian
|
||||
}
|
||||
|
||||
public func normalizeArabicNumeralString(_ string: String, type: ArabicNumeralStringType) -> String {
|
||||
var string = string
|
||||
let numerals = ["٠": "0", "١": "1", "٢": "2", "٣": "3", "٤": "4", "٥": "5", "٦": "6", "٧": "7", "٨": "8", "٩": "9"]
|
||||
for (easternNumeral, westernNumeral) in numerals {
|
||||
|
||||
let numerals = [
|
||||
("0", "٠", "۰"),
|
||||
("1", "١", "۱"),
|
||||
("2", "٢", "۲"),
|
||||
("3", "٣", "۳"),
|
||||
("4", "٤", "۴"),
|
||||
("5", "٥", "۵"),
|
||||
("6", "٦", "۶"),
|
||||
("7", "٧", "۷"),
|
||||
("8", "٨", "۸"),
|
||||
("9", "٩", "۹"),
|
||||
]
|
||||
for (western, arabic, persian) in numerals {
|
||||
switch type {
|
||||
case .western:
|
||||
string = string.replacingOccurrences(of: easternNumeral, with: westernNumeral)
|
||||
case .eastern:
|
||||
string = string.replacingOccurrences(of: westernNumeral, with: easternNumeral)
|
||||
string = string.replacingOccurrences(of: arabic, with: western)
|
||||
string = string.replacingOccurrences(of: persian, with: western)
|
||||
case .arabic:
|
||||
string = string.replacingOccurrences(of: western, with: arabic)
|
||||
string = string.replacingOccurrences(of: persian, with: arabic)
|
||||
case .persian:
|
||||
string = string.replacingOccurrences(of: western, with: persian)
|
||||
string = string.replacingOccurrences(of: arabic, with: persian)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user