TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

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 RevenueCat.

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

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.