Various UI fixes

This commit is contained in:
Ilya Laktyushin
2019-09-02 21:30:09 +03:00
parent e4a472f246
commit 7d2e62fcce
85 changed files with 4488 additions and 4289 deletions

View File

@@ -1,10 +1,21 @@
import Foundation
public func convertToArabicNumeralString(_ string: String) -> String {
public enum ArabicNumeralStringType {
case western
case eastern
}
public func normalizeArabicNumeralString(_ string: String, type: ArabicNumeralStringType) -> String {
var string = string
let arabicNumbers = ["٠": "0", "١": "1", "٢": "2", "٣": "3", "٤": "4", "٥": "5", "٦": "6", "٧": "7", "٨": "8", "٩": "9"]
for (arabic, generic) in arabicNumbers {
string = string.replacingOccurrences(of: generic, with: arabic)
let numerals = ["٠": "0", "١": "1", "٢": "2", "٣": "3", "٤": "4", "٥": "5", "٦": "6", "٧": "7", "٨": "8", "٩": "9"]
for (easternNumeral, westernNumeral) in numerals {
switch type {
case .western:
string = string.replacingOccurrences(of: easternNumeral, with: westernNumeral)
case .eastern:
string = string.replacingOccurrences(of: westernNumeral, with: easternNumeral)
}
}
return string
}