Skip to content

Commit

Permalink
Release/0.2.6 (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
EgzonArifi authored Aug 11, 2023
2 parents 9a4f863 + 30c12cf commit 8b743c6
Show file tree
Hide file tree
Showing 15 changed files with 24 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--This file was generated with Lingua command line tool. Please do not change it!-->
<!--Source: https://github.com/poviolabs/Lingua-->
<!-- This file was generated with Lingua command line tool. Please do not change it! -->
<!-- Source: https://github.com/poviolabs/Lingua -->
<resources>
<string name="general_success">Erfolg</string>
<string name="general_save">Speichern</string>
</resources>
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--This file was generated with Lingua command line tool. Please do not change it!-->
<!--Source: https://github.com/poviolabs/Lingua-->
<!-- This file was generated with Lingua command line tool. Please do not change it! -->
<!-- Source: https://github.com/poviolabs/Lingua -->
<resources>
<string name="general_success">Success</string>
<string name="general_save">Save</string>
</resources>
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// swiftlint:disable all
// This file was generated with Lingua command line tool. Please do not change it!
// Source: https://github.com/poviolabs/Lingua

// swiftlint:disable all
import Foundation

enum Lingua {
enum General {

/// Save
static let save = tr("General", "save")
/// Success
static let success = tr("General", "success")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
// Source: https://github.com/poviolabs/Lingua

"success" = "Erfolg";
"save" = "Speichern";
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
// Source: https://github.com/poviolabs/Lingua

"success" = "Success";
"save" = "Save";
2 changes: 1 addition & 1 deletion Sources/Lingua/Common/Extensions/String+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation

extension String {
static let packageName = "Lingua"
static let version = "0.2.4"
static let version = "0.2.6"
static let swiftLocalizedName = "\(String.packageName).swift"
static let fileHeader = """
This file was generated with Lingua command line tool. Please do not change it!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ struct AndroidStringEscaper: StringEscaping {
escapedString = escapedString.replacingOccurrences(of: "\"", with: "\\&quot;")
escapedString = escapedString.replacingOccurrences(of: "'", with: "\\&apos;")

debugPrint(string)
debugPrint(escapedString)
return escapedString
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ struct IOSNonPluralFormatter: LocalizedContentFormatting {
}

func wrapContent(_ content: String) -> String {
[String.fileHeader.commentOut(for: .ios), content].joined(separator: "\n")
String.fileHeader.commentOut(for: .ios) + "\n\n" + content
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ import Foundation

struct IOSStringEscaper: StringEscaping {
func escapeSpecialCharacters(in string: String) -> String {
var escapedString = string
escapedString = escapedString.replacingOccurrences(of: "\\", with: "\\\\")
escapedString = escapedString.replacingOccurrences(of: "\"", with: "\\\"")
escapedString = escapedString.replacingOccurrences(of: "@", with: "\\@")
return escapedString
string.replacingOccurrences(of: "\"", with: "\\\"")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ struct DefaultLocalizedSwiftCodeOutputStringBuilder: LocalizedSwiftCodeOutputStr
let sectionsOutput = buildSectionsOutput(sections: sections, translations: translations)

let output = """
// swiftlint:disable all
\(String.fileHeader.commentOut(for: .ios))
// swiftlint:disable all
import Foundation
enum \(String.packageName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private extension LocalizedSwiftCodeGenerator {
private extension String {
func commented() -> String {
components(separatedBy: "\n")
.map { "\n\t\t/// \($0)" }
.joined()
.map { "/// \($0)" }
.joined(separator: "\n\t\t")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class IOSNonPluralFormatterTests: XCTestCase {
let content = "content"
let sut = makeSUT()
let wrappedContent = sut.wrapContent(content)
let expectedContent = [String.fileHeader.commentOut(for: .ios), content].joined(separator: "\n")
let expectedContent = String.fileHeader.commentOut(for: .ios) + "\n\n" + content

XCTAssertEqual(expectedContent, wrappedContent)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,16 @@ import XCTest

final class IOSStringEscaperTests: XCTestCase {
func test_escapeSpecialCharacters_backslash() {
expect(original: "This is a test\\", expected: "This is a test\\\\")
expect(original: "This is a test\\", expected: "This is a test\\")
}

func test_escapeSpecialCharacters_quotes() {
expect(original: "This is a \"test\"", expected: "This is a \\\"test\\\"")
}

func test_escapeSpecialCharacters_atSymbol() {
expect(original: "This is a @test", expected: "This is a \\@test")
}

func test_escapeSpecialCharacters_multipleCharacters() {
expect(original: "This \\ is a \"test\" @ multiple characters", expected: "This \\\\ is a \\\"test\\\" \\@ multiple characters")
expect(original: "This is a \"test\" @ multiple \n characters",
expected: "This is a \\\"test\\\" @ multiple \n characters")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ final class DefaultLocalizedSwiftCodeOutputStringBuilderTests: XCTestCase {
let output = sut.buildOutput(sections: sections, translations: translations)

let expectedOutput = """
// swiftlint:disable all
// This file was generated with Lingua command line tool. Please do not change it!
// Source: https://github.com/poviolabs/Lingua
// swiftlint:disable all
import Foundation
enum Lingua {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ final class LocalizedSwiftCodeGeneratorTests: XCTestCase {
let sut = makeSUT()
let code = sut.generateCode(section: "section", key: "key", translation: "translation %d %@")
let expectedCode = """
\n\t\t/// translation %d %@
/// translation %d %@
\t\tstatic func key(_ param1: Int, _ param2: String) -> String {
\t\t\treturn tr("section", "key", param1, param2)
\t\t}
Expand All @@ -17,7 +17,7 @@ final class LocalizedSwiftCodeGeneratorTests: XCTestCase {
func test_generateCode_createsStaticPropertyCode_forNoStringFormatSpecifiers() {
let sut = makeSUT()
let code = sut.generateCode(section: "section", key: "key", translation: "translation")
XCTAssertEqual(code, "\n\t\t/// translation\n\t\tstatic let key = tr(\"section\", \"key\")")
XCTAssertEqual(code, "/// translation\n\t\tstatic let key = tr(\"section\", \"key\")")
}
}

Expand Down

0 comments on commit 8b743c6

Please sign in to comment.