-
Notifications
You must be signed in to change notification settings - Fork 8
Conversation
This might require additional Unit Tests though, especially at least one expected output containing multiple tables (to be sure we don't override entries on every new table added for example) Also, what about if the tables have the same name, because the user misunderstood the feature and passes Should we make the last one override the previous ones? Merge them? Generate an |
Hmmm. I think we should throw an error if the user provides multiple tables with the same name. And this error should be thrown by SwiftGenKit, not in Stencil. If a user wants to generate code for 2 different targets, then they should run it twice. |
093ae46
to
29ea509
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than the wording, LGTM
|
||
public var description: String { | ||
switch self { | ||
case .failureOnLoading(let path): | ||
return "Failed to load a file at \"\(path)\"" | ||
case .invalidFormat: | ||
return "Invalid strings file" | ||
case .duplicateTable(let name): | ||
return "Table \"\(name)\" already loaded, cannot add it again" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The real problem isn't that we cannot add it again (to be fair, we could totally merge the entries form both tables in a single context entry), but more that it wouldn't make sense, because:
- either both tables with the same name come from the same target but for different languages so that would lead to parsing the same entries — just with different translations
- or because they come from different targets (a framework and an app for example) and that wouldn't make sense to merge them in a single huge file while they should be split in different files belonging to their respective targets
So maybe we should find a better wording/explanation for this error? Like this?
Duplicate table \"\(name)\". Only provide all your strings files for a *single* language (typically your base language) from *one* given target (app or framework).
Or if you have a better wording don't hesitate 😉
29ea509
to
61c2162
Compare
@djbe Rebased but with conflicts so I'll let you double-check (esp the sync with SwiftGen/templates#49) before merging |
61c2162
to
1634f06
Compare
1634f06
to
52dafe3
Compare
This partially adresses SwiftGen/SwiftGen#39, it would still need an implementation on the SwiftGen (CLI) side, and of course also one on the templates side.
Refs SwiftGen/templates#49