Skip to content

Commit

Permalink
Force localization string extraction
Browse files Browse the repository at this point in the history
Our translatable string extractor is currently broken.
As such, only the strings inside Text() or NSLocalizedString()
are currently being extracted for localization.
(See #1183 (comment)
for more details)

This commit makes sure to use Text() and NSLocalizedString()
Note: I did not check the entire codebase for non-extractable strings.
It's possible that there are more.
  • Loading branch information
lissine0 authored and tmolitor-stud-tu committed Jan 4, 2025
1 parent 83453c4 commit c907070
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Monal/Classes/AddContactMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ struct AddContactMenu: View {
MLQRCodeScanner(handleClose: {
self.showQRCodeScanner = false
})
.navigationTitle("QR-Code Scanner")
.navigationTitle(Text("QR-Code Scanner"))
.navigationBarTitleDisplayMode(.inline)
.toolbar(content: {
ToolbarItem(placement: .navigationBarLeading, content: {
Expand Down
12 changes: 6 additions & 6 deletions Monal/Classes/BlockedUsers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct BlockedUsers: View {

var body: some View {
if showBlockingUnsupportedPlaceholder {
ContentUnavailableShimView("Blocking unsupported", systemImage: "iphone.homebutton.slash", description: Text("Your server does not support blocking (XEP-0191)."))
ContentUnavailableShimView(NSLocalizedString("Blocking unsupported", comment: ""), systemImage: "iphone.homebutton.slash", description: Text("Your server does not support blocking (XEP-0191)."))
} else {
List {
ForEach(blockedJids, id: \.self) { blockedJid in
Expand All @@ -42,7 +42,7 @@ struct BlockedUsers: View {
}
}
.listStyle(.plain)
.navigationTitle("Blocked Users")
.navigationTitle(Text("Blocked Users"))
.animation(.default, value: blockedJids)
.onAppear {
if !(xmppAccount.accountState.rawValue >= xmppState.stateBound.rawValue && xmppAccount.connectionProperties.accountDiscoDone) {
Expand Down Expand Up @@ -84,13 +84,13 @@ struct BlockedUsers: View {
})
}
}
.alert("Enter the jid that you want to block", isPresented: $showAddingToBlocklistForm, actions: {
.alert(NSLocalizedString("Enter the jid that you want to block", comment: ""), isPresented: $showAddingToBlocklistForm, actions: {
TextField("[email protected]/resource", text: $jidToBlock)
.textInputAutocapitalization(.never)
.keyboardType(.emailAddress)
.autocorrectionDisabled()

Button("Block", role: .destructive) {
Button(NSLocalizedString("Block", comment: ""), role: .destructive) {
guard (jidToBlock.range(of: BlockedUsers.jidPattern, options: .regularExpression) != nil) else {
showInvalidJidAlert = true
return
Expand All @@ -101,7 +101,7 @@ struct BlockedUsers: View {
MLXMPPManager.sharedInstance().block(true, fullJid: jidToBlock, onAccount: self.xmppAccount.accountID)
}

Button("Cancel", role: .cancel, action: {})
Button(NSLocalizedString("Cancel", comment: ""), role: .cancel, action: {})
}
)
// If .onDisappear is applied to the alert or any of its subviews, its perform action won't
Expand All @@ -112,7 +112,7 @@ struct BlockedUsers: View {
jidToBlock = ""
}
}
.alert("Input is not a valid jid", isPresented: $showInvalidJidAlert, actions: {})
.alert(NSLocalizedString("Input is not a valid jid", comment: ""), isPresented: $showInvalidJidAlert, actions: {})
.addLoadingOverlay(overlay)
}
}
Expand Down
2 changes: 1 addition & 1 deletion Monal/Classes/ContactPicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ struct ContactPicker: View {
var body: some View {
if(allContacts.isEmpty) {
Text("No contacts to show :(")
.navigationTitle("Contact Lists")
.navigationTitle(Text("Contact Lists"))
} else {
List(searchResults) { contact in
let contactIsSelected = self.selectedContacts.contains(contact);
Expand Down
2 changes: 1 addition & 1 deletion Monal/Classes/ContactsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ struct ContactsView: View {
}
}
.animation(.default, value: contactList)
.navigationTitle("Contacts")
.navigationTitle(Text("Contacts"))
.listStyle(.plain)
.searchable(text: $searchText, placement: .navigationBarDrawer(displayMode: .always))
.autocorrectionDisabled()
Expand Down
2 changes: 1 addition & 1 deletion Monal/Classes/MediaGallery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct MediaGalleryView: View {
}
.padding()
}
.navigationTitle("Shared Media")
.navigationTitle(Text("Shared Media"))
.onAppear {
fetchDownloadedMediaItems()
}
Expand Down
4 changes: 2 additions & 2 deletions Monal/Classes/WelcomeLogIn.swift
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ struct WelcomeLogIn: View {
.listRowSeparator(.hidden)

if advancedMode {
TextField("Optional Hardcoded Hostname", text: $hardcodedServer)
TextField(NSLocalizedString("Optional Hardcoded Hostname", comment: "advanced account settings"), text: $hardcodedServer)
.textInputAutocapitalization(.never)
.autocorrectionDisabled()
.keyboardType(.URL)
Expand All @@ -192,7 +192,7 @@ struct WelcomeLogIn: View {
HStack {
Text("Port")
Spacer()
TextField("Optional Hardcoded Port", text: $hardcodedPort)
TextField(NSLocalizedString("Optional Hardcoded Port", comment: "advanced account settings"), text: $hardcodedPort)
.keyboardType(.numberPad)
.addClearButton(isEditing: hardcodedPort.count > 0, text: $hardcodedPort)
.onDisappear {
Expand Down

0 comments on commit c907070

Please sign in to comment.