You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DevnagriSDK.shared.initSdk(apiKey: String, updateStringTime:Int?) { isInitialized, message in
54
-
//Reload or update UI here...
55
-
}
56
-
}
57
-
58
-
# Default Localisation Override
59
-
The SDK override the functionality of NSLocalisedString by default. You just need to import the DevnagriSdk to the file where you want NSLocalisedString to be override by the SDK.
55
+
**Note**: This import is **required** when using `NSLocalizedString` method replacement functionality, as the SDK extends the localization system to work with SDK's dynamic translation features.
56
+
57
+
The SDK override the functionality of NSLocalisedString by default. You just need to import the DevnagriSdk to the file where you want NSLocalisedString to be override by the SDK.
58
+
59
+
---
60
+
61
+
## Public Methods & APIs
62
+
Initialize the SDK by calling the following code in your `didFinishLaunchingWithOptions` Method and you can get `API_KEY` from devnagri.
In case you don't want to use the system language, you can set a different language in the updateAppLocale method. The language code (locale) needs to be present in a release from Devnagri.
63
-
//You can start loader here...
64
-
DevnagriSDK.shared.updateAppLocale(code: "hi") { isUpdated, message in
65
-
//You can stop loader here...
66
-
//Reload or update UI here...
67
-
}
68
-
69
+
DevnagriSDK.shared.initSdk(
70
+
apiKey: "YOUR_API_KEY",
71
+
updateStringsTime: 30, // Minutes (minimum 10)
72
+
completionHandler: { isInitialized, message in
73
+
if isInitialized {
74
+
print("SDK initialized successfully")
75
+
} else {
76
+
print("Initialization failed: \(message ??"")")
77
+
}
78
+
}
79
+
80
+
)}
81
+
```
82
+
-`apiKey`: Your DevNagri API key (required)
83
+
-`updateStringsTime`: Automatic translation update interval in minutes (optional, minimum 10)
84
+
-`completionHandler`: Callback with initialization status and message
85
+
86
+
87
+
# Language Management
88
+
### **Change Language**
89
+
In case you don't want to use the system language, you can set a different language in the `updateAppLocale` method. The language code (locale) needs to be present in a release from Devnagri.
90
+
91
+
```swift
92
+
importDevnagriSdk
93
+
94
+
DevnagriSDK.shared.updateAppLocale(code: "es") { isUpdated, message in
95
+
//You can stop loader here...
96
+
//Reload or update UI here...
97
+
98
+
}
99
+
```
69
100
Please note that you will see the english text back if your device language is english and you have not set any specific language for the SDK. To get the translation in Hindi, Please update app locale to Hindi as per above method.
70
-
71
-
#Get Current language code
101
+
102
+
### **Get Current language code** ###
72
103
In case you want to know which language code currently used by application.
73
104
74
-
let currentLanguageCode = DevnagriSDK.shared.getCurrentApplicationLanguageCode()
105
+
```swift
106
+
importDevnagriSdk
75
107
76
-
77
-
# Get Supported Languages
108
+
let currentLang = DevnagriSDK.shared.getCurrentApplicationLanguageCode()
0 commit comments