BLACK FRIDAY: Save 50% on all my Swift books and bundles! >>

Using different locale in Preview

Forums > SwiftUI

Hi everyone, i´m currently at Day 30 of 100 Days of SwiftUI and really enjoying it.

Have the follwing problem: My locale is set to german, but i wanted to use "en-US" in some apps instead to avoid word replacement with german words. This works great in the simulator by adding the following modifier to the view(in this case a list):

.typesettingLanguage(.init(identifier: "en-US"))

In order to have that in the preview, Apple suggests to use the following modifer be added to the preview:

.environment(\.locale, .init(identifier: "en"))

This produces the following behaviour in the preview: Sometimes the words are processed using "en-US", sometimes my default locale is used again.

I know it´s a small issue, but it´s quite anoying. Is this a bug with the preview or am i missing something?

Thank You all for your help.

Greetings Markus

1      

Save 50% in my WWDC sale.

SAVE 50% All our books and bundles are half price for Black Friday, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.

Save 50% on all our books and bundles!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.