-
Discover String Catalogs
Discover how Xcode 15 makes it easy to localize your app by managing all of your strings in one place. We'll show you how to extract, edit, export, and build strings in your project using String Catalogs. We'll also share how you can adopt String Catalogs in existing projects at your own pace by choosing which files to migrate.
Capítulos
- 0:00 - Introduction
- 1:29 - Demo
- 4:13 - Extract
- 13:19 - Edit
- 22:48 - Export
- 27:52 - Build
- 28:44 - Migrate
- 31:03 - Wrap-up
Recursos
Vídeos relacionados
WWDC23
-
Buscar neste vídeo...
-
-
4:30 - Localizable string
String(localized: "Welcome to WWDC!") -
4:42 - Localizable string with default value
String(localized: "WWDC_NOTIFICATION_TITLE", defaultValue: "Welcome to WWDC!") -
5:05 - Localizable string with comment
String(localized: "Welcome to WWDC!", comment: "Notification banner title") -
5:22 - Localizable string with table and comment
String(localized: "Welcome to WWDC!", table: "WWDCNotifications", comment: "Notification banner title") -
7:36 - Localizable strings in SwiftUI
// Localizable strings in SwiftUI struct ContentView: View { var body: some View { VStack { Label("Thanks for shopping with us!", systemImage: "bag") .font(.title) HStack { Button("Clear Cart") { } Button("Checkout") { } } } } } -
8:01 - Localizable strings in SwiftUI with LocalizedStringKey
// Localizable strings in SwiftUI struct ContentView: View { var body: some View { VStack { // init(_ titleKey: LocalizedStringKey, systemImage name: String) Label("Thanks for shopping with us!", systemImage: "bag") .font(.title) HStack { Button("Clear Cart") { } Button("Checkout") { } } } } } -
8:08 - Localizable strings in SwiftUI text view
// Localizable strings in SwiftUI struct ContentView: View { var body: some View { VStack { Label { Text("Thanks for shopping with us!", comment: "Label above checkout button") } icon: { Image(systemName: "bag") } .font(.title) HStack { Button("Clear Cart") { } Button("Checkout") { } } } } } -
8:16 - Localizable strings in SwiftUI custom view
// Localizable strings in SwiftUI struct CardView: View { let title: LocalizedStringResource let subtitle: LocalizedStringResource var body: some View { ZStack { RoundedRectangle(cornerRadius: 10.0) VStack { Text(title) Text(subtitle) } .padding() } } } CardView(title: "Recent Purchases", subtitle: "Items you’ve ordered in the past week.") -
9:03 - Localizable strings in Swift displayed at runtime
// Localizable strings in Swift import Foundation func stringsToPresent() -> (String, AttributedString) { let deferredString = LocalizedStringResource("Title") … return ( String(localized: deferredString), AttributedString(localized: "**Attributed** _Subtitle_") ) } -
9:44 - Localizable strings in Objective-C
// Localizable strings in Objective-C #import <Foundation/Foundation.h> - (NSString *)stringForDisplay { return NSLocalizedString(@"Recent Purchases", @"Button Title"); } #define MyLocalizedString(key, comment) \ [myBundle localizedStringForKey:key value:nil table:nil] -
10:04 - Localizable strings in C
// Localizable strings in C #include <CoreFoundation/CoreFoundation.h> CFStringRef stringForDisplay(void) { return CFCopyLocalizedString(CFSTR("Recent Purchases"), CFSTR("Button Title")); } #define MyLocalizedString(key, comment) \ CFBundleCopyLocalizedString(myBundle, key, NULL, NULL) -
11:23 - App Shortcut phrases
// App Shortcut phrases struct FoodTruckShortcuts: AppShortcutsProvider { static var appShortcuts: [AppShortcut] { AppShortcut( intent: ShowTopDonutsIntent(), phrases: [ "\(.applicationName) Trends for \(\.$timeframe)", "Show trending donuts for \(\.$timeframe) in \(.applicationName)", "Give me trends for \(\.$timeframe) in \(.applicationName)" ] ) } } -
23:53 - Stringsdict in XLIFF
// Stringsdict in XLIFF <trans-unit id="/%lld Recent Visitors:dict/NSStringLocalizedFormatKey:dict/:string"> <source>%#@recentVisitors@</source> <target>%#@recentVisitors@</target> </trans-unit> <trans-unit id="/%lld Recent Visitors:dict/recentVisitors:dict/one:dict/:string"> <source>%lld Recent Visitor</source> <target>%lld Visitante Recente</target> </trans-unit> <trans-unit id="/%lld Recent Visitors:dict/recentVisitors:dict/other:dict/:string"> <source>%lld Recent Visitors</source> <target>%lld Visitantes Recentes</target> </trans-unit> -
24:08 - String Catalog in XLIFF
// String Catalog in XLIFF <trans-unit id="%lld Recent Visitors|==|plural.one"> <source>%lld Recent Visitor</source> <target>%lld Visitante Recente</target> </trans-unit> <trans-unit id="%lld Recent Visitors|==|plural.other"> <source>%lld Recent Visitors</source> <target>%lld Visitantes Recentes</target> </trans-unit> -
24:58 - String Catalog variations in XLIFF
// Overriding variation in XLIFF <trans-unit id="Bird Food Shop|==|device.applewatch"> <source>Bird Food Shop</source> <target>Loja de Comida</target> </trans-unit> <trans-unit id="Bird Food Shop|==|device.other"> <source>Bird Food Shop</source> <target>Loja de Comida de Passarinho</target> </trans-unit>
-