Streamline your localized strings

RSS for tag

Discuss the WWDC21 session Streamline your localized strings.

Posts under wwdc21-10221 tag

4 Posts

Post

Replies

Boosts

Views

Activity

New iOS String Initializer can't get correct localized String for specific locale
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
7
0
5.4k
Mar ’24
Localization - Long Strings and Multi-line Strings
Hi. I'm looking forward to using the new localization features as shown in 10221. Is there a version of String(localized: ) that uses a key that is separate from the user-facing string? This is my preferred approach even with short strings but becomes really important for long strings like what you might see for an explanation in a table view footer. And is there support for multi-line strings? Again, with a key? Many thanks.
1
0
987
Aug ’21
New iOS String Initializer can't get correct localized String for specific locale
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
Replies
7
Boosts
0
Views
5.4k
Activity
Mar ’24
Export Localization don't export Strings
Hi, I thought that with Exporting String with localization in all files but it didn't. It export all SwiftUI Text and Button Strings but thats it. I had a file where I have. String(localized: “Hello, world!”, comment: “Hello”) It is in project and it is passed to the view later. Tired in Beta 5 and RC Thanks
Replies
4
Boosts
0
Views
2.4k
Activity
Jul ’23
Ho
Tags
Replies
0
Boosts
0
Views
987
Activity
May ’22
Localization - Long Strings and Multi-line Strings
Hi. I'm looking forward to using the new localization features as shown in 10221. Is there a version of String(localized: ) that uses a key that is separate from the user-facing string? This is my preferred approach even with short strings but becomes really important for long strings like what you might see for an explanation in a table view footer. And is there support for multi-line strings? Again, with a key? Many thanks.
Replies
1
Boosts
0
Views
987
Activity
Aug ’21