@akylas/nativescript-app-utils 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,31 @@
1
+ //
2
+ // NSLocale+ISO639_2.swift
3
+ // nsdocumentscanner
4
+ //
5
+ // Created by Martin Guillon on 03/01/2024.
6
+ // Copyright © 2024 NativeScript. All rights reserved.
7
+ //
8
+
9
+ import Foundation
10
+
11
+
12
+ @objc(NSLocale)
13
+ extension NSLocale {
14
+ static let sISO639_2Dictionary: NSDictionary? = {
15
+ let bundleURL:URL! = Bundle.main.url(forResource:"iso639_2", withExtension:"bundle")
16
+ let bundle:Bundle! = Bundle(url: bundleURL)
17
+ let plistPath:String! = bundle.path(forResource: "iso639_1_to_iso639_2", ofType:"plist")
18
+ return NSDictionary(contentsOfFile: plistPath)
19
+ }()
20
+ class func ISO639_2Dictionary() -> NSDictionary! {
21
+ return sISO639_2Dictionary;
22
+ }
23
+
24
+ @objc
25
+ func ISO639_2LanguageCode() -> String! {
26
+ let ISO639_1LanguageCode:String! = self.object(forKey: NSLocale.Key.languageCode) as? String
27
+ let ISO639_2LanguageCode:String? = NSLocale.ISO639_2Dictionary().object(forKey: ISO639_1LanguageCode!) as? String
28
+ if (ISO639_2LanguageCode == nil) {return ISO639_1LanguageCode}
29
+ return ISO639_2LanguageCode
30
+ }
31
+ }
@@ -0,0 +1,19 @@
1
+ import Foundation
2
+ import UIKit
3
+
4
+ @objcMembers
5
+ @objc(NWorkerContext)
6
+ class NWorkerContext : NSObject {
7
+ private static var container: [String: Any] = [:]
8
+ static func setValue(_ key: String, _ value: Any?) {
9
+ if (value == nil) {
10
+ container.removeValue(forKey: key)
11
+ } else {
12
+ container[key] = value
13
+ }
14
+ }
15
+ static func getValue(_ key: String) -> Any? {
16
+ return container[key]
17
+ }
18
+ }
19
+