This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import SwiftUI | |
| struct ContentView: View { | |
| var body: some View { | |
| Text("Hello, world!") | |
| .padding() | |
| } | |
| } | |
| struct ContentView_Previews: PreviewProvider { | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | @available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
| extension Text { | |
| /// Creates a text view that displays localized content identified by a key. | |
| /// | |
| /// Use this initializer to look for the `key` parameter in a localization | |
| /// table and display the associated string value in the initialized text | |
| /// view. If the initializer can't find the key in the table, or if no table | |
| /// exists, the text view displays the string representation of the key | |
| /// instead. | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import SwiftUI | |
| struct ContentView: View { | |
| var body: some View { | |
| Text("Hello, world!") | |
| .padding() | |
| } | |
| } | |
| struct ContentView_Previews: PreviewProvider { | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | struct LocalDemoApp: App { | |
| @State(initialValue: "en") var lang: String | |
| var body: some Scene { | |
| WindowGroup { | |
| ContentView(lang: $lang) | |
| .environment(\.locale, .init(identifier: lang)) | |
| } | |
| } | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import SwiftUI | |
| struct ContentView: View { | |
| @Binding var lang: String | |
| var body: some View { | |
| VStack(alignment: .center, spacing: 30){ | |
| Text("Hello, world!") | |
| .padding() | |
| Button("English") { | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | struct ContentView_Previews: PreviewProvider { | |
| static var previews: some View { | |
| VStack{ | |
| Text("Preview in English").foregroundColor(.green) | |
| PreviewWrapper(lang: .init(initialValue: "en")) | |
| } | |
| VStack{ | |
| Text("Preview in Spanish").foregroundColor(.orange) | |
| PreviewWrapper(lang: .init(initialValue: "es")) | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import Foundation | |
| import XcodeKit | |
| class BetterCommand: NSObject, XCSourceEditorCommand { | |
| func perform(with invocation: XCSourceEditorCommandInvocation, completionHandler: @escaping (Error?) -> Void ) -> Void { | |
| print("BetterCommand: \(invocation.description)") | |
| print("BetterCommand: \(invocation.commandIdentifier)") | |
| completionHandler(nil) | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <key>NSExtension</key> | |
| <dict> | |
| <key>NSExtensionAttributes</key> | |
| <dict> | |
| <key>XCSourceEditorCommandDefinitions</key> | |
| <array> | |
| <dict> | |
| <key>XCSourceEditorCommandClassName</key> | |
| <string>$(PRODUCT_MODULE_NAME).BetterCommand</string> | |
| <key>XCSourceEditorCommandIdentifier</key> | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <key>NSExtension</key> | |
| <dict> | |
| <key>NSExtensionAttributes</key> | |
| <dict> | |
| <key>XCSourceEditorCommandDefinitions</key> | |
| <array> | |
| <dict> | |
| <key>XCSourceEditorCommandClassName</key> | |
| <string>$(PRODUCT_MODULE_NAME).BetterCommand</string> | |
| <key>XCSourceEditorCommandIdentifier</key> | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import Foundation | |
| import XcodeKit | |
| class BetterCommand: NSObject, XCSourceEditorCommand { | |
| func perform(with invocation: XCSourceEditorCommandInvocation, completionHandler: @escaping (Error?) -> Void) { | |
| switch invocation.commandIdentifier { | |
| case "BetterHelloWorld": | |
| insertHelloWorl(source: invocation.buffer) | |
| completionHandler(nil) | |
| return | 
OlderNewer