30 lines
1.3 KiB
Swift
30 lines
1.3 KiB
Swift
import Foundation
|
|
|
|
/// EN: Localization resource smoke-test helper.
|
|
/// VI: Helper smoke-test cho tài nguyên localization.
|
|
public enum LocalizationManifest {
|
|
/// EN: Relative path from package root to app resources.
|
|
/// VI: Đường dẫn tương đối từ package root đến tài nguyên ứng dụng.
|
|
public static let resourcesRelativePath = "../AppClientBaseSwift/AppClientBaseSwift/Resources"
|
|
|
|
/// EN: Build absolute path to Localizable.strings for a locale.
|
|
/// VI: Tạo đường dẫn tuyệt đối tới Localizable.strings theo locale.
|
|
public static func localizableFilePath(
|
|
for locale: String,
|
|
currentDirectoryPath: String = FileManager.default.currentDirectoryPath
|
|
) -> String {
|
|
let localeFolder = "\(locale).lproj"
|
|
return URL(fileURLWithPath: currentDirectoryPath)
|
|
.appendingPathComponent(resourcesRelativePath)
|
|
.appendingPathComponent(localeFolder)
|
|
.appendingPathComponent("Localizable.strings")
|
|
.path
|
|
}
|
|
|
|
/// EN: Check if a locale file exists.
|
|
/// VI: Kiểm tra file locale có tồn tại hay không.
|
|
public static func hasLocale(_ locale: String, fileManager: FileManager = .default) -> Bool {
|
|
fileManager.fileExists(atPath: localizableFilePath(for: locale))
|
|
}
|
|
}
|