🌐 l10n

This commit is contained in:
Patrick Müller 2021-02-02 22:32:32 +01:00 committed by Patrick Müller
parent b8b1439bf1
commit c8a6ba8008
6 changed files with 63 additions and 23 deletions

View File

@ -7,6 +7,7 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* 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 */; }; 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 */; }; 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 */; }; CD2FC0C725A869FE00963178 /* alpaca-alt-icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = CD2FC0C325A869FE00963178 /* alpaca-alt-icon@2x.png */; };
@ -52,6 +53,8 @@
/* End PBXContainerItemProxy section */ /* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
CD17FAD125C9F93B0088D700 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/HomeView.strings; sourceTree = "<group>"; };
CD17FAD625C9F9440088D700 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/HomeView.strings; sourceTree = "<group>"; };
CD2FC0C025A869FE00963178 /* dhbw-standard-icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "dhbw-standard-icon@2x.png"; sourceTree = "<group>"; }; CD2FC0C025A869FE00963178 /* dhbw-standard-icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "dhbw-standard-icon@2x.png"; sourceTree = "<group>"; };
CD2FC0C125A869FE00963178 /* dhbw-standard-icon@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "dhbw-standard-icon@3x.png"; sourceTree = "<group>"; }; CD2FC0C125A869FE00963178 /* dhbw-standard-icon@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "dhbw-standard-icon@3x.png"; sourceTree = "<group>"; };
CD2FC0C325A869FE00963178 /* alpaca-alt-icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "alpaca-alt-icon@2x.png"; sourceTree = "<group>"; }; CD2FC0C325A869FE00963178 /* alpaca-alt-icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "alpaca-alt-icon@2x.png"; sourceTree = "<group>"; };
@ -297,6 +300,7 @@
CDDCF4832592028A0027CDC5 /* Localizer.swift */, CDDCF4832592028A0027CDC5 /* Localizer.swift */,
CDDCF495259203390027CDC5 /* Localizable.strings */, CDDCF495259203390027CDC5 /* Localizable.strings */,
CDDCF4A4259203B40027CDC5 /* General.strings */, CDDCF4A4259203B40027CDC5 /* General.strings */,
CD17FAD225C9F93B0088D700 /* HomeView.strings */,
); );
path = l10n; path = l10n;
sourceTree = "<group>"; sourceTree = "<group>";
@ -405,6 +409,7 @@
isa = PBXResourcesBuildPhase; isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
CD17FAD025C9F93B0088D700 /* HomeView.strings in Resources */,
CD2FC0C725A869FE00963178 /* alpaca-alt-icon@2x.png in Resources */, CD2FC0C725A869FE00963178 /* alpaca-alt-icon@2x.png in Resources */,
CD9FAB88258EC60600D6D0C5 /* Preview Assets.xcassets in Resources */, CD9FAB88258EC60600D6D0C5 /* Preview Assets.xcassets in Resources */,
CDDCF4A2259203B40027CDC5 /* General.strings in Resources */, CDDCF4A2259203B40027CDC5 /* General.strings in Resources */,
@ -487,6 +492,15 @@
/* End PBXTargetDependency section */ /* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */ /* Begin PBXVariantGroup section */
CD17FAD225C9F93B0088D700 /* HomeView.strings */ = {
isa = PBXVariantGroup;
children = (
CD17FAD125C9F93B0088D700 /* en */,
CD17FAD625C9F9440088D700 /* de */,
);
name = HomeView.strings;
sourceTree = "<group>";
};
CDDCF495259203390027CDC5 /* Localizable.strings */ = { CDDCF495259203390027CDC5 /* Localizable.strings */ = {
isa = PBXVariantGroup; isa = PBXVariantGroup;
children = ( children = (

View File

@ -24,7 +24,7 @@ private class Localizer {
} }
extension String { 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) return Localizer.sharedInstance.localize(string: self, tableName: tableName, plural: plural)
} }
} }

View File

@ -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";

View File

@ -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";

View File

