mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-11-23 11:35:19 +01:00
66f30d4dc0
Added Serbian translation by crusher and Indonesian bu Badruzeus. Changing boot1 boot sectors installation to use boo1-intsall only. Rework on how the nvram get dumped for CloverEFI.
59 lines
1.3 KiB
Swift
59 lines
1.3 KiB
Swift
//
|
|
// Locale.swift
|
|
// Clover
|
|
//
|
|
// Created by vector sigma on 17/11/2019.
|
|
// Copyright © 2019 CloverHackyColor. All rights reserved.
|
|
//
|
|
|
|
import Cocoa
|
|
|
|
extension String {
|
|
var locale: String {
|
|
get {
|
|
let preferred : [String] = Bundle.main.preferredLocalizations
|
|
var table : String = "en"
|
|
if preferred.count > 0 {
|
|
table = preferred[0]
|
|
}
|
|
|
|
var result = localeBundle?.localizedString(forKey: self, value: nil, table: table)
|
|
|
|
if result == self {
|
|
result = localeBundle?.localizedString(forKey: self, value: nil, table: "en")
|
|
}
|
|
return (result != nil) ? result! : self
|
|
}
|
|
}
|
|
|
|
public func locale(_ localized: Bool) -> String {
|
|
return (localized ? self.locale : self)
|
|
}
|
|
}
|
|
|
|
// MARK: localize view and sub views
|
|
func localize(view: NSView) {
|
|
for o in view.subviews {
|
|
if o is NSButton {
|
|
let x = (o as! NSButton)
|
|
if x.title.count > 0 {
|
|
x.title = x.title.locale
|
|
}
|
|
} else if o is NSTextField {
|
|
let x = (o as! NSTextField)
|
|
if x.stringValue.count > 0 {
|
|
x.stringValue = x.stringValue.locale
|
|
}
|
|
} else if o is NSBox {
|
|
let x = (o as! NSBox)
|
|
if x.title.count > 0 {
|
|
x.title = x.title.locale
|
|
}
|
|
}
|
|
|
|
if o.subviews.count > 0 {
|
|
localize(view: o)
|
|
}
|
|
}
|
|
}
|