mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2026-08-26 05:14:09 +02:00
Add:Language code setting and translations #448
This commit is contained in:
@@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
// Override point for customization after application launch.
|
||||
|
||||
let configuration = Realm.Configuration(
|
||||
schemaVersion: 14,
|
||||
schemaVersion: 15,
|
||||
migrationBlock: { [weak self] migration, oldSchemaVersion in
|
||||
if (oldSchemaVersion < 1) {
|
||||
self?.logger.log("Realm schema version was \(oldSchemaVersion)")
|
||||
@@ -42,6 +42,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
newObject?["hapticFeedback"] = "LIGHT"
|
||||
}
|
||||
}
|
||||
if (oldSchemaVersion < 15) {
|
||||
self?.logger.log("Realm schema version was \(oldSchemaVersion)... Adding languageCode setting")
|
||||
migration.enumerateObjects(ofType: DeviceSettings.className()) { oldObject, newObject in
|
||||
newObject?["languageCode"] = "en-us"
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
Realm.Configuration.defaultConfiguration = configuration
|
||||
|
||||
@@ -241,6 +241,7 @@ public class AbsDatabase: CAPPlugin {
|
||||
let jumpForwardTime = call.getInt("jumpForwardTime") ?? 10
|
||||
let lockOrientation = call.getString("lockOrientation") ?? "NONE"
|
||||
let hapticFeedback = call.getString("hapticFeedback") ?? "LIGHT"
|
||||
let languageCode = call.getString("languageCode") ?? "en-us"
|
||||
let settings = DeviceSettings()
|
||||
settings.disableAutoRewind = disableAutoRewind
|
||||
settings.enableAltView = enableAltView
|
||||
@@ -248,6 +249,7 @@ public class AbsDatabase: CAPPlugin {
|
||||
settings.jumpForwardTime = jumpForwardTime
|
||||
settings.lockOrientation = lockOrientation
|
||||
settings.hapticFeedback = hapticFeedback
|
||||
settings.languageCode = languageCode
|
||||
|
||||
Database.shared.setDeviceSettings(deviceSettings: settings)
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ class DeviceSettings: Object {
|
||||
@Persisted var jumpForwardTime: Int = 10
|
||||
@Persisted var lockOrientation: String = "NONE"
|
||||
@Persisted var hapticFeedback: String = "LIGHT"
|
||||
@Persisted var languageCode: String = "en-us"
|
||||
}
|
||||
|
||||
func getDefaultDeviceSettings() -> DeviceSettings {
|
||||
@@ -28,6 +29,7 @@ func deviceSettingsToJSON(settings: DeviceSettings) -> Dictionary<String, Any> {
|
||||
"jumpBackwardsTime": settings.jumpBackwardsTime,
|
||||
"jumpForwardTime": settings.jumpForwardTime,
|
||||
"lockOrientation": settings.lockOrientation,
|
||||
"hapticFeedback": settings.hapticFeedback
|
||||
"hapticFeedback": settings.hapticFeedback,
|
||||
"languageCode": settings.languageCode
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user