Optional generation of extension (R.xx)

Optional generation of Colors/Fonts/Images/Stringium extension

Fix swiftlint warning
This commit is contained in:
2025-07-17 09:39:43 +02:00
parent c3b8ebfb37
commit 3092376b65
34 changed files with 973 additions and 688 deletions

View File

@ -21,7 +21,6 @@ struct Stringium: ParsableCommand {
// MARK: - Static
static let toolName = "Stringium"
static let defaultExtensionName = "String"
static let noTranslationTag: String = "notranslation"
// MARK: - Command options
@ -49,8 +48,7 @@ struct Stringium: ParsableCommand {
langs: options.langs,
defaultLang: options.defaultLang,
tags: options.tags,
outputPath: options.stringsFileOutputPath,
inputFilenameWithoutExt: options.inputFilenameWithoutExt
lprojPathFormat: options.lprojPathFormat
)
} else {
StringsFileGenerator.writeXcStringsFiles(
@ -58,22 +56,25 @@ struct Stringium: ParsableCommand {
langs: options.langs,
defaultLang: options.defaultLang,
tags: options.tags,
outputPath: options.stringsFileOutputPath,
inputFilenameWithoutExt: options.inputFilenameWithoutExt
xcStringsFilePath: options.xcStringsFilePath
)
}
// Generate extension
StringsFileGenerator.writeExtensionFiles(
sections: sections,
defaultLang: options.defaultLang,
tags: options.tags,
staticVar: options.staticMembers,
inputFilename: options.inputFilenameWithoutExt,
extensionName: options.extensionName,
extensionFilePath: options.extensionFilePath,
extensionSuffix: options.extensionSuffix
)
if let extensionName = options.extensionName,
let extensionFilePath = options.extensionFilePath {
print("Will generate extensions")
StringsFileGenerator.writeExtensionFiles(
sections: sections,
defaultLang: options.defaultLang,
tags: options.tags,
staticVar: options.staticMembers,
inputFilename: options.inputFilenameWithoutExt,
extensionName: extensionName,
extensionFilePath: extensionFilePath,
extensionSuffix: options.extensionSuffix ?? ""
)
}
print("[\(Self.toolName)] Strings generated")
}
@ -104,10 +105,18 @@ struct Stringium: ParsableCommand {
}
// Check if needed to regenerate
let fileToCompareToInput: String = {
// If there is no extension file to compare
// Then check the xcassets file instead
if options.xcStrings {
return options.xcStringsFilePath
}
return String(format: options.lprojPathFormat, options.defaultLang)
}()
guard GeneratorChecker.shouldGenerate(
force: options.forceGeneration,
inputFilePath: options.inputFile,
extensionFilePath: options.extensionFilePath
extensionFilePath: fileToCompareToInput
) else {
print("[\(Self.toolName)] Strings are already up to date :) ")
return false