Browse Source

adapt to new set-stock-translations api

B. Petersen 5 years ago
parent
commit
db8475e34f
2 changed files with 36 additions and 40 deletions
  1. 36 0
      deltachat-ios/AppDelegate.swift
  2. 0 40
      deltachat-ios/DC/events.swift

+ 36 - 0
deltachat-ios/AppDelegate.swift

@@ -73,6 +73,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         appCoordinator.start()
         UIApplication.shared.setMinimumBackgroundFetchInterval(UIApplication.backgroundFetchIntervalMinimum)
         start()
+        setStockTranslations()
         if !isConfigured {
             appCoordinator.presentLoginController()
         }
@@ -145,6 +146,41 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         _ = dc_open(mailboxPointer, dbfile(), nil)
     }
 
+    func setStockTranslations() {
+        dc_set_stock_translation(mailboxPointer, UInt32(DC_STR_NOMESSAGES), String.localized("chat_no_messages"))
+        dc_set_stock_translation(mailboxPointer, UInt32(DC_STR_SELF), String.localized("self"))
+        dc_set_stock_translation(mailboxPointer, UInt32(DC_STR_DRAFT), String.localized("draft"))
+        dc_set_stock_translation(mailboxPointer, UInt32(DC_STR_VOICEMESSAGE), String.localized("voice_message"))
+        dc_set_stock_translation(mailboxPointer, UInt32(DC_STR_DEADDROP), String.localized("chat_contact_request"))
+        dc_set_stock_translation(mailboxPointer, UInt32(DC_STR_IMAGE), String.localized("image"))
+        dc_set_stock_translation(mailboxPointer, UInt32(DC_STR_VIDEO), String.localized("video"))
+        dc_set_stock_translation(mailboxPointer, UInt32(DC_STR_AUDIO), String.localized("audio"))
+        dc_set_stock_translation(mailboxPointer, UInt32(DC_STR_FILE), String.localized("file"))
+        dc_set_stock_translation(mailboxPointer, UInt32(DC_STR_STATUSLINE), String.localized("pref_default_status_text"))
+        dc_set_stock_translation(mailboxPointer, UInt32(DC_STR_NEWGROUPDRAFT), String.localized("group_hello_draft"))
+        dc_set_stock_translation(mailboxPointer, UInt32(DC_STR_MSGGRPNAME), String.localized("systemmsg_group_name_changed"))
+        dc_set_stock_translation(mailboxPointer, UInt32(DC_STR_MSGGRPIMGCHANGED), String.localized("systemmsg_group_image_changed"))
+        dc_set_stock_translation(mailboxPointer, UInt32(DC_STR_MSGADDMEMBER), String.localized("systemmsg_member_added"))
+        dc_set_stock_translation(mailboxPointer, UInt32(DC_STR_MSGDELMEMBER), String.localized("systemmsg_member_removed"))
+        dc_set_stock_translation(mailboxPointer, UInt32(DC_STR_MSGGROUPLEFT), String.localized("systemmsg_group_left"))
+        dc_set_stock_translation(mailboxPointer, UInt32(DC_STR_GIF), String.localized("gif"))
+        dc_set_stock_translation(mailboxPointer, UInt32(DC_STR_CANTDECRYPT_MSG_BODY), String.localized("systemmsg_cannot_decrypt"))
+        dc_set_stock_translation(mailboxPointer, UInt32(DC_STR_READRCPT), String.localized("systemmsg_read_receipt_subject"))
+        dc_set_stock_translation(mailboxPointer, UInt32(DC_STR_READRCPT_MAILBODY), String.localized("systemmsg_read_receipt_body"))
+        dc_set_stock_translation(mailboxPointer, UInt32(DC_STR_MSGGRPIMGDELETED), String.localized("systemmsg_group_image_deleted"))
+        dc_set_stock_translation(mailboxPointer, UInt32(DC_STR_CONTACT_VERIFIED), String.localized("contact_verified"))
+        dc_set_stock_translation(mailboxPointer, UInt32(DC_STR_CONTACT_NOT_VERIFIED), String.localized("contact_not_verified"))
+        dc_set_stock_translation(mailboxPointer, UInt32(DC_STR_CONTACT_SETUP_CHANGED), String.localized("contact_setup_changed"))
+        dc_set_stock_translation(mailboxPointer, UInt32(DC_STR_ARCHIVEDCHATS), String.localized("chat_archived_chats_title"))
+        dc_set_stock_translation(mailboxPointer, UInt32(DC_STR_AC_SETUP_MSG_SUBJECT), String.localized("autocrypt_asm_subject"))
+        dc_set_stock_translation(mailboxPointer, UInt32(DC_STR_AC_SETUP_MSG_BODY), String.localized("autocrypt_asm_general_body"))
+        dc_set_stock_translation(mailboxPointer, UInt32(DC_STR_SELFTALK_SUBTITLE), String.localized("chat_self_talk_subtitle"))
+        dc_set_stock_translation(mailboxPointer, UInt32(DC_STR_CANNOT_LOGIN), String.localized("login_error_cannot_login"))
+        dc_set_stock_translation(mailboxPointer, UInt32(DC_STR_SERVER_RESPONSE), String.localized("login_error_server_response"))
+        dc_set_stock_translation(mailboxPointer, UInt32(DC_STR_MSGACTIONBYUSER), String.localized("systemmsg_action_by_user"))
+        dc_set_stock_translation(mailboxPointer, UInt32(DC_STR_MSGACTIONBYME), String.localized("systemmsg_action_by_me"))
+    }
+
     func stop() {
         state = .background
 

+ 0 - 40
deltachat-ios/DC/events.swift

@@ -166,46 +166,6 @@ public func callbackSwift(event: CInt, data1: CUnsignedLong, data2: CUnsignedLon
             )
         }
 
-    case DC_EVENT_GET_STRING:
-        var string = ""
-        switch Int32(data1) {
-        case DC_STR_NOMESSAGES: string = String.localized("chat_no_messages")
-        case DC_STR_SELF: string = String.localized("self")
-        case DC_STR_DRAFT: string = String.localized("draft")
-        case DC_STR_MEMBER: return nil // we create this string in hackPluralsString()
-        case DC_STR_VOICEMESSAGE: string = String.localized("voice_message")
-        case DC_STR_DEADDROP: string = String.localized("chat_contact_request")
-        case DC_STR_IMAGE: string = String.localized("image")
-        case DC_STR_VIDEO: string = String.localized("video")
-        case DC_STR_AUDIO: string = String.localized("audio")
-        case DC_STR_FILE: string = String.localized("file")
-        case DC_STR_STATUSLINE: string = String.localized("pref_default_status_text")
-        case DC_STR_NEWGROUPDRAFT: string = String.localized("group_hello_draft")
-        case DC_STR_MSGGRPNAME: string = String.localized("systemmsg_group_name_changed")
-        case DC_STR_MSGGRPIMGCHANGED: string = String.localized("systemmsg_group_image_changed")
-        case DC_STR_MSGADDMEMBER: string = String.localized("systemmsg_member_added")
-        case DC_STR_MSGDELMEMBER: string = String.localized("systemmsg_member_removed")
-        case DC_STR_MSGGROUPLEFT: string = String.localized("systemmsg_group_left")
-        case DC_STR_GIF: string = String.localized("gif")
-        case DC_STR_CANTDECRYPT_MSG_BODY: string = String.localized("systemmsg_cannot_decrypt")
-        case DC_STR_READRCPT: string = String.localized("systemmsg_read_receipt_subject")
-        case DC_STR_READRCPT_MAILBODY: string = String.localized("systemmsg_read_receipt_body")
-        case DC_STR_MSGGRPIMGDELETED: string = String.localized("systemmsg_group_image_deleted")
-        case DC_STR_CONTACT_VERIFIED: string = String.localized("contact_verified")
-        case DC_STR_CONTACT_NOT_VERIFIED: string = String.localized("contact_not_verified")
-        case DC_STR_CONTACT_SETUP_CHANGED: string = String.localized("contact_setup_changed")
-        case DC_STR_ARCHIVEDCHATS: string = String.localized("chat_archived_chats_title")
-        case DC_STR_AC_SETUP_MSG_SUBJECT: string = String.localized("autocrypt_asm_subject")
-        case DC_STR_AC_SETUP_MSG_BODY: string = String.localized("autocrypt_asm_general_body")
-        case DC_STR_SELFTALK_SUBTITLE: string = String.localized("chat_self_talk_subtitle")
-        case DC_STR_CANNOT_LOGIN: string = String.localized("login_error_cannot_login")
-        case DC_STR_SERVER_RESPONSE: string = String.localized("login_error_server_response")
-        case DC_STR_MSGACTIONBYUSER: string = String.localized("systemmsg_action_by_user")
-        case DC_STR_MSGACTIONBYME: string = String.localized("systemmsg_action_by_me")
-        default: return nil
-        }
-        return UnsafePointer(strdup(string))
-
     default:
         logger.warning("unknown event: \(event)")
     }