Merge pull request 'v1.2.2' (#5) from v1.2.2 into master
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
Reviewed-on: #5
This commit is contained in:
commit
7d6bb4fcb9
@ -6,13 +6,24 @@ fileprivate let kStringsFileName = "sampleStrings"
|
||||
|
||||
extension String {
|
||||
|
||||
enum Key: String {
|
||||
enum KeyGenAllScript: String {
|
||||
case param_lang = "param_lang"
|
||||
case generic_back = "generic_back"
|
||||
case generic_loading_data = "generic_loading_data"
|
||||
case generic_welcome_firstname_format = "generic_welcome_firstname_format"
|
||||
case test_equal_symbol = "test_equal_symbol"
|
||||
case placeholders_test_one = "placeholders_test_one"
|
||||
|
||||
var keyPath: KeyPath<String, String> {
|
||||
switch self {
|
||||
case .param_lang: return \String.param_lang
|
||||
case .generic_back: return \String.generic_back
|
||||
case .generic_loading_data: return \String.generic_loading_data
|
||||
case .generic_welcome_firstname_format: return \String.generic_welcome_firstname_format
|
||||
case .test_equal_symbol: return \String.test_equal_symbol
|
||||
case .placeholders_test_one: return \String.placeholders_test_one
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Webservice
|
||||
|
@ -2,33 +2,33 @@
|
||||
|
||||
FORCE_FLAG="$1"
|
||||
|
||||
# Font
|
||||
swift run -c release ResgenSwift fonts $FORCE_FLAG "./Fonts/sampleFontsAll.txt" \
|
||||
--extension-output-path "./Fonts/Generated" \
|
||||
--extension-name "UIFontYolo" \
|
||||
--extension-name-swift-ui "FontYolo" \
|
||||
--extension-suffix "GenAllScript" \
|
||||
--info-plist-paths "./Fonts/Generated/test.plist ./Fonts/Generated/test2.plist"
|
||||
|
||||
echo "\n-------------------------\n"
|
||||
|
||||
# Color
|
||||
swift run -c release ResgenSwift colors $FORCE_FLAG "./Colors/sampleColors1.txt" \
|
||||
--style all \
|
||||
--xcassets-path "./Colors/colors.xcassets" \
|
||||
--extension-output-path "./Colors/Generated/" \
|
||||
--extension-name "UIColorYolo" \
|
||||
--extension-name-swift-ui "ColorYolo" \
|
||||
--extension-suffix "GenAllScript"
|
||||
|
||||
echo "\n-------------------------\n"
|
||||
|
||||
# Twine
|
||||
swift run -c release ResgenSwift strings twine $FORCE_FLAG "./Twine/sampleStrings.txt" \
|
||||
--output-path "./Twine/Generated" \
|
||||
--langs "fr en en-us" \
|
||||
--default-lang "en" \
|
||||
--extension-output-path "./Twine/Generated"
|
||||
## Font
|
||||
#swift run -c release ResgenSwift fonts $FORCE_FLAG "./Fonts/sampleFontsAll.txt" \
|
||||
# --extension-output-path "./Fonts/Generated" \
|
||||
# --extension-name "UIFontYolo" \
|
||||
# --extension-name-swift-ui "FontYolo" \
|
||||
# --extension-suffix "GenAllScript" \
|
||||
# --info-plist-paths "./Fonts/Generated/test.plist ./Fonts/Generated/test2.plist"
|
||||
#
|
||||
#echo "\n-------------------------\n"
|
||||
#
|
||||
## Color
|
||||
#swift run -c release ResgenSwift colors $FORCE_FLAG "./Colors/sampleColors1.txt" \
|
||||
# --style all \
|
||||
# --xcassets-path "./Colors/colors.xcassets" \
|
||||
# --extension-output-path "./Colors/Generated/" \
|
||||
# --extension-name "UIColorYolo" \
|
||||
# --extension-name-swift-ui "ColorYolo" \
|
||||
# --extension-suffix "GenAllScript"
|
||||
#
|
||||
#echo "\n-------------------------\n"
|
||||
#
|
||||
## Twine
|
||||
#swift run -c release ResgenSwift strings twine $FORCE_FLAG "./Twine/sampleStrings.txt" \
|
||||
# --output-path "./Twine/Generated" \
|
||||
# --langs "fr en en-us" \
|
||||
# --default-lang "en" \
|
||||
# --extension-output-path "./Twine/Generated"
|
||||
|
||||
echo "\n-------------------------\n"
|
||||
|
||||
@ -43,19 +43,19 @@ swift run -c release ResgenSwift strings stringium $FORCE_FLAG "./Strings/sample
|
||||
|
||||
echo "\n-------------------------\n"
|
||||
|
||||
# Tags
|
||||
swift run -c release ResgenSwift strings tags $FORCE_FLAG "./Tags/sampleTags.txt" \
|
||||
--lang "ium" \
|
||||
--extension-output-path "./Tags/Generated" \
|
||||
--extension-name "Tags" \
|
||||
--extension-suffix "GenAllScript"
|
||||
|
||||
echo "\n-------------------------\n"
|
||||
|
||||
# Images
|
||||
swift run -c release ResgenSwift images $FORCE_FLAG "./Images/sampleImages.txt" \
|
||||
--xcassets-path "./Images/imagium.xcassets" \
|
||||
--extension-output-path "./Images/Generated" \
|
||||
--extension-name "UIImage" \
|
||||
--extension-name-swift-ui "ImageYolo" \
|
||||
--extension-suffix "GenAllScript"
|
||||
## Tags
|
||||
#swift run -c release ResgenSwift strings tags $FORCE_FLAG "./Tags/sampleTags.txt" \
|
||||
# --lang "ium" \
|
||||
# --extension-output-path "./Tags/Generated" \
|
||||
# --extension-name "Tags" \
|
||||
# --extension-suffix "GenAllScript"
|
||||
#
|
||||
#echo "\n-------------------------\n"
|
||||
#
|
||||
## Images
|
||||
#swift run -c release ResgenSwift images $FORCE_FLAG "./Images/sampleImages.txt" \
|
||||
# --xcassets-path "./Images/imagium.xcassets" \
|
||||
# --extension-output-path "./Images/Generated" \
|
||||
# --extension-name "UIImage" \
|
||||
# --extension-name-swift-ui "ImageYolo" \
|
||||
# --extension-suffix "GenAllScript"
|
||||
|
@ -133,7 +133,7 @@ class StringsFileGenerator {
|
||||
extensionSuffix: String) -> String {
|
||||
[
|
||||
Self.getHeader(stringsFilename: inputFilename, extensionClassname: extensionName),
|
||||
Self.getEnumKey(sections: sections, tags: tags, extensionSuffix: extensionSuffix),
|
||||
Self.getEnumKey(sections: sections, tags: tags, extensionClassname: extensionName, extensionSuffix: extensionSuffix),
|
||||
Self.getProperties(sections: sections, defaultLang: lang, tags: tags, staticVar: staticVar),
|
||||
Self.getFooter()
|
||||
]
|
||||
@ -154,9 +154,10 @@ class StringsFileGenerator {
|
||||
"""
|
||||
}
|
||||
|
||||
private static func getEnumKey(sections: [Section], tags: [String], extensionSuffix: String) -> String {
|
||||
private static func getEnumKey(sections: [Section], tags: [String], extensionClassname: String, extensionSuffix: String) -> String {
|
||||
var enumDefinition = "\n enum Key\(extensionSuffix.uppercasedFirst()): String {\n"
|
||||
|
||||
// Enum
|
||||
sections.forEach { section in
|
||||
// Check that at least one string will be generated
|
||||
guard section.hasOneOrMoreMatchingTags(tags: tags) else {
|
||||
@ -172,7 +173,27 @@ class StringsFileGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
enumDefinition += " }"
|
||||
// KeyPath accessors
|
||||
enumDefinition += "\n"
|
||||
enumDefinition += " var keyPath: KeyPath<\(extensionClassname), String> {\n"
|
||||
enumDefinition += " switch self {\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): return \\\(extensionClassname).\(definition.name)\n"
|
||||
}
|
||||
}
|
||||
enumDefinition += " }\n" // Switch
|
||||
enumDefinition += " }\n" // var keyPath
|
||||
enumDefinition += " }" // Enum
|
||||
|
||||
return enumDefinition
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user