@ -18,9 +18,9 @@ struct FirstOpeningSettings: View {
var body: some View { var body: some View {
VStack { 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)) .overlay(RoundedRectangle(cornerRadius: 10).stroke(invalidInputName ? Color.red : Color.secondary, lineWidth: 1))
.foregroundColor(invalidInputName ? .red : .primary) .foregroundColor(invalidInputName ? .red : .primary)
.textContentType(.name) .textContentType(.name)
@ -28,7 +28,7 @@ struct FirstOpeningSettings: View {
.frame(minWidth: 200, idealWidth: nil, maxWidth: 500, minHeight: nil, idealHeight: nil, maxHeight: nil, alignment: .center) .frame(minWidth: 200, idealWidth: nil, maxWidth: 500, minHeight: nil, idealHeight: nil, maxHeight: nil, alignment: .center)
.padding(.horizontal) .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)) .overlay(RoundedRectangle(cornerRadius: 10).stroke(invalidInputCourse ? Color.red : Color.secondary, lineWidth: 1))
.onChange(of: course, perform: { value in .onChange(of: course, perform: { value in
self.setDirector() self.setDirector()
@ -40,7 +40,7 @@ struct FirstOpeningSettings: View {
.frame(minWidth: 200, idealWidth: nil, maxWidth: 500, minHeight: nil, idealHeight: nil, maxHeight: nil, alignment: .center) .frame(minWidth: 200, idealWidth: nil, maxWidth: 500, minHeight: nil, idealHeight: nil, maxHeight: nil, alignment: .center)
.padding(.horizontal) .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) .foregroundColor(.primary)
.textContentType(.name) .textContentType(.name)
.textFieldStyle(RoundedBorderTextFieldStyle()) .textFieldStyle(RoundedBorderTextFieldStyle())

View File

@ -38,16 +38,16 @@ struct HomeView: View {
Spacer() Spacer()
VStack { VStack {
Text("Today") Text("today".localized(tableName: "HomeView"))
.font(/*@START_MENU_TOKEN@*/.title/*@END_MENU_TOKEN@*/) .font(/*@START_MENU_TOKEN@*/.title/*@END_MENU_TOKEN@*/)
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
VStack { VStack {
if(todaysEvents.count > 0){ if(!todaysEvents.isEmpty){
ForEach(todaysEvents, id: \.self) { exam in ForEach(todaysEvents, id: \.self) { exam in
Text(exam.value(forKey: "summary") as! String) Text(exam.value(forKey: "summary") as! String)
} }
} else { } else {
Text("No lectures") Text("noLectures".localized(tableName: "HomeView"))
} }
} }
} }
@ -58,16 +58,16 @@ struct HomeView: View {
) )
VStack { VStack {
Text("Tomorrow") Text("tomorrow".localized(tableName: "HomeView"))
.font(/*@START_MENU_TOKEN@*/.title/*@END_MENU_TOKEN@*/) .font(/*@START_MENU_TOKEN@*/.title/*@END_MENU_TOKEN@*/)
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
VStack { VStack {
if(tomorrowsEvents.count > 0){ if(!tomorrowsEvents.isEmpty){
ForEach(tomorrowsEvents, id: \.self) { exam in ForEach(tomorrowsEvents, id: \.self) { exam in
Text(exam.value(forKey: "summary") as! String) Text(exam.value(forKey: "summary") as! String)
} }
} else { } else {
Text("No lectures") Text("noLectures".localized(tableName: "HomeView"))
} }
} }
} }
@ -85,16 +85,16 @@ struct HomeView: View {
Spacer() Spacer()
VStack { VStack {
Text("Upcoming exams") Text("upcomingExams".localized(tableName: "HomeView"))
.font(/*@START_MENU_TOKEN@*/.title/*@END_MENU_TOKEN@*/) .font(/*@START_MENU_TOKEN@*/.title/*@END_MENU_TOKEN@*/)
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
VStack { VStack {
if(upcomingExams.count > 0){ if(!upcomingExams.isEmpty){
ForEach(upcomingExams, id: \.self) { exam in ForEach(upcomingExams, id: \.self) { exam in
Text(exam.value(forKey: "summary") as! String) Text(exam.value(forKey: "summary") as! String)
} }
} else { } else {
Text("No exams") Text("noExams".localized(tableName: "HomeView"))
} }
} }
} }
@ -136,7 +136,7 @@ extension HomeView{
predicates.append(contentsOf: getDayPredicates(today: true)) predicates.append(contentsOf: getDayPredicates(today: true))
let compoundPredicate = NSCompoundPredicate(andPredicateWithSubpredicates: predicates) let compoundPredicate = NSCompoundPredicate(andPredicateWithSubpredicates: predicates)
let events = UtilityFunctions.getCoreDataObject(entity: "RaPlaEvent", searchPredicate: compoundPredicate) let events = UtilityFunctions.getCoreDataObject(entity: "RaPlaEvent", searchPredicate: compoundPredicate)
if(events.count > 0) { if(!events.isEmpty) {
return Array(events[...min(1, events.count-1)]) return Array(events[...min(1, events.count-1)])
} else { } else {
return [] return []
@ -150,7 +150,7 @@ extension HomeView{
predicates.append(contentsOf: getDayPredicates(tomorrow: true)) predicates.append(contentsOf: getDayPredicates(tomorrow: true))
let compoundPredicate = NSCompoundPredicate(andPredicateWithSubpredicates: predicates) let compoundPredicate = NSCompoundPredicate(andPredicateWithSubpredicates: predicates)
let events = UtilityFunctions.getCoreDataObject(entity: "RaPlaEvent", searchPredicate: compoundPredicate) let events = UtilityFunctions.getCoreDataObject(entity: "RaPlaEvent", searchPredicate: compoundPredicate)
if(events.count > 0) { if(!events.isEmpty) {
return Array(events[...min(1, events.count-1)]) return Array(events[...min(1, events.count-1)])
} else { } else {
return [] return []
@ -164,7 +164,7 @@ extension HomeView{
let sectionSortDescriptor = NSSortDescriptor(key: "startDate", ascending: true) let sectionSortDescriptor = NSSortDescriptor(key: "startDate", ascending: true)
let sortDescriptors = [sectionSortDescriptor] let sortDescriptors = [sectionSortDescriptor]
let events = UtilityFunctions.getCoreDataObject(entity: "RaPlaEvent", sortDescriptors: sortDescriptors, searchPredicate: compoundPredicate) 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)]) return Array(events[...min(1, events.count-1)])
} else { } else {
return [] return []