From c8a6ba8008ee9718cc817e44e3f87ab9e793440d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Mu=CC=88ller?= Date: Tue, 2 Feb 2021 22:32:32 +0100 Subject: [PATCH] :globe_with_meridians: l10n --- DHBW-Service.xcodeproj/project.pbxproj | 14 ++++++++ .../Supporting Files/l10n/Localizer.swift | 2 +- .../l10n/de.lproj/HomeView.strings | 13 +++++++ .../l10n/en.lproj/HomeView.strings | 13 +++++++ .../Views/Other/FirstOpeningSettings.swift | 8 ++--- DHBW-Service/Views/Tabs/HomeView.swift | 36 +++++++++---------- 6 files changed, 63 insertions(+), 23 deletions(-) create mode 100644 DHBW-Service/Supporting Files/l10n/de.lproj/HomeView.strings create mode 100644 DHBW-Service/Supporting Files/l10n/en.lproj/HomeView.strings diff --git a/DHBW-Service.xcodeproj/project.pbxproj b/DHBW-Service.xcodeproj/project.pbxproj index 47bb99e..56c6f6a 100644 --- a/DHBW-Service.xcodeproj/project.pbxproj +++ b/DHBW-Service.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + CD17FAD025C9F93B0088D700 /* HomeView.strings in Resources */ = {isa = PBXBuildFile; fileRef = CD17FAD225C9F93B0088D700 /* HomeView.strings */; }; CD2FC0C525A869FE00963178 /* dhbw-standard-icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = CD2FC0C025A869FE00963178 /* dhbw-standard-icon@2x.png */; }; CD2FC0C625A869FE00963178 /* dhbw-standard-icon@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = CD2FC0C125A869FE00963178 /* dhbw-standard-icon@3x.png */; }; CD2FC0C725A869FE00963178 /* alpaca-alt-icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = CD2FC0C325A869FE00963178 /* alpaca-alt-icon@2x.png */; }; @@ -52,6 +53,8 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + CD17FAD125C9F93B0088D700 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/HomeView.strings; sourceTree = ""; }; + CD17FAD625C9F9440088D700 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/HomeView.strings; sourceTree = ""; }; CD2FC0C025A869FE00963178 /* dhbw-standard-icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "dhbw-standard-icon@2x.png"; sourceTree = ""; }; CD2FC0C125A869FE00963178 /* dhbw-standard-icon@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "dhbw-standard-icon@3x.png"; sourceTree = ""; }; CD2FC0C325A869FE00963178 /* alpaca-alt-icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "alpaca-alt-icon@2x.png"; sourceTree = ""; }; @@ -297,6 +300,7 @@ CDDCF4832592028A0027CDC5 /* Localizer.swift */, CDDCF495259203390027CDC5 /* Localizable.strings */, CDDCF4A4259203B40027CDC5 /* General.strings */, + CD17FAD225C9F93B0088D700 /* HomeView.strings */, ); path = l10n; sourceTree = ""; @@ -405,6 +409,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + CD17FAD025C9F93B0088D700 /* HomeView.strings in Resources */, CD2FC0C725A869FE00963178 /* alpaca-alt-icon@2x.png in Resources */, CD9FAB88258EC60600D6D0C5 /* Preview Assets.xcassets in Resources */, CDDCF4A2259203B40027CDC5 /* General.strings in Resources */, @@ -487,6 +492,15 @@ /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ + CD17FAD225C9F93B0088D700 /* HomeView.strings */ = { + isa = PBXVariantGroup; + children = ( + CD17FAD125C9F93B0088D700 /* en */, + CD17FAD625C9F9440088D700 /* de */, + ); + name = HomeView.strings; + sourceTree = ""; + }; CDDCF495259203390027CDC5 /* Localizable.strings */ = { isa = PBXVariantGroup; children = ( diff --git a/DHBW-Service/Supporting Files/l10n/Localizer.swift b/DHBW-Service/Supporting Files/l10n/Localizer.swift index 6d44df5..c8da0b9 100644 --- a/DHBW-Service/Supporting Files/l10n/Localizer.swift +++ b/DHBW-Service/Supporting Files/l10n/Localizer.swift @@ -24,7 +24,7 @@ private class Localizer { } extension String { - func localized(tableName: String = "Localizable", plural: Bool) -> String { + func localized(tableName: String = "Localizable", plural: Bool = false) -> String { return Localizer.sharedInstance.localize(string: self, tableName: tableName, plural: plural) } } diff --git a/DHBW-Service/Supporting Files/l10n/de.lproj/HomeView.strings b/DHBW-Service/Supporting Files/l10n/de.lproj/HomeView.strings new file mode 100644 index 0000000..91b8b10 --- /dev/null +++ b/DHBW-Service/Supporting Files/l10n/de.lproj/HomeView.strings @@ -0,0 +1,13 @@ +/* + HomeView.strings + DHBW-Service + + Created by Patrick Müller on 02.02.21. + +*/ + +"today" = "Heute"; +"tomorrow" = "Morgen"; +"upcomingExams" = "Nächste Klausuren"; +"noLectures" = "Keine Vorlesungen"; +"noExams" = "Keine Klausuren"; diff --git a/DHBW-Service/Supporting Files/l10n/en.lproj/HomeView.strings b/DHBW-Service/Supporting Files/l10n/en.lproj/HomeView.strings new file mode 100644 index 0000000..30c1289 --- /dev/null +++ b/DHBW-Service/Supporting Files/l10n/en.lproj/HomeView.strings @@ -0,0 +1,13 @@ +/* + HomeView.strings + DHBW-Service + + Created by Patrick Müller on 02.02.21. + +*/ + +"today" = "Today"; +"tomorrow" = "Tomorrow"; +"upcomingExams" = "Upcoming exams"; +"noLectures" = "No lectures"; +"noExams" = "No exams"; diff --git a/DHBW-Service/Views/Other/FirstOpeningSettings.swift b/DHBW-Service/Views/Other/FirstOpeningSettings.swift index f3640f1..620a417 100644 --- a/DHBW-Service/Views/Other/FirstOpeningSettings.swift +++ b/DHBW-Service/Views/Other/FirstOpeningSettings.swift @@ -18,9 +18,9 @@ struct FirstOpeningSettings: View { var body: some View { VStack { - Text("welcomeText".localized(tableName: "General", plural: false)) + Text("welcomeText".localized(tableName: "General")) - TextField("name".localized(tableName: "General", plural: false), text: self.$name) + TextField("name".localized(tableName: "General"), text: self.$name) .overlay(RoundedRectangle(cornerRadius: 10).stroke(invalidInputName ? Color.red : Color.secondary, lineWidth: 1)) .foregroundColor(invalidInputName ? .red : .primary) .textContentType(.name) @@ -28,7 +28,7 @@ struct FirstOpeningSettings: View { .frame(minWidth: 200, idealWidth: nil, maxWidth: 500, minHeight: nil, idealHeight: nil, maxHeight: nil, alignment: .center) .padding(.horizontal) - TextField("course".localized(tableName: "General", plural: false), text: self.$course) + TextField("course".localized(tableName: "General"), text: self.$course) .overlay(RoundedRectangle(cornerRadius: 10).stroke(invalidInputCourse ? Color.red : Color.secondary, lineWidth: 1)) .onChange(of: course, perform: { value in self.setDirector() @@ -40,7 +40,7 @@ struct FirstOpeningSettings: View { .frame(minWidth: 200, idealWidth: nil, maxWidth: 500, minHeight: nil, idealHeight: nil, maxHeight: nil, alignment: .center) .padding(.horizontal) - TextField("director".localized(tableName: "General", plural: false) + " (" + "filledAuto".localized(tableName: "General", plural: false) + ")", text: self.$director) + TextField("director".localized(tableName: "General") + " (" + "filledAuto".localized(tableName: "General") + ")", text: self.$director) .foregroundColor(.primary) .textContentType(.name) .textFieldStyle(RoundedBorderTextFieldStyle()) diff --git a/DHBW-Service/Views/Tabs/HomeView.swift b/DHBW-Service/Views/Tabs/HomeView.swift index 01ef7b4..4b9a62a 100644 --- a/DHBW-Service/Views/Tabs/HomeView.swift +++ b/DHBW-Service/Views/Tabs/HomeView.swift @@ -38,43 +38,43 @@ struct HomeView: View { Spacer() VStack { - Text("Today") + Text("today".localized(tableName: "HomeView")) .font(/*@START_MENU_TOKEN@*/.title/*@END_MENU_TOKEN@*/) .frame(maxWidth: .infinity) VStack { - if(todaysEvents.count > 0){ + if(!todaysEvents.isEmpty){ ForEach(todaysEvents, id: \.self) { exam in Text(exam.value(forKey: "summary") as! String) } } else { - Text("No lectures") + Text("noLectures".localized(tableName: "HomeView")) } } } .padding() .overlay( - RoundedRectangle(cornerRadius: 10) - .stroke(Color.blue, lineWidth: 4) + RoundedRectangle(cornerRadius: 10) + .stroke(Color.blue, lineWidth: 4) ) VStack { - Text("Tomorrow") + Text("tomorrow".localized(tableName: "HomeView")) .font(/*@START_MENU_TOKEN@*/.title/*@END_MENU_TOKEN@*/) .frame(maxWidth: .infinity) VStack { - if(tomorrowsEvents.count > 0){ + if(!tomorrowsEvents.isEmpty){ ForEach(tomorrowsEvents, id: \.self) { exam in Text(exam.value(forKey: "summary") as! String) } } else { - Text("No lectures") + Text("noLectures".localized(tableName: "HomeView")) } } } .padding() .overlay( - RoundedRectangle(cornerRadius: 10) - .stroke(Color.blue, lineWidth: 4) + RoundedRectangle(cornerRadius: 10) + .stroke(Color.blue, lineWidth: 4) ) Spacer() @@ -85,23 +85,23 @@ struct HomeView: View { Spacer() VStack { - Text("Upcoming exams") + Text("upcomingExams".localized(tableName: "HomeView")) .font(/*@START_MENU_TOKEN@*/.title/*@END_MENU_TOKEN@*/) .frame(maxWidth: .infinity) VStack { - if(upcomingExams.count > 0){ + if(!upcomingExams.isEmpty){ ForEach(upcomingExams, id: \.self) { exam in Text(exam.value(forKey: "summary") as! String) } } else { - Text("No exams") + Text("noExams".localized(tableName: "HomeView")) } } } .padding() .overlay( - RoundedRectangle(cornerRadius: 10) - .stroke(Color.red, lineWidth: 4) + RoundedRectangle(cornerRadius: 10) + .stroke(Color.red, lineWidth: 4) ) Spacer() @@ -136,7 +136,7 @@ extension HomeView{ predicates.append(contentsOf: getDayPredicates(today: true)) let compoundPredicate = NSCompoundPredicate(andPredicateWithSubpredicates: predicates) let events = UtilityFunctions.getCoreDataObject(entity: "RaPlaEvent", searchPredicate: compoundPredicate) - if(events.count > 0) { + if(!events.isEmpty) { return Array(events[...min(1, events.count-1)]) } else { return [] @@ -150,7 +150,7 @@ extension HomeView{ predicates.append(contentsOf: getDayPredicates(tomorrow: true)) let compoundPredicate = NSCompoundPredicate(andPredicateWithSubpredicates: predicates) let events = UtilityFunctions.getCoreDataObject(entity: "RaPlaEvent", searchPredicate: compoundPredicate) - if(events.count > 0) { + if(!events.isEmpty) { return Array(events[...min(1, events.count-1)]) } else { return [] @@ -164,7 +164,7 @@ extension HomeView{ let sectionSortDescriptor = NSSortDescriptor(key: "startDate", ascending: true) let sortDescriptors = [sectionSortDescriptor] let events = UtilityFunctions.getCoreDataObject(entity: "RaPlaEvent", sortDescriptors: sortDescriptors, searchPredicate: compoundPredicate) - if(events.count > 0) { + if(!events.isEmpty) { return Array(events[...min(1, events.count-1)]) } else { return []