Merge pull request #396 from oxen-io/localization

Remove Unused Strings
This commit is contained in:
Niels Andriesse 2021-04-29 15:21:43 +10:00 committed by GitHub
commit 795d7bbf1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 49 additions and 30188 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,38 @@
#!/usr/bin/env xcrun swift
import Foundation
// The way this works is:
// Run the AbandonedStrings executable (see https://www.avanderlee.com/xcode/unused-localized-strings/)
// Paste the list of unused strings below
// Run this script by doing:
// swiftc remove_unused_strings.swift
// ./remove_unused_strings
let unusedStringKeys = [
]
let allFileURLs = try! FileManager.default.contentsOfDirectory(at: URL(string: "./")!, includingPropertiesForKeys: nil)
let translationFiles = allFileURLs.map { $0.lastPathComponent }.filter { $0.hasSuffix(".lproj") }
for translationFile in translationFiles {
let contents = try! String(contentsOfFile: "\(translationFile)/Localizable.strings")
let lines = contents.split(separator: "\n")
var filteredLines0: [String] = []
for line in lines {
if !unusedStringKeys.contains(where: { line.hasPrefix("\"\($0)\"") }) {
filteredLines0.append(String(line))
}
}
var filteredLines1: [String] = []
for (index, line) in filteredLines0.enumerated() {
if line.hasPrefix("/*") && index != (filteredLines0.count - 1) && filteredLines0[index + 1].hasPrefix("/*") {
// Orphaned comment; drop it
} else {
filteredLines1.append(line)
}
}
let newContents = filteredLines1.joined(separator: "\n")
try newContents.write(to: URL(fileURLWithPath: "\(FileManager.default.currentDirectoryPath)/\(translationFile)/Localizable.strings"), atomically: true, encoding: String.Encoding.utf8)
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -52,7 +52,7 @@ final class LandingVC : BaseVC {
let bottomSpacer = UIView.vStretchingSpacer()
// Link button
let linkButton = UIButton()
linkButton.setTitle("Link a Device", for: UIControl.State.normal)
linkButton.setTitle(NSLocalizedString("vc_landing_link_button_title", comment: ""), for: UIControl.State.normal)
linkButton.setTitleColor(Colors.text, for: UIControl.State.normal)
linkButton.titleLabel!.font = .boldSystemFont(ofSize: Values.smallFontSize)
linkButton.addTarget(self, action: #selector(link), for: UIControl.Event.touchUpInside)

View file

@ -14,7 +14,7 @@ final class LinkDeviceVC : BaseVC, UIPageViewControllerDataSource, UIPageViewCon
guard let self = self else { return }
self.pageVC.setViewControllers([ self.pages[0] ], direction: .forward, animated: false, completion: nil)
},
TabBar.Tab(title: "Scan QR Code") { [weak self] in
TabBar.Tab(title: NSLocalizedString("vc_link_device_scan_qr_code_tab_title", comment: "")) { [weak self] in
guard let self = self else { return }
self.pageVC.setViewControllers([ self.pages[1] ], direction: .forward, animated: false, completion: nil)
}
@ -46,7 +46,7 @@ final class LinkDeviceVC : BaseVC, UIPageViewControllerDataSource, UIPageViewCon
super.viewDidLoad()
setUpGradientBackground()
setUpNavBarStyle()
setNavBarTitle("Link a Device")
setNavBarTitle(NSLocalizedString("vc_link_device_title", comment: ""))
let navigationBar = navigationController!.navigationBar
// Page VC
let hasCameraAccess = (AVCaptureDevice.authorizationStatus(for: .video) == .authorized)