mikaoj / BSImagePicker

A multiple image picker for iOS
MIT License
1.35k stars 380 forks source link

Done button is not localized from system localization. #249

Open ghost opened 4 years ago

ghost commented 4 years ago

I use BSImagePicker in Japanese environment. The cancel button is localized well, but done button not seems to be localized.

ss

Following code may not be work well. Sources/Controller/ImagePickerController.swift fileprivate let localizedDone = Bundle(identifier: "com.apple.UIKit")?.localizedString(forKey: "Done", value: "Done", table: "") ?? "Done"

mikaoj commented 4 years ago

Oh, interesting. I tested it on a phone set to swedish and there the localization worked.

Could you check where "Done" comes from? Is it because it fails to initialize the bundle Bundle(identifier: "com.apple.UIKit")? or is it localizedString(forKey: "Done", value: "Done", table: "") that returns "Done"?

ghost commented 4 years ago

@mikaoj

Thank you for your quick reply. I prepare following debug code for this issue.

https://github.com/bonzeboy/BSImagePicker/tree/debug/i8n cd9ccaca18aa88c5a3013b08d143b6c3a628c9d4

I added following code in init of ImagePickerController.

        print("1")
        print(Bundle(identifier: "com.apple.UIKit"))
        print("2")
        print(Bundle(identifier: "com.apple.UIKit")?.localizedString(forKey: "Done", value: "Done", table: ""))
        print("3")
        print(Bundle(identifier: "com.apple.UIKit")?.localizedString(forKey: "Done", value: "Done", table: "") ?? "Done")

Reproduce environment: Xcode: Version 11.4(11E146) iOS: iPhone 8(17E255, version 13.4) simulator in the Xcode

(check1) condition: change iPhone Language to Japanese result: 1 Optional(NSBundle </Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/UIKit.framework> (loaded)) 2 Optional("Done") 3 Done

I expect that "Done" button is displayed as "完了", but it is displayed as "Done".

check1

(check2) condition: change iPhone Language to Svenska result: 1 Optional(NSBundle </Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/UIKit.framework> (loaded)) 2 Optional("Done") 3 Done

I don't know swedish well (sorry...), but I think "Done" is not expected is it?

check2

mikaoj commented 4 years ago

Yeah it isn't working for me anymore either. As for a swedish lesson, 'Done' should be 'Klar'. :)

knox commented 4 years ago

I have the same problem for german localization. Obviously UIKit localization got moved to somewhere else.

Try this in Playground:

let bundle = Bundle(identifier: "com.apple.UIKit")!
bundle.localizedString(forKey: "Done", value: "<failed>", table: nil)  // "<failed>"
bundle.localizedString(forKey: "Save", value: "<failed>", table: nil)  // "<failed>"
bundle.localizations  // ["English"]

Tested with Xcode 11.4.1 (16137)

mikaoj commented 4 years ago

I've done a temporary workaround in 3.1.7 where there is a property named doneButtonTitle that you can set on the image picker.

vasilich6107 commented 3 years ago

hi @mikaoj this bug seems to be fixed in https://github.com/mikaoj/BSImagePicker/commit/bea10a522477e193958dce3de42241f8fed2ab9c

Any news about releasing new version?