UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

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      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

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.