Warning, /network/kdeconnect-ios/KDE Connect/KDE Connect/Swift Backend/LocalizedStringKey+Extensions.swift is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: 2021 Lucas Wang <lucas.wang@tuta.io> 0003 * SPDX-FileCopyrightText: 2022 Claudio Cambra <claudio.cambra@gmail.com> 0004 * 0005 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0006 */ 0007 0008 // 0009 // LocalizedStringKey+Extensions.swift 0010 // KDE Connect 0011 // 0012 // Created by Claudio Cambra on 25/5/22. 0013 // 0014 0015 import Foundation 0016 import SwiftUI 0017 0018 extension LocalizedStringKey.StringInterpolation { 0019 mutating func appendInterpolation(percent: Int) { 0020 if #available(iOS 15, *) { 0021 appendInterpolation(Double(percent) / 100, format: .percent) 0022 } else { 0023 appendInterpolation(Double(percent) / 100 as NSNumber, formatter: NumberFormatter.percentage) 0024 } 0025 } 0026 } 0027 0028 fileprivate extension NumberFormatter { 0029 static let percentage: NumberFormatter = { 0030 let formatter = NumberFormatter() 0031 formatter.numberStyle = .percent 0032 return formatter 0033 }() 0034 }