- fix crash when Chinese (Simplified) language of macos (macos build number error)

- add Chinese and Turkish translation contributors to README
This commit is contained in:
Serhiy Mytrovtsiy
2020-09-01 19:04:41 +02:00
parent 766ebdae9a
commit 1ab1d5ffe4
2 changed files with 13 additions and 8 deletions

View File

@@ -37,8 +37,8 @@ Stats is an application that allows you to monitor your macOS system.
- Polski
- Український
- Русский
- 中文(简体)
- Türkçe
- 中文(简体)(thanks to [chenguokai](https://github.com/chenguokai))
- Türkçe (thanks to [yusufozgul](https://github.com/yusufozgul))
You can help by adding a new language.

View File

@@ -69,7 +69,7 @@ public struct info_s {
}
public struct device_s {
public var model: model_s = model_s(name: "Unknown", year: 2020, type: .unknown)
public var model: model_s = model_s(name: LocalizedString("Unknown"), year: 2020, type: .unknown)
public var os: os_s? = nil
public var info: info_s? = info_s()
}
@@ -87,13 +87,18 @@ public class SystemKit {
os_log(.error, log: self.log, "unknown device %s", modelName)
}
}
let procInfo = ProcessInfo()
let systemVersion = procInfo.operatingSystemVersion
let build = procInfo.operatingSystemVersionString.split(separator: "(")[1].replacingOccurrences(of: "Build ", with: "").replacingOccurrences(of: ")", with: "")
self.device.os = os_s(name: osDict[systemVersion.minorVersion] ?? "Unknown", version: systemVersion, build: build)
var build = LocalizedString("Unknown")
let buildArr = procInfo.operatingSystemVersionString.split(separator: "(")
if buildArr.indices.contains(1) {
build = buildArr[1].replacingOccurrences(of: "Build ", with: "").replacingOccurrences(of: ")", with: "")
}
self.device.os = os_s(name: osDict[systemVersion.minorVersion] ?? LocalizedString("Unknown"), version: systemVersion, build: build)
self.device.info?.cpu = self.getCPUInfo()
self.device.info?.ram = self.getRamInfo()
self.device.info?.gpu = self.getGPUInfo()