SwiftUI Tips 1 — Dynamic Localization without Changing system’s Language

Things you may need to know about the power of SwiftUI, and how we can take advantage of it by some tricks.

Table of Content

Introduction

Add a new project
type the name of project, uncheck “Use Core Data” then Next to create.
new project structure
Preview window if you provide a inherit object of PreviewProvider

Basic Setting for Localization

xcodeproj file → project setting → info → Localizations
Storyboard with lproj folder and related resource files
Create Strings File with name “Localizable”
Associate english with Localizable.strings
Text field with localized string in English in preview window

Adding a new language

Adding a new language
Select new language

Make preview window with multi-language

Make the app with dynamic changing language

Fix preview, and make 2 languages preview
The final app with dynamic locales

simply a coder

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store