# HG changeset patch # User Dennis Concepción Martín # Date 1626989454 -3600 # Node ID c52966834f8326c406524ecaf2776e3059bd204d # Parent 4f862c618b445840803a818523146759134983a5 Add localised strings diff -r 4f862c618b44 -r c52966834f83 Simoleon.xcodeproj/project.pbxproj --- a/Simoleon.xcodeproj/project.pbxproj Thu Jul 22 19:06:01 2021 +0100 +++ b/Simoleon.xcodeproj/project.pbxproj Thu Jul 22 22:30:54 2021 +0100 @@ -506,6 +506,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; @@ -568,6 +569,7 @@ baseConfigurationReference = 9585BB0F26A6B58500E3193E /* Config.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; diff -r 4f862c618b44 -r c52966834f83 Simoleon.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate Binary file Simoleon.xcodeproj/project.xcworkspace/xcuserdata/dennis.xcuserdatad/UserInterfaceState.xcuserstate has changed diff -r 4f862c618b44 -r c52966834f83 Simoleon/ContentView.swift --- a/Simoleon/ContentView.swift Thu Jul 22 19:06:01 2021 +0100 +++ b/Simoleon/ContentView.swift Thu Jul 22 22:30:54 2021 +0100 @@ -17,20 +17,24 @@ Conversion(fetchUserSettings: true, currencyPair: "USD/GBP") .environmentObject(subscriptionController) .tabItem { - Label("Convert", systemImage: "arrow.counterclockwise.circle") + Text("Convert", comment: "Tab bar button to show conversion") + Image(systemName: "arrow.counterclockwise.circle") } .tag(Tab.convert) Favourites() + .environmentObject(subscriptionController) .tabItem { - Label("Favourites", systemImage: "star") + Text("Favourites", comment: "Tab bar button to show favourites") + Image(systemName: "star") } .tag(Tab.favourites) Settings() .environmentObject(subscriptionController) .tabItem { - Label("Settings", systemImage: "gear") + Text("Settings", comment: "Tab bar button to show settings") + Image(systemName: "gear") } .tag(Tab.settings) } @@ -40,10 +44,9 @@ private func checkEntitlements() { Purchases.shared.purchaserInfo { (purchaserInfo, error) in if purchaserInfo?.entitlements["all"]?.isActive == true { - print("User's subscription is active") self.subscriptionController.isActive = true } else { - print("User's subscription expired or doesn't exist") + // User subscription is not active } } } diff -r 4f862c618b44 -r c52966834f83 Simoleon/Conversion.swift --- a/Simoleon/Conversion.swift Thu Jul 22 19:06:01 2021 +0100 +++ b/Simoleon/Conversion.swift Thu Jul 22 22:30:54 2021 +0100 @@ -62,14 +62,16 @@ CurrencySelector(currencyPair: $currencyPair, showingCurrencySelector: $showingCurrencySelector) } } - .navigationTitle("Conversion") + .navigationTitle(Text("Conversion", comment: "Navigation title")) .toolbar { ToolbarItem(placement: .cancellationAction) { if isEditing { - Button("Cancel", action: { + Button(action: { UIApplication.shared.dismissKeyboard() isEditing = false - }) + }) { + Text("Cancel", comment: "Button to stop editing textfield") + } } } } diff -r 4f862c618b44 -r c52966834f83 Simoleon/Favourites.swift --- a/Simoleon/Favourites.swift Thu Jul 22 19:06:01 2021 +0100 +++ b/Simoleon/Favourites.swift Thu Jul 22 22:30:54 2021 +0100 @@ -18,8 +18,8 @@ VStack { if favourite.isEmpty { Group { - Text("Tap ") + Text(Image(systemName: "star")) - Text("to add a currency pair to favourites") + Text("Tap ", comment: "First line when favourites are empty") + Text(Image(systemName: "star")) + Text("to add a currency pair to favourites", comment: "Finish line when favourites are empty") .padding(.top, 5) } .foregroundColor(Color(.systemGray)) @@ -34,7 +34,7 @@ } } } - .navigationTitle("Favourites") + .navigationTitle(Text("Favourites", comment: "Navigation title")) .toolbar { #if os(iOS) EditButton() diff -r 4f862c618b44 -r c52966834f83 Simoleon/Helpers/CurrencyRow.swift --- a/Simoleon/Helpers/CurrencyRow.swift Thu Jul 22 19:06:01 2021 +0100 +++ b/Simoleon/Helpers/CurrencyRow.swift Thu Jul 22 22:30:54 2021 +0100 @@ -30,7 +30,7 @@ .offset(x: -20) .padding(.trailing, -20) - Text("From \(String(currencies[0])) to \(String(currencies[1]))") + Text("From \(String(currencies[0])) to \(String(currencies[1]))", comment: "Conversion from one currency to another") .fontWeight(.semibold) .foregroundColor(Color("PlainButton")) .padding(.leading) diff -r 4f862c618b44 -r c52966834f83 Simoleon/Helpers/CurrencySelector.swift --- a/Simoleon/Helpers/CurrencySelector.swift Thu Jul 22 19:06:01 2021 +0100 +++ b/Simoleon/Helpers/CurrencySelector.swift Thu Jul 22 22:30:54 2021 +0100 @@ -32,7 +32,7 @@ } } - Section(header: Text("All currencies")) { + Section(header: Text("All currencies", comment: "Section header in currency selector")) { ForEach(currencyPairs(), id: \.self) { currencyPair in Button(action: { select(currencyPair) }) { CurrencyRow(currencyPair: currencyPair) @@ -46,22 +46,25 @@ searching = false }) ) - .navigationTitle("Currencies") + .navigationTitle(Text("Currencies", comment: "Navigation title")) .navigationBarTitleDisplayMode(.inline) .toolbar { ToolbarItem(placement: .cancellationAction) { - Button("Cancel", action: { showingCurrencySelector = false }) + Button(action: { showingCurrencySelector = false }) { + Text("Cancel", comment: "Button to dismiss currency selector") + } } ToolbarItem(placement: .confirmationAction) { - if searching { - Button("OK") { + if searching { + Button(action: { withAnimation { searchCurrency = "" - withAnimation { - searching = false - UIApplication.shared.dismissKeyboard() - } - } + searching = false + UIApplication.shared.dismissKeyboard() + }} + ) { + Text("Ok", comment: "Button to stop searching in currency selector") + } } } } diff -r 4f862c618b44 -r c52966834f83 Simoleon/Helpers/LockedCurrencyPicker.swift --- a/Simoleon/Helpers/LockedCurrencyPicker.swift Thu Jul 22 19:06:01 2021 +0100 +++ b/Simoleon/Helpers/LockedCurrencyPicker.swift Thu Jul 22 22:30:54 2021 +0100 @@ -10,9 +10,9 @@ struct LockedCurrencyPicker: View { var body: some View { HStack { - Text("Default currency") + Text("Default currency", comment: "Label in locked picker") Spacer() - Text("USD/GBP") + Text("USD/GBP", comment: "Default currency in locked picker") .foregroundColor(Color(.systemGray)) Image(systemName: "lock") diff -r 4f862c618b44 -r c52966834f83 Simoleon/Helpers/RestoreButton.swift --- a/Simoleon/Helpers/RestoreButton.swift Thu Jul 22 19:06:01 2021 +0100 +++ b/Simoleon/Helpers/RestoreButton.swift Thu Jul 22 22:30:54 2021 +0100 @@ -13,8 +13,8 @@ @EnvironmentObject var subscriptionController: SubscriptionController @State private var restoringPurchases = false - @State private var alertTitle = "" - @State private var alertMessage = "" + @State private var alertTitle = Text("") + @State private var alertMessage = Text("") @State private var showingAlert = false var body: some View { @@ -22,11 +22,11 @@ if restoringPurchases { ProgressView() } else { - Text("Restore purchases") + Text("Restore purchases", comment: "Button to restore in-App purchases") } } .alert(isPresented: $showingAlert) { - Alert(title: Text(alertTitle), message: Text(alertMessage), dismissButton: .default(Text("Ok"))) + Alert(title: alertTitle, message: alertMessage, dismissButton: .default(Text("Ok", comment: "Button to dismiss alert"))) } } @@ -38,15 +38,15 @@ subscriptionController.isActive = true showingSubscriptionPaywall = false } else { - alertTitle = "No subscriptions found" - alertMessage = "You are not subscripted to Simoleon yet." + alertTitle = Text("No subscriptions found", comment: "Alert title") + alertMessage = Text("You are not subscripted to Simoleon yet.", comment: "Alert message") restoringPurchases = false showingAlert = true } if let error = error as NSError? { - alertTitle = error.localizedDescription - alertMessage = error.localizedFailureReason ?? "If the problem persists send an email to dmartin@dennistech.io" + alertTitle = Text(error.localizedDescription) + alertMessage = Text(error.localizedFailureReason ?? "If the problem persists send an email to dmartin@dennistech.io") showingAlert = true } } diff -r 4f862c618b44 -r c52966834f83 Simoleon/Helpers/Sidebar.swift --- a/Simoleon/Helpers/Sidebar.swift Thu Jul 22 19:06:01 2021 +0100 +++ b/Simoleon/Helpers/Sidebar.swift Thu Jul 22 22:30:54 2021 +0100 @@ -11,19 +11,28 @@ var body: some View { List { NavigationLink(destination: Conversion(fetchUserSettings: true, currencyPair: "USD/GBP")) { - Label("Convert", systemImage: "arrow.counterclockwise.circle") + HStack { + Text("Convert", comment: "Tab bar button to show conversion") + Image(systemName: "arrow.counterclockwise.circle") + } } NavigationLink(destination: Favourites()) { - Label("Favourites", systemImage: "star") + HStack { + Text("Favourites", comment: "Tab bar button to show favourites") + Image(systemName: "star") + } } NavigationLink(destination: Settings()) { - Label("Settings", systemImage: "gear") + HStack { + Text("Settings", comment: "Tab bar button to show settings") + Image(systemName: "gear") + } } } .listStyle(SidebarListStyle()) - .navigationTitle("Categories") + .navigationTitle(Text("Categories", comment: "Side bar navigation title")) } } diff -r 4f862c618b44 -r c52966834f83 Simoleon/Helpers/SubscriberInfo.swift --- a/Simoleon/Helpers/SubscriberInfo.swift Thu Jul 22 19:06:01 2021 +0100 +++ b/Simoleon/Helpers/SubscriberInfo.swift Thu Jul 22 22:30:54 2021 +0100 @@ -13,36 +13,36 @@ @State private var expiration: Date? = nil @State private var latestPurchase: Date? = nil @State private var showingAlert = false - @State private var alertTitle = "" - @State private var alertMessage = "" + @State private var alertTitle = Text("") + @State private var alertMessage = Text("") var body: some View { VStack { List { if let memberSince = self.memberSince { - Text("Member since \(formatDate(memberSince))") + Text("Member since \(formatDate(memberSince))", comment: "Subscriber information") } else { Text("-") } if let expiration = self.expiration { - Text("Expires at \(formatDate(expiration))") + Text("Expires at \(formatDate(expiration))", comment: "Subscriber information") } else { Text("-") } if let latestPurchase = self.latestPurchase { - Text("Latest purchase \(formatDate(latestPurchase))") + Text("Latest purchase \(formatDate(latestPurchase))", comment: "Subscriber information") } else { Text("-") } } .listStyle(InsetGroupedListStyle()) } - .navigationTitle("Information") + .navigationTitle(Text("Information", comment: "Navigation title")) .onAppear(perform: getInfo) .alert(isPresented: $showingAlert) { - Alert(title: Text(alertTitle), message: Text(alertMessage), dismissButton: .default(Text("Ok"))) + Alert(title: alertTitle, message: alertMessage, dismissButton: .default(Text("Ok", comment: "Dismiss alert"))) } } @@ -53,8 +53,8 @@ self.latestPurchase = purchaserInfo?.entitlements["all"]?.latestPurchaseDate if let error = error as NSError? { - alertTitle = error.localizedDescription - alertMessage = error.localizedFailureReason ?? "If the problem persists send an email to dmartin@dennistech.io" + alertTitle = Text(error.localizedDescription) + alertMessage = Text(error.localizedFailureReason ?? "If the problem persists send an email to dmartin@dennistech.io") showingAlert = true } } diff -r 4f862c618b44 -r c52966834f83 Simoleon/Helpers/SubscriptionFeature.swift --- a/Simoleon/Helpers/SubscriptionFeature.swift Thu Jul 22 19:06:01 2021 +0100 +++ b/Simoleon/Helpers/SubscriptionFeature.swift Thu Jul 22 22:30:54 2021 +0100 @@ -9,8 +9,8 @@ struct SubscriptionFeature: View { var symbol: String - var title: String - var text: String + var title: LocalizedStringKey + var text: LocalizedStringKey var colour: Color var body: some View { @@ -20,10 +20,10 @@ .font(.title) VStack(alignment: .leading) { - Text(title) + Text(title, comment: "Title of subscription feature") .font(.headline) - Text(text) + Text(text, comment: "Description of subscription feature") } } } diff -r 4f862c618b44 -r c52966834f83 Simoleon/Settings.swift --- a/Simoleon/Settings.swift Thu Jul 22 19:06:01 2021 +0100 +++ b/Simoleon/Settings.swift Thu Jul 22 22:30:54 2021 +0100 @@ -20,21 +20,24 @@ var body: some View { List { - Section(header: Text("Subscription")) { - NavigationLink("Information", destination: SubscriberInfo()) - if !subscriptionController.isActive { - Text("Subscribe") + Section(header: Text("Subscription", comment: "Section header in settings")) { + if subscriptionController.isActive { + NavigationLink(destination: SubscriberInfo()) { + Text("Information", comment: "Button to show subscription information in settings") + } + } else { + Text("Subscribe", comment: "Button to suscribe in settings") .onTapGesture { showingSubscriptionPaywall = true } } } - Section(header: Text("Preferences")) { + Section(header: Text("Preferences", comment: "Section header in settings")) { if subscriptionController.isActive { - Picker("Default currency", selection: $selectedDefaultCurrency) { + Picker(selection: $selectedDefaultCurrency, label: Text("Default currency", comment: "Picker to select default currency"), content: { ForEach(currencyPairs.sorted(), id: \.self) { currencyPair in Text(currencyPair) } - } + }) } else { LockedCurrencyPicker() .contentShape(Rectangle()) @@ -42,14 +45,14 @@ } } - Section(header: Text("Stay in touch")) { + Section(header: Text("Stay in touch", comment: "Section header in settings")) { Link(destination: URL(string: "https://itunes.apple.com/app/id1576390953?action=write-review")!) { HStack { Image(systemName: "heart.fill") .foregroundColor(Color(.systemRed)) .imageScale(.large) - Text("Rate Simoleon") + Text("Rate Simoleon", comment: "Button to rate app in Settings") } } @@ -59,7 +62,7 @@ .resizable() .frame(width: 30, height: 30) - Text("Developer's Twitter") + Text("Developer's Twitter", comment: "Button to go to Twitter in Settings") } } @@ -69,19 +72,24 @@ .renderingMode(.original) .imageScale(.large) - Text("Contact") + Text("Contact", comment: "Button to contact in Settings") } } } Section(header: Text("About")) { - Link("Website", destination: URL(string: "https://dennistech.io")!) - Link("Privacy Policy", destination: URL(string: "https://dennistech.io")!) + Link(destination: URL(string: "https://dennistech.io")!) { + Text("Website", comment: "Button to go to Dennis Tech website") + } + + Link(destination: URL(string: "https://dennistech.io")!) { + Text("Privacy Policy", comment: "Button to go to app privacy policy") + } } } .onAppear(perform: onAppear) .listStyle(InsetGroupedListStyle()) - .navigationTitle("Settings") + .navigationTitle(Text("Settings", comment: "Navigation title")) .sheet(isPresented: $showingSubscriptionPaywall) { Subscription(showingSubscriptionPaywall: $showingSubscriptionPaywall) .environmentObject(subscriptionController) diff -r 4f862c618b44 -r c52966834f83 Simoleon/Subscription.swift --- a/Simoleon/Subscription.swift Thu Jul 22 19:06:01 2021 +0100 +++ b/Simoleon/Subscription.swift Thu Jul 22 22:30:54 2021 +0100 @@ -23,7 +23,7 @@ .frame(width: 100, height: 100) .cornerRadius(25) - Text("Unlock all access") + Text("Unlock all access", comment: "Headline in Subscription paywall") .font(.title) .fontWeight(.semibold) .padding(.top) @@ -75,7 +75,9 @@ } .toolbar { ToolbarItem(placement: .cancellationAction) { - Button("Cancel", action: { showingSubscriptionPaywall = false }) + Button(action: { showingSubscriptionPaywall = false }) { + Text("Cancel", comment: "Button to dismiss paywall modal sheet") + } } } }