StringsDicts support#16
Conversation
|
@LukasHromadnik your pull request is missing a changelog! |
olejnjak
left a comment
There was a problem hiding this comment.
I am also missing some tests regarding this feature 🤔
olejnjak
left a comment
There was a problem hiding this comment.
Well right now I think we're just missing the tests 🙂
fortmarek
left a comment
There was a problem hiding this comment.
two minor comments, otherwise seems good, can't wait for this to land !
| } | ||
| } | ||
|
|
||
| class SheetsAPIServiceMock: SheetsAPIServicing { |
There was a problem hiding this comment.
just a nitpick, if ACKLocalizationPluralsTests is final I would also make this class final
| import XCTest | ||
| @testable import ACKLocalizationCore | ||
|
|
||
| class AuthAPIServiceMock: AuthAPIServicing { |
There was a problem hiding this comment.
just a nitpick, if ACKLocalizationPluralsTests is final I would also make this class final
|
I made some changes to the plurals parser. Now we are able to determine if the translation key / plural key is missing, also all those checks throw an |
| case invalidPluralRule(String) | ||
| } | ||
|
|
||
| extension PluralError: Equatable { |
There was a problem hiding this comment.
Equatable should be automatically synthesized, shouldn't it?
| LocRow(key: "##{zero}", value: "zero") | ||
| ] | ||
|
|
||
| XCTAssertThrowsError(try ackLocalization.buildPlurals(from: rows)) { error in |
There was a problem hiding this comment.
might be nice to add a following extension for XCTest (might be handy in the future, too):
func XCTAssertThrowsSpecific<Error: Swift.Error & Equatable, T>(_ closure: @autoclosure () throws -> T, _ error: Error, file: StaticString = #file, line: UInt = #line) {
do {
_ = try closure()
} catch let closureError as Error {
XCTAssertEqual(error, closureError, file: file, line: line)
} catch let closureError {
XCTFail("\(error) is not equal to: \(closureError)", file: file, line: line)
}
}Your code can then be changed to something like this:
XCTAssertThrowsSpecific(try ackLocalization.buildPlurals(from: rows), PluralError.missingTranslationkey(rows[0].key))
In combination with SwiftGen 6.3 we are now able to support simple stringsDicts.
Currently we can handle only top level plurals. That means that nested plurals where multiple plural keys are used in one single translation key are not supported.