forked from LoopKit/LoopKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLocalizedString.swift
29 lines (26 loc) · 945 Bytes
/
LocalizedString.swift
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
//
// LocalizedString.swift
// LoopKit
//
// Created by Retina15 on 8/6/18.
// Copyright © 2018 LoopKit Authors. All rights reserved.
//
import Foundation
private class LocalBundle {
/// Returns the resource bundle associated with the current Swift module.
static var main: Bundle = {
if let mainResourceURL = Bundle.main.resourceURL,
let bundle = Bundle(url: mainResourceURL.appendingPathComponent("LoopKit_LoopKit.bundle"))
{
return bundle
}
return Bundle(for: LocalBundle.self)
}()
}
func LocalizedString(_ key: String, tableName: String? = nil, value: String? = nil, comment: String) -> String {
if let value = value {
return NSLocalizedString(key, tableName: tableName, bundle: LocalBundle.main, value: value, comment: comment)
} else {
return NSLocalizedString(key, tableName: tableName, bundle: LocalBundle.main, comment: comment)
}
}