Local+Extension.swift 765 Bytes
Newer Older
domenicw's avatar
domenicw committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//
//  Local+Extension.swift
//  Amiv
//
//  Created by Domenic Wüthrich on 12.10.18.
//  Copyright © 2018 Amiv an der ETH. All rights reserved.
//

import Foundation

public extension Locale {
    
    public enum AppLanguage {
        case german
        case english
    }
    
    public static func current() -> AppLanguage {
        if ["de-DE", "de-CH", "de-AT", "de-LI", "de-LU"].contains(Locale.current.languageCode) {
            return .german
        } else {
            return .english
        }
    }
    
    public static func getLocalizedString(english: String, german: String) -> String {
        switch Locale.current() {
        case .english:
            return english
        case .german:
            return german
        }
    }
    
}