Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Done button is not localized from system localization. #249

Open
ghost opened this issue Apr 11, 2020 · 6 comments
Open

Done button is not localized from system localization. #249

ghost opened this issue Apr 11, 2020 · 6 comments

Comments

@ghost
Copy link

ghost commented Apr 11, 2020

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
Copy link
Owner

mikaoj commented Apr 11, 2020

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
Copy link
Author

ghost commented Apr 11, 2020

@mikaoj

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

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

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
Copy link
Owner

mikaoj commented Apr 15, 2020

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

@knox
Copy link
Contributor

knox commented Apr 28, 2020

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
Copy link
Owner

mikaoj commented Apr 30, 2020

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
Copy link

hi @mikaoj
this bug seems to be fixed in bea10a5

Any news about releasing new version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants