I tried to build LocalizedKeyString using String's new Initializer.
String(localized: "hello",locale: locale)
When I change the language setting of the device, everything works as expected.
However, when I try to get the string in a specific language using the specified Locale, I can only ever get the string in .current.
String(localized: "hello",locale: Locale(identifier: "zh-cn"))
func getString(locale:Locale) -> String{
String(localized: "hello",locale: locale)
}
If you change the display language of the project (or the language setting of the device), the text in Text is always displayed correctly.
Text(getString(locale:.current))
However, the code in onAppear
print(getString(locale:Locale(identifier: "zh-cn")))
It only displays the same content as Text, but not the specified Chinese.
Is it my fault that the new Initializer The understanding is not correct, or the bug of String
init(localized keyAndValue: String.LocalizationValue, table: String? = nil, bundle: Bundle? = nil, locale: Locale = .current, comment: StaticString? = nil)
FB number: FB9675845
Localization
RSS for tagLocalization is the process of adapting and translating your app to multiple languages.
Posts under Localization tag
103 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
With the announcement of the new Apple Translate app and offline support, are there any URL schemes that we can use in our apps to send text to the Translate app and have it open and translate the sent text?
I have mulling over this for many years ,Uralic and Siberian language user interface Support.Ainu of Japan is only supported by writing roman and rendering into Katakana with a few small modified characters there is no user interface ,spell,grammar checker,dictionary ,translator ,of course the Ainu has few terms in modern vocabulary but Iam studying the language in order to find words and coin new ones, iPhone hoomi-ye-p electric speak thing. I am looking for other peple who have the same idea.