#walter_code
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1458432188172341535
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Adding CFBundleLocalizations on the app's plist and only adding a single language there, to force the PaymentSheet to use that
Yes this is the only workaround availble
Otherwise, you can't force the PaymentSheet to use a particular local programmatically.
the ios SDK
I set the phone to Finnish, and set the BundleLocalizations to english
the sheet is still Finnish
Ok let me do a quick test with the native IOs SDK. I had done this with ReactNative before...
thanks!
I managed to reproduce using our official sample:
https://github.com/stripe/stripe-ios/tree/master/Example/PaymentSheet Example
Checking now if there is a workaround..
thanks!
Found it. Try to override the local in your main AppDelegate:
@_spi(STP) import StripeCore
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
// Force English locale for the example app
STPLocalizationUtils.overrideLanguage(to: "en") // <= ADD THIS LINE
thanks, let me try
'overrideLanguage' is inaccessible due to 'internal' protection level
I can see the method on the core, but looks like I can't access it
Yes indeed, and it's in core and can't be exposed publically
I added the import according to your code
Yes yes, you need to modify the core, which isn't possible
yep
Ok I think another option, is to use Bundle extension
Create a file in your root directory Bundle+ForceEnglish.swift (same level with your AppDelegate)
//
// Bundle+ForceEnglish.swift
// PaymentSheet Example
//
// Created to force English localization in the example app
//
import Foundation
import ObjectiveC
private var bundleKey: UInt8 = 0
extension Bundle {
static func swizzleLocalization() {
// Swizzle the preferredLocalizations property to always return English
DispatchQueue.once(token: "com.stripe.bundleSwizzle") {
object_setClass(Bundle.main, PrivateBundle.self)
}
}
}
private class PrivateBundle: Bundle {
override var preferredLocalizations: [String] {
return ["en"]
}
override var localizations: [String] {
return ["en"]
}
}
extension DispatchQueue {
private static var _onceTracker = [String]()
class func once(token: String, block: () -> Void) {
objc_sync_enter(self)
defer { objc_sync_exit(self) }
if _onceTracker.contains(token) {
return
}
_onceTracker.append(token)
block()
}
}
Then in your AppDelegate called Bundle.swizzleLocalization()
I just tested it and it works actually
Can you try it on our official IOS sample?
I can see that the preferredLocalizations method is called
but the sheet is still in Finnish
hopefully I'm not doing anything else on the app that messes with it
There must be something else in your integration that ignoring the forcing of the local
Can you try it on our official IOS sample?
https://github.com/stripe/stripe-ios/tree/master/Example/PaymentSheet Example
?
You should open the main project stripe-ios via Stripe.xcworkspace then run the PaymentSheet Example
ah! thanks!
still Finnish
I'm running on a simulator, does that make any difference?
Mm, I'm running it on a simulator too ๐ค
I added a breakpoint and the preferredLocalizations is called