Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StringsDicts support #16

Merged
merged 18 commits into from
Aug 24, 2020
Merged

StringsDicts support #16

merged 18 commits into from
Aug 24, 2020

Conversation

LukasHromadnik
Copy link
Contributor

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.

@github-actions
Copy link

@LukasHromadnik your pull request is missing a changelog!

@olejnjak olejnjak requested review from olejnjak and fortmarek August 21, 2020 11:10
Copy link
Member

@olejnjak olejnjak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am also missing some tests regarding this feature 🤔

Sources/ACKLocalizationCore/ACKLocalization.swift Outdated Show resolved Hide resolved
ACKLocalization.podspec Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@olejnjak olejnjak self-requested a review August 21, 2020 12:46
Copy link
Member

@olejnjak olejnjak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well right now I think we're just missing the tests 🙂

Copy link
Contributor

@fortmarek fortmarek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two minor comments, otherwise seems good, can't wait for this to land !

Sources/ACKLocalizationCore/ACKLocalization.swift Outdated Show resolved Hide resolved
Sources/ACKLocalizationCore/ACKLocalization.swift Outdated Show resolved Hide resolved
@olejnjak olejnjak self-requested a review August 24, 2020 10:10
}
}

class SheetsAPIServiceMock: SheetsAPIServicing {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a nitpick, if ACKLocalizationPluralsTests is final I would also make this class final

import XCTest
@testable import ACKLocalizationCore

class AuthAPIServiceMock: AuthAPIServicing {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a nitpick, if ACKLocalizationPluralsTests is final I would also make this class final

@LukasHromadnik
Copy link
Contributor Author

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 PluralError so the script won't complete until all plural keys are fine

@olejnjak olejnjak requested review from olejnjak and fortmarek August 24, 2020 12:20
case invalidPluralRule(String)
}

extension PluralError: Equatable {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Equatable should be automatically synthesized, shouldn't it?

LocRow(key: "##{zero}", value: "zero")
]

XCTAssertThrowsError(try ackLocalization.buildPlurals(from: rows)) { error in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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))

@fortmarek fortmarek self-requested a review August 24, 2020 18:39
@LukasHromadnik LukasHromadnik merged commit be7341f into master Aug 24, 2020
@LukasHromadnik LukasHromadnik deleted the feature/stringsDict branch August 24, 2020 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants