Settings.swift 1.21 KB
Newer Older
Grigor Aghabalyan's avatar
Grigor Aghabalyan committed
1
2
3
4
5
6
7
8
9
10
//
//  Settings.swift
//  App16
//
//  Created by Grigor Aghabalyan on 3/25/20.
//  Copyright © 2020 X-TECH. All rights reserved.
//

import Foundation
import CoreLocation
Grigor Aghabalyan's avatar
Grigor Aghabalyan committed
11
import Localize_Swift
Grigor Aghabalyan's avatar
Grigor Aghabalyan committed
12
13
14
15
16
17
18

struct Settings {
    
    enum YEREVAN: Double {
        case latitude = 40.178576
        case longitude = 44.511739
    }
Grigor Aghabalyan's avatar
Grigor Aghabalyan committed
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
    
    enum Languages: String {
        case Armenian = "hy"
        case English = "en"
        case Russian = "ru"
    }
    
    static func changeLanguage(_ code: String, langauge: String) {
        
        Settings.language = code
        Localize.setCurrentLanguage(Settings.language)
        
        UserDefaultsHelper.set(alias: .locale, value: code)
        UserDefaultsHelper.set(alias: .langauge, value: langauge)
        UserDefaults.standard.set(code, forKey: "language")
        UserDefaults.standard.synchronize()
    }
    
    static var language: String! {
        set(token) {
            let defaults = Foundation.UserDefaults.standard
            defaults.set(token, forKey: "User.Language")
        }
        get {
            let defaults = Foundation.UserDefaults.standard
            let lang = defaults.object(forKey: "User.Language") as? String
            return lang
        }
    }
Grigor Aghabalyan's avatar
Grigor Aghabalyan committed
48
}