This project provides an iOS app with a string catalog for managing localizable strings. It is supposed to show options of how to store localizable keys so that a string catalog can automatically manage them.
- Localizing and varying text with a string catalog
- Discover String Catalogs
- Editing XLIFF and string catalog files
LocalizedStringResource
ID | Type | SC compatible | SwiftUI | SwiftUI previews | UIKit | Key Access | Parameters |
---|---|---|---|---|---|---|---|
a | Swift.String.LocalizationValue |
✅ | ❌ | ❌ | ❌ | ||
b | SwiftUI.LocalizedStringKey |
✅ | ✅ | ✅ | ❌ | ❌ | ❌ |
c | Foundation.LocalizedStringResource |
✅ | ✅ | ✅ | ✅ | ✅ | |
d | SwiftUI.Text |
✅ | ✅ | ✅ | ❌ | ❌ | ✅ |
f | Foundation.NSLocalizedString |
✅ | ✅ | ❌ | ✅ | ❌ | ✅ |
g | Swift.String extension |
❌ | ✅ | ❌ | ✅ | ❌ | ❌ |
h | Swift.String(localized:) |
✅ | ✅ | ❌ | ✅ | ❌ | ✅ |
Key | Description |
---|---|
ID | The variable name in the Examples |
Type | The type to store a localizable key |
SC compatible | Does the string catalog automatically find the specified keys in the project? |
SwiftUI | Do SwiftUI symbols come with an interface? |
SwiftUI previews | Do SwiftUI previews automatically reflect the current locale from environment? |
UIKit | Do UIKit symbols come with an interface? |
Key Access | Can the raw key be accessed, e.g. in tests? |
Parameters | Are parameters for choosing comment , table , bundle available? |
⚠️ Some types can and need to be converted intoString
before using them inUIKit
, orSwiftUI
String(localized resource: LocalizedStringValue)
String(localized resource: LocalizedStringResource)
All "SC compatible" types also support String interpolation to insert dynamic values into the localizable key.
For simplification these examples are not added to the project. The following code would result in a string catalog entry: Hello %@
func greeting(with name: String) -> LocalizedStringResource {
LocalizedStringResource(
"Hello \(name)",
comment: "A short greeting with a name parameter"
)
}
App | SwiftUI preview |
---|---|