Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

## master

### Fixed
- Fix creating empty files when spreadsheet doesn't contain any plurals or only plurals ([#20](https://github.com/AckeeCZ/ACKLocalization/pull/17), kudos to @olejnjak)

## 1.1.1

### Fixed
Expand Down
14 changes: 9 additions & 5 deletions Sources/ACKLocalizationCore/ACKLocalization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,13 @@ public final class ACKLocalization {

try plistOutputs.forEach { try writeRows($1, to: dirPath + "/" + $0 + ".strings") }

// Create stringDict from data and save it
let encoder = PropertyListEncoder()
encoder.outputFormat = .xml
let data = try encoder.encode(plurals)
try data.write(to: URL(fileURLWithPath: pluralsPath))
if plurals.count > 0 {
// Create stringDict from data and save it
let encoder = PropertyListEncoder()
encoder.outputFormat = .xml
let data = try encoder.encode(plurals)
try data.write(to: URL(fileURLWithPath: pluralsPath))
}
} catch {
throw LocalizationError(message: "Unable to save mapped values - " + error.localizedDescription)
}
Expand Down Expand Up @@ -319,6 +321,8 @@ public final class ACKLocalization {

/// Actually writes given `rows` to given `file`
private func writeRows(_ rows: [LocRow], to file: String) throws {
guard rows.count > 0 else { return }

try rows.map { $0.localizableRow }
.joined(separator: "\n")
.write(toFile: file, atomically: true, encoding: .utf8)
Expand Down