Merge pull request #1491 from JPKribs/webplates

[Meta] Fix Webplates
This commit is contained in:
Bill Thornton 2025-04-11 22:50:22 -04:00 committed by GitHub
commit 78feccca14
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View File

@ -16,7 +16,7 @@ let fileURL = URL(fileURLWithPath: "./Translations/en.lproj/Localizable.strings"
let regex = #/^\"(?<key>[^\"]+)\"\s*=\s*\"(?<value>[^\"]+)\";/# let regex = #/^\"(?<key>[^\"]+)\"\s*=\s*\"(?<value>[^\"]+)\";/#
// Attempt to read the file content. // Attempt to read the file content.
guard let content = try? String(contentsOf: fileURL, encoding: .utf8) else { guard let content = try? String(contentsOf: fileURL, encoding: .utf16) else {
print("Unable to read file: \(fileURL.path)") print("Unable to read file: \(fileURL.path)")
exit(1) exit(1)
} }
@ -43,10 +43,10 @@ let newContent = sortedKeys.map { "/// \(entries[$0]!)\n\"\($0)\" = \"\(entries[
// Write the updated, sorted, and commented localizations back to the file. // Write the updated, sorted, and commented localizations back to the file.
do { do {
try newContent.write(to: fileURL, atomically: true, encoding: .utf8) try newContent.write(to: fileURL, atomically: true, encoding: .utf16)
if let derivedFileDirectory = ProcessInfo.processInfo.environment["DERIVED_FILE_DIR"] { if let derivedFileDirectory = ProcessInfo.processInfo.environment["DERIVED_FILE_DIR"] {
try? "".write(toFile: derivedFileDirectory + "/alphabetizeStrings.txt", atomically: true, encoding: .utf8) try? "".write(toFile: derivedFileDirectory + "/alphabetizeStrings.txt", atomically: true, encoding: .utf16)
} }
} catch { } catch {
print("Error: Failed to write to \(fileURL.path)") print("Error: Failed to write to \(fileURL.path)")