`NSBundle.localizedStringForKey` doesn't work prop...
# kotlin-native
d
NSBundle.localizedStringForKey
doesn't work properly in pair with
NSString.localizedStringWithFormat
. Looks like
NSString
losing some metadata during conversion into Kotlin
String
. Here is example on Kotlin:
Copy code
import platform.Foundation.NSBundle
import platform.Foundation.NSString
import platform.Foundation.localizedStringWithFormat

class TestClass(private val bundle: NSBundle) {
    fun localizedStringWithFormat(string: String): String {
        return NSString.localizedStringWithFormat(
                this.bundle.localizedStringForKey(string, "", "Localizable"), 5)
    }
}
Here is the code in swift:
Copy code
let testClass = TestClass(bundle: Bundle.main)
let testString = "screen_main_plural_string"
let nativeStr = Bundle.main.localizedString(forKey: testString, value: "", table: "Localizable") as NSString

NSLog("swift: %@", NSString.localizedStringWithFormat(nativeStr, 5))
NSLog("kotlin: %@", testClass.localizedStringWithFormat(string: testString))
Output logs: swift: Plural: 5 apples kotlin: %#@value@
o
Does it work if framework is written in Swift?
d
s
Thanks, confirmed.
Fixed in master. The fix will be included to 1.3.70.