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
4 changes: 2 additions & 2 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ let package = Package(
.package(url: "https://github.com/richardpiazza/CoreDataPlus.git", from: "0.5.0"),
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.7.1"),
.package(url: "https://github.com/apple/swift-syntax.git", from: "509.0.0"),
.package(url: "https://github.com/CoreOffice/XMLCoder.git", from: "0.17.1"),
.package(url: "https://github.com/CoreOffice/XMLCoder.git", from: "0.18.1"),
.package(url: "https://github.com/stephencelis/SQLite.swift.git", from: "0.16.0"),
],
targets: [
Expand Down
1 change: 1 addition & 0 deletions Sources/TranslationCatalog/Catalog.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Foundation

/// Interface providing storage and retrieval of the `Expression`s and associated `Translation`s.
public protocol Catalog {

// MARK: - Project

/// Retrieve all `Project`s in the catalog.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ extension FilesystemContainer {
}

extension FilesystemContainer {

// MARK: - Project

public func projects() throws -> [Project] {
Expand Down
2 changes: 1 addition & 1 deletion Sources/TranslationCatalogIO/Internal/Resource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct Resource: Codable, DynamicNodeDecoding, DynamicNodeEncoding {
let value: String
let formatted: Bool?

static func nodeDecoding(for key: CodingKey) -> XMLDecoder.NodeDecoding {
static func nodeDecoding(for key: any CodingKey) -> XMLDecoder.NodeDecoding {
switch key {
case CodingKeys.name, CodingKeys.formatted:
.attribute
Expand Down
11 changes: 3 additions & 8 deletions Sources/TranslationCatalogIO/Internal/StringsXml.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ struct StringsXml: Codable, DynamicNodeDecoding, DynamicNodeEncoding {

let resources: [Resource]

static func nodeDecoding(for key: CodingKey) -> XMLDecoder.NodeDecoding {
static func nodeDecoding(for key: any CodingKey) -> XMLDecoder.NodeDecoding {
.element
}

Expand All @@ -28,20 +28,15 @@ struct StringsXml: Codable, DynamicNodeDecoding, DynamicNodeEncoding {

func encoded() throws -> Data {
let encoder = XMLEncoder()
encoder.outputFormatting = [.sortedKeys]
let encoded = try encoder.encode(
encoder.outputFormatting = [.sortedKeys, .prettyPrinted]
return try encoder.encode(
self,
withRootKey: "resources",
header: XMLHeader(
version: 1.0,
encoding: "UTF-8"
)
)
var string = String(decoding: encoded, as: UTF8.self)
string = string.replacingOccurrences(of: "><resources>", with: ">\n<resources>")
string = string.replacingOccurrences(of: "><string", with: ">\n <string")
string = string.replacingOccurrences(of: "></resources>", with: ">\n</resources>")
return string.data(using: .utf8) ?? encoded
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ extension SQLiteStatement {
// MARK: - Expression (Queries)

extension SQLiteStatement {

// MARK: Select Expressions

static var selectAllFromExpression: Self {
Expand Down
28 changes: 14 additions & 14 deletions Tests/LocalizerTests/ExportTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ struct ExportTests {
#expect(output == """
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<string name="APPLICATION_NAME">Lingua</string>
<string name="GREETING">Hello World!</string>
<string name="HIDDEN_MESSAGE"></string>
<string name="PLATFORM_ANDROID">Android</string>
<string name="PLATFORM_APPLE">Apple</string>
<string name="PLATFORM_WEB">Web</string>
<string name="APPLICATION_NAME">Lingua</string>
<string name="GREETING">Hello World!</string>
<string name="HIDDEN_MESSAGE"></string>
<string name="PLATFORM_ANDROID">Android</string>
<string name="PLATFORM_APPLE">Apple</string>
<string name="PLATFORM_WEB">Web</string>
</resources>

""")
Expand All @@ -107,8 +107,8 @@ struct ExportTests {
#expect(output == """
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<string name="GREETING">Hola Mundo!</string>
<string name="HIDDEN_MESSAGE">solo en español</string>
<string name="GREETING">Hola Mundo!</string>
<string name="HIDDEN_MESSAGE">solo en español</string>
</resources>

""")
Expand All @@ -126,12 +126,12 @@ struct ExportTests {
#expect(output == """
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<string name="APPLICATION_NAME">Lingua</string>
<string name="GREETING">Hola Mundo!</string>
<string name="HIDDEN_MESSAGE">solo en español</string>
<string name="PLATFORM_ANDROID">Android</string>
<string name="PLATFORM_APPLE">Apple</string>
<string name="PLATFORM_WEB">Web</string>
<string name="APPLICATION_NAME">Lingua</string>
<string name="GREETING">Hola Mundo!</string>
<string name="HIDDEN_MESSAGE">solo en español</string>
<string name="PLATFORM_ANDROID">Android</string>
<string name="PLATFORM_APPLE">Apple</string>
<string name="PLATFORM_WEB">Web</string>
</resources>

""")
Expand Down
6 changes: 3 additions & 3 deletions Tests/TranslationCatalogTests/ExpressionEncoderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ struct ExpressionEncoderTests {
#expect(output == """
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<string name="EXP_01">Hello World!</string>
<string name="EXP_02">Hello %s!</string>
<string formatted="false" name="EXP_03">Hello %s, welcome to %s!</string>
<string name="EXP_01">Hello World!</string>
<string name="EXP_02">Hello %s!</string>
<string formatted="false" name="EXP_03">Hello %s, welcome to %s!</string>
</resources>
""")
}
Expand Down
Loading