Files
pos-system/apps/app-client-base-swift/smoke-tests/Sources/AppClientBaseSwiftSmoke/LocalizationManifest.swift
2026-02-23 13:15:02 +00:00

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 dn tương đi t package root đến tài nguyên ng dng.
public static let resourcesRelativePath = "../AppClientBaseSwift/AppClientBaseSwift/Resources"
/// EN: Build absolute path to Localizable.strings for a locale.
/// VI: To đưng dn tuyt đi ti 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: Kim tra file locale có tn ti hay không.
public static func hasLocale(_ locale: String, fileManager: FileManager = .default) -> Bool {
fileManager.fileExists(atPath: localizableFilePath(for: locale))
}
}