我想知道如何使用新的字符串目录系统动态手动获取和更改当前应用程序语言。
尝试在https://developer.apple.com/documentation/xcode/localization处查看文档以获取信息。
我希望有一种方法可以获取当前的语言环境,并有一个函数可以更改它......
最佳答案
如果您支持 iOS 13 或 macOS Catalina 或更高版本,则不再需要提供在应用内选择语言的方法。 Apple 支持每个应用程序本地化:
How to support per-app language settings in your app
When you localize your app, people all over the world can view your content in the language they feel most comfortable reading. And with the latest versions of iOS and macOS, people can have even more control by choosing languages on a per-app basis. For example, someone may set their iPhone’s language to English, but want to use a social media app in Arabic.
Apple 明确建议不要手动进行语言切换:
If you currently offer such a UI, you should remove it to avoid customer confusion and potential conflict with the system. If you’d like to guide people to the system settings for language selection, you can replace your app’s custom UI with a flow that launches directly into the Settings app on iOS. On iOS, add the following:
UIApplication.shared.open(URL(字符串:UIApplication.openSettingsURLString)!)
On macOS, direct people to System Preferences > Language & Region to add a per-language setting for your app.
关于ios - 如何使用新的字符串目录系统动态更改应用程序语言? [Xcode 15],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76730835/