Fix architecture generation and add enum key of each string in R2String
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit
This commit is contained in:
@ -111,6 +111,7 @@ class StringsFileGenerator {
|
||||
static func getExtensionContent(sections: [Section], defaultLang lang: String, tags: [String], staticVar: Bool, inputFilename: String, extensionName: String) -> String {
|
||||
[
|
||||
Self.getHeader(stringsFilename: inputFilename, extensionClassname: extensionName),
|
||||
Self.getEnumKey(sections: sections, tags: tags),
|
||||
Self.getProperties(sections: sections, defaultLang: lang, tags: tags, staticVar: staticVar),
|
||||
Self.getFooter()
|
||||
]
|
||||
@ -131,6 +132,29 @@ class StringsFileGenerator {
|
||||
"""
|
||||
}
|
||||
|
||||
private static func getEnumKey(sections: [Section], tags: [String]) -> String {
|
||||
var enumDefinition = "\n enum Key: String {\n"
|
||||
|
||||
sections.forEach { section in
|
||||
// Check that at least one string will be generated
|
||||
guard section.hasOneOrMoreMatchingTags(tags: tags) else {
|
||||
return // Go to next section
|
||||
}
|
||||
|
||||
section.definitions.forEach { definition in
|
||||
guard definition.hasOneOrMoreMatchingTags(inputTags: tags) == true else {
|
||||
return // Go to next definition
|
||||
}
|
||||
debugPrint("Found definition")
|
||||
enumDefinition += " case \(definition.name) = \"\(definition.name)\"\n"
|
||||
}
|
||||
}
|
||||
|
||||
enumDefinition += " }"
|
||||
|
||||
return enumDefinition
|
||||
}
|
||||
|
||||
private static func getProperties(sections: [Section], defaultLang lang: String, tags: [String], staticVar: Bool) -> String {
|
||||
sections.compactMap { section in
|
||||
// Check that at least one string will be generated
|
||||
|
Reference in New Issue
Block a user