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