Project menu (Option key) Run ... then on the Options tab select Localization Debuggin - Show non-localized strings.
I learned this technique from Paul Hudson - developing his Ultimate Portfolio project, so you will see this project name in examples.
Step 1
Create a new Strings file.
File > New File > filter for “strings” choose Strings File - name it “Localizable.strings”
The Localizable.strings file is a key = value; list of terms e.g. “hotel” = “The White Horse Inn”;
Change to the source code folder: Development/UltimatePortfolio/UltimatePortfolio
The command line tool - and run the command: genstrings -SwiftUI *.swift
This command will put it’s output in Localizable.strings
Step 2
Hand coding work:
%@ -> %lld as in "%lld items" = "%lld items";
Add the strings that are not found by genstrings
Then back in Xcode > Projects (Option)-Run > App — Options tab > App Language - set to “Double-Length Pseudolanguage” - makes the language double - speak :^). Helps find the other strings like below:
In HomeView.swift the line
@ViewBuilder func list(_ title: String, for items: FetchedResults<Item>.SubSequence) -> some View {
@ViewBuilder func list(_ title: LocalizedStringKey, for items: FetchedResults<Item>.SubSequence) -> some View {
Step 3
Delete these lines
/* No comment provided by engineer. */
"%lld items" = "%lld items";
We will use a Strings Dictionary for plurals.
New > File > filter for “strings” make Localizable.stringsdict
Then right click on file name >> Open As - Source Code :: to get XML view.
Video mark 30:54
Change: <key>StringKey</key> into <key>%lld items</key>
Step 4
In Project-CoreDataHelpers.swift these strings need to use lower level NSLocalizedString()
var projectTitle: String {
title ?? NSLocalizedString("New Project", comment: "Create a new project")
}
Step 5 - Localization to a specific language
Localization - Step 1 - choose a language
Project file > Info tab Localization section
Localization - Step 2 - file inspector - click Localize…