6 Commits
2.2.0 ... 2.2.3

Author SHA1 Message Date
f1ca8e92b7 Remove unwanted lang translation when generated xcStrings catalog
All checks were successful
openium/resgen.swift/pipeline/head This commit looks good
2025-09-30 16:08:45 +02:00
Jean-Charles Neboit
436bc4b2af Fix Makefile INSTALL_DIR & man page
All checks were successful
gitea-openium/resgen.swift/pipeline/pr-master This commit looks good
gitea-openium/resgen.swift/pipeline/head This commit looks good
2025-09-11 14:28:21 +02:00
e0e561ff7f Update SwiftLint and fix some Swift 6 issues
All checks were successful
gitea-openium/resgen.swift/pipeline/head This commit looks good
2025-09-10 16:51:23 +02:00
ed4e9849e7 fix(RES-71): Checkstyle resgen analytics (#20)
All checks were successful
gitea-openium/resgen.swift/pipeline/head This commit looks good
Reviewed-on: #20
Reviewed-by: Thibaut Schmitt <t.schmitt@openium.fr>
Co-authored-by: Quentin Bandera <q.bandera@openium.fr>
Co-committed-by: Quentin Bandera <q.bandera@openium.fr>
2025-08-26 08:51:33 +02:00
ddf1d2509f Fix d'une inversion de property dans la génération des strings
All checks were successful
gitea-openium/resgen.swift/pipeline/head This commit looks good
2025-08-26 08:50:45 +02:00
2ae06867c7 Handle backslash in xcstrings file generation
All checks were successful
gitea-openium/resgen.swift/pipeline/head This commit looks good
2025-08-04 10:38:45 +02:00
22 changed files with 134 additions and 127 deletions

View File

@@ -1,7 +1,6 @@
SHELL = /bin/zsh SHELL = /bin/zsh
#INSTALL_DIR ?= /usr/local/bin INSTALL_DIR = /usr/local/bin
INSTALL_DIR = /tmp/ResgenYolo
MAN_DIR := /usr/local/share/man MAN_DIR := /usr/local/share/man
MAN_PAGE_NAME = resgen-swift.1 MAN_PAGE_NAME = resgen-swift.1
@@ -14,7 +13,7 @@ BUILD_DIR = $(REPO_DIR)/.build
# create-man-files: # create-man-files:
# swift package plugin generate-manual # swift package plugin generate-manual
# cp $(BUILDDIR)/plugins/GenerateManualPlugin/outputs/ResgenSwift/resgen-swift.1 $(REPODIR)/man/resgen-swift.1 # cp $(BUILDDIR)/plugins/GenerateManual/outputs/ResgenSwift/resgen-swift.1 $(REPODIR)/man/resgen-swift.1
# install-man-files: # install-man-files:
# mkdir -p ${DESTDIR}${mandir}/man1 # mkdir -p ${DESTDIR}${mandir}/man1
@@ -23,7 +22,7 @@ BUILD_DIR = $(REPO_DIR)/.build
create-and-install-man-files: create-and-install-man-files:
swift package plugin generate-manual swift package plugin generate-manual
mkdir -p ${MAN_DIR}/man1 mkdir -p ${MAN_DIR}/man1
cp $(BUILD_DIR)/plugins/GenerateManualPlugin/outputs/ResgenSwift/${MAN_PAGE_NAME} ${MAN_DIR}/man1/${MAN_PAGE_NAME} cp $(BUILD_DIR)/plugins/GenerateManual/outputs/ResgenSwift/${MAN_PAGE_NAME} ${MAN_DIR}/man1/${MAN_PAGE_NAME}
# #
# Build and install # Build and install

View File

@@ -1,4 +1,5 @@
{ {
"originHash" : "fae67d9ce14b6664edc4151ad1a55b74d50d7281499f09eeca50b0376d0f837f",
"pins" : [ "pins" : [
{ {
"identity" : "swift-argument-parser", "identity" : "swift-argument-parser",
@@ -14,8 +15,8 @@
"kind" : "remoteSourceControl", "kind" : "remoteSourceControl",
"location" : "https://github.com/lukepistrol/SwiftLintPlugin", "location" : "https://github.com/lukepistrol/SwiftLintPlugin",
"state" : { "state" : {
"revision" : "87454f5c9ff4d644086aec2a0df1ffba678e7f3c", "revision" : "8e785a9801fc7961fef3d41ccb81acb3bd3d9735",
"version" : "0.57.1" "version" : "0.60.0"
} }
}, },
{ {
@@ -28,5 +29,5 @@
} }
} }
], ],
"version" : 2 "version" : 3
} }

View File

@@ -1,4 +1,4 @@
// swift-tools-version:5.9 // swift-tools-version:6.1
// The swift-tools-version declares the minimum version of Swift required to build this package. // The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription import PackageDescription
@@ -18,7 +18,7 @@ let package = Package(
), ),
.package( .package(
url: "https://github.com/lukepistrol/SwiftLintPlugin", url: "https://github.com/lukepistrol/SwiftLintPlugin",
exact: "0.57.1" exact: "0.60.0"
), ),
], ],
targets: [ targets: [

View File

@@ -6,7 +6,7 @@ fileprivate let kStringsFileName = "sampleStrings"
extension String { extension String {
public enum KeyGenAllScript: String { internal 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"
@@ -14,7 +14,7 @@ extension String {
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"
public var keyPath: KeyPath<String, String> { internal var keyPath: KeyPath<String, String> {
switch self { switch self {
case .param_lang: return \String.param_lang case .param_lang: return \String.param_lang
case .generic_back: return \String.generic_back case .generic_back: return \String.generic_back
@@ -33,7 +33,7 @@ extension String {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
public var param_lang: String { internal var param_lang: String {
NSLocalizedString("param_lang", tableName: kStringsFileName, bundle: Bundle.main, value: "en", comment: "") NSLocalizedString("param_lang", tableName: kStringsFileName, bundle: Bundle.main, value: "en", comment: "")
} }
@@ -44,17 +44,17 @@ extension String {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
public var generic_back: String { internal var generic_back: String {
NSLocalizedString("generic_back", tableName: kStringsFileName, bundle: Bundle.main, value: "Back", comment: "") NSLocalizedString("generic_back", tableName: kStringsFileName, bundle: Bundle.main, value: "Back", comment: "")
} }
/// Translation in en : /// Translation in en :
/// Loading data... /// Loading\ndata...
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
public var generic_loading_data: String { internal var generic_loading_data: String {
NSLocalizedString("generic_loading_data", tableName: kStringsFileName, bundle: Bundle.main, value: "Loading data...", comment: "") NSLocalizedString("generic_loading_data", tableName: kStringsFileName, bundle: Bundle.main, value: "Loading\ndata...", comment: "")
} }
/// Translation in en : /// Translation in en :
@@ -62,7 +62,7 @@ extension String {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
public var generic_welcome_firstname_format: String { internal var generic_welcome_firstname_format: String {
NSLocalizedString("generic_welcome_firstname_format", tableName: kStringsFileName, bundle: Bundle.main, value: "Welcome \"%@\" !", comment: "") NSLocalizedString("generic_welcome_firstname_format", tableName: kStringsFileName, bundle: Bundle.main, value: "Welcome \"%@\" !", comment: "")
} }
/// Translation in en : /// Translation in en :
@@ -70,7 +70,7 @@ extension String {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
public func generic_welcome_firstname_format(arg0: String) -> String { internal func generic_welcome_firstname_format(arg0: String) -> String {
String(format: self.generic_welcome_firstname_format, arg0) String(format: self.generic_welcome_firstname_format, arg0)
} }
@@ -81,7 +81,7 @@ extension String {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
public var test_equal_symbol: String { internal var test_equal_symbol: String {
NSLocalizedString("test_equal_symbol", tableName: kStringsFileName, bundle: Bundle.main, value: "1€ = 1 point !", comment: "") NSLocalizedString("test_equal_symbol", tableName: kStringsFileName, bundle: Bundle.main, value: "1€ = 1 point !", comment: "")
} }
@@ -92,7 +92,7 @@ extension String {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
public var placeholders_test_one: String { internal var placeholders_test_one: String {
NSLocalizedString("placeholders_test_one", tableName: kStringsFileName, bundle: Bundle.main, value: "You %%: %2$@ %1$@ Age: %3$d", comment: "") NSLocalizedString("placeholders_test_one", tableName: kStringsFileName, bundle: Bundle.main, value: "You %%: %2$@ %1$@ Age: %3$d", comment: "")
} }
/// Translation in en : /// Translation in en :
@@ -100,7 +100,7 @@ extension String {
/// ///
/// Comment : /// Comment :
/// No comment /// No comment
public func placeholders_test_one(arg0: String, arg1: String, arg2: Int) -> String { internal func placeholders_test_one(arg0: String, arg1: String, arg2: Int) -> String {
String(format: self.placeholders_test_one, arg0, arg1, arg2) String(format: self.placeholders_test_one, arg0, arg1, arg2)
} }
} }

View File

@@ -32,19 +32,19 @@
"en" : { "en" : {
"stringUnit" : { "stringUnit" : {
"state" : "translated", "state" : "translated",
"value" : "Loading data..." "value" : "Loading\ndata..."
} }
}, },
"en-us" : { "en-us" : {
"stringUnit" : { "stringUnit" : {
"state" : "translated", "state" : "translated",
"value" : "Loading data..." "value" : "Loading\ndata..."
} }
}, },
"fr" : { "fr" : {
"stringUnit" : { "stringUnit" : {
"state" : "translated", "state" : "translated",
"value" : "Chargement des données..." "value" : "Chargement\ndes données..."
} }
} }
} }
@@ -56,19 +56,19 @@
"en" : { "en" : {
"stringUnit" : { "stringUnit" : {
"state" : "translated", "state" : "translated",
"value" : "Welcome \\\"%@\\\" !" "value" : "Welcome \"%@\" !"
} }
}, },
"en-us" : { "en-us" : {
"stringUnit" : { "stringUnit" : {
"state" : "translated", "state" : "translated",
"value" : "Welcome \\\"%@\\\" !" "value" : "Welcome \"%@\" !"
} }
}, },
"fr" : { "fr" : {
"stringUnit" : { "stringUnit" : {
"state" : "translated", "state" : "translated",
"value" : "Bienvenue \\\"%@\\\" !" "value" : "Bienvenue \"%@\" !"
} }
} }
} }

View File

@@ -14,11 +14,11 @@
fr = Retour fr = Retour
en-us = Back en-us = Back
[generic_loading_data] [generic_loading_data]
en = Loading data... en = Loading\ndata...
tags = droid,ios tags = droid,ios
comments = comments =
fr = Chargement des données... fr = Chargement\ndes données...
en-us = Loading data... en-us = Loading\ndata...
[generic_welcome_firstname_format] [generic_welcome_firstname_format]
en = Welcome "%@" ! en = Welcome "%@" !
tags = droid,ios tags = droid,ios

View File

@@ -3,34 +3,34 @@
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 "FontYolo" \ # --extension-name "FontYolo" \
--extension-name-ui-kit "UIFontYolo" \ # --extension-name-ui-kit "UIFontYolo" \
--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 "ColorYolo" \ # --extension-name "ColorYolo" \
--extension-name-ui-kit "UIhkjhkColorYolo" \ # --extension-name-ui-kit "UIhkjhkColorYolo" \
--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"
## Strings ## Strings
swift run -c release ResgenSwift strings stringium $FORCE_FLAG "./Strings/sampleStrings.txt" \ swift run -c release ResgenSwift strings stringium $FORCE_FLAG "./Strings/sampleStrings.txt" \
@@ -41,31 +41,31 @@ swift run -c release ResgenSwift strings stringium $FORCE_FLAG "./Strings/sample
--extension-name "String" \ --extension-name "String" \
--extension-suffix "GenAllScript" --extension-suffix "GenAllScript"
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"
#
# Analytics ## Analytics
swift run -c release ResgenSwift analytics $FORCE_FLAG "./Tags/sampleTags.yml" \ #swift run -c release ResgenSwift analytics $FORCE_FLAG "./Tags/sampleTags.yml" \
--target "firebase" \ # --target "firebase" \
--extension-output-path "./Tags/Generated" \ # --extension-output-path "./Tags/Generated" \
--extension-name "Analytics" \ # --extension-name "Analytics" \
--extension-suffix "GenAllScript" \ # --extension-suffix "GenAllScript" \
--static-members true # --static-members true
#
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 "ImageYolo" \ # --extension-name "ImageYolo" \
--extension-name-ui-kit "UIImageYolo" \ # --extension-name-ui-kit "UIImageYolo" \
--extension-suffix "GenAllScript" # --extension-suffix "GenAllScript"

View File

@@ -13,7 +13,7 @@ struct Analytics: ParsableCommand {
// MARK: - Command Configuration // MARK: - Command Configuration
static var configuration = CommandConfiguration( static let configuration = CommandConfiguration(
abstract: "Generate analytics extension file.", abstract: "Generate analytics extension file.",
version: ResgenSwiftVersion version: ResgenSwiftVersion
) )

View File

@@ -13,7 +13,7 @@ struct Fonts: ParsableCommand {
// MARK: - CommandConfiguration // MARK: - CommandConfiguration
static var configuration = CommandConfiguration( static let configuration = CommandConfiguration(
abstract: "A utility to generate an helpful etension to access your custom font from code and also Info.plist UIAppsFont content.", abstract: "A utility to generate an helpful etension to access your custom font from code and also Info.plist UIAppsFont content.",
version: ResgenSwiftVersion version: ResgenSwiftVersion
) )

View File

@@ -13,7 +13,7 @@ struct Generate: ParsableCommand {
// MARK: - CommandConfiguration // MARK: - CommandConfiguration
static var configuration = CommandConfiguration( static let configuration = CommandConfiguration(
abstract: "A utility to generate ressources based on a configuration file", abstract: "A utility to generate ressources based on a configuration file",
version: ResgenSwiftVersion version: ResgenSwiftVersion
) )

View File

@@ -38,8 +38,8 @@ extension StringsConfiguration: Runnable {
("--extension-suffix", extensionSuffix), ("--extension-suffix", extensionSuffix),
("--visibility", visibility), ("--visibility", visibility),
("--asset-bundle", assetBundle), ("--asset-bundle", assetBundle),
("--xc-strings", staticMembers?.description), ("--xc-strings", xcStrings?.description),
("--static-members", xcStrings?.description) ("--static-members", staticMembers?.description)
].forEach { argumentName, argumentValue in ].forEach { argumentName, argumentValue in
if let argumentValue { if let argumentValue {
args += [ args += [

View File

@@ -186,8 +186,6 @@ class XcassetsGenerator {
atomically: false, atomically: false,
encoding: .utf8 encoding: .utf8
) )
print("\(parsedImage.name) -> Generated")
} }
// Success info // Success info

View File

@@ -13,7 +13,7 @@ struct Images: ParsableCommand {
// MARK: - CommandConfiguration // MARK: - CommandConfiguration
static var configuration = CommandConfiguration( static let configuration = CommandConfiguration(
abstract: "A utility for generate images and an extension to access them easily.", abstract: "A utility for generate images and an extension to access them easily.",
version: ResgenSwiftVersion version: ResgenSwiftVersion
) )

View File

@@ -133,15 +133,17 @@ enum StringsFileGenerator {
tags inputTags: [String], tags inputTags: [String],
sections: [Section] sections: [Section]
) -> String { ) -> String {
let rootObject = generateRootObject( generateXcStringsFileContentFromRootObject(
rootObject: generateRootObject(
langs: langs, langs: langs,
defaultLang: defaultLang, defaultLang: defaultLang,
tags: inputTags, tags: inputTags,
sections: sections sections: sections
) )
let file = generateXcStringsFileContentFromRootObject(rootObject: rootObject) )
// Remove unwanted \ generated when transforming object to json
return file .replacingOccurrences(of: "\\\\", with: "\\")
.replacingOccurrences(of: "\\\"", with: "\"")
} }
static func generateXcStringsFileContentFromRootObject(rootObject: Root) -> String { static func generateXcStringsFileContentFromRootObject(rootObject: Root) -> String {
@@ -173,22 +175,23 @@ enum StringsFileGenerator {
guard section.hasOneOrMoreMatchingTags(tags: inputTags) else { guard section.hasOneOrMoreMatchingTags(tags: inputTags) else {
return // Go to next section return // Go to next section
} }
print("DOUDOU")
section.definitions.forEach { definition in // swiftlint:disable:this closure_body_length section
.definitions
.forEach { definition in // swiftlint:disable:this closure_body_length
var skipDefinition = false var skipDefinition = false
var isNoTranslation = false var isNoTranslation = false
var localizationTab: [XCStringLocalization] = [] var localizationTab: [XCStringLocalization] = []
if definition.hasOneOrMoreMatchingTags(inputTags: inputTags) == false { guard definition.hasOneOrMoreMatchingTags(inputTags: inputTags) else {
skipDefinition = true return
} }
if definition.tags.contains(Stringium.noTranslationTag) { if definition.tags.contains(Stringium.noTranslationTag) {
isNoTranslation = true isNoTranslation = true
} }
if !skipDefinition {
if isNoTranslation { if isNoTranslation {
// Search for langs in yaml // Search for langs in yaml
for lang in langs { for lang in langs {
@@ -196,7 +199,10 @@ enum StringsFileGenerator {
let localization = XCStringLocalization( let localization = XCStringLocalization(
lang: lang, lang: lang,
content: XCStringLocalizationLangContent( content: XCStringLocalizationLangContent(
stringUnit: DefaultStringUnit(state: "translated", value: value) stringUnit: DefaultStringUnit(
state: "translated",
value: value
)
) )
) )
localizationTab.append(localization) localizationTab.append(localization)
@@ -204,14 +210,18 @@ enum StringsFileGenerator {
} }
} else { } else {
// Search for langs in twine // Search for langs in twine
for (lang, value) in definition.translations where !value.isEmpty { for (lang, value) in definition.translations
where langs.contains(lang) && !value.isEmpty {
print("DOUDOU-> generate for \(lang)")
let localization = XCStringLocalization( let localization = XCStringLocalization(
lang: lang, lang: lang,
content: XCStringLocalizationLangContent( content: XCStringLocalizationLangContent(
stringUnit: DefaultStringUnit(state: "translated", value: value) stringUnit: DefaultStringUnit(
state: "translated",
value: value
)
) )
) )
localizationTab.append(localization) localizationTab.append(localization)
} }
} }
@@ -230,7 +240,6 @@ enum StringsFileGenerator {
xcStringDefinitionTab.append(xcStringDefinition) xcStringDefinitionTab.append(xcStringDefinition)
} }
} }
}
let xcStringContainer = XCStringDefinitionContainer(strings: xcStringDefinitionTab) let xcStringContainer = XCStringDefinitionContainer(strings: xcStringDefinitionTab)

View File

@@ -13,7 +13,7 @@ struct Stringium: ParsableCommand {
// MARK: - Command Configuration // MARK: - Command Configuration
static var configuration = CommandConfiguration( static let configuration = CommandConfiguration(
abstract: "Generate strings with custom scripts.", abstract: "Generate strings with custom scripts.",
version: ResgenSwiftVersion version: ResgenSwiftVersion
) )

View File

@@ -11,7 +11,7 @@ import ToolCore
struct Strings: ParsableCommand { struct Strings: ParsableCommand {
static var configuration = CommandConfiguration( static let configuration = CommandConfiguration(
abstract: "A utility for generate strings.", abstract: "A utility for generate strings.",
version: ResgenSwiftVersion, version: ResgenSwiftVersion,

View File

@@ -13,7 +13,7 @@ struct Tags: ParsableCommand {
// MARK: - Command Configuration // MARK: - Command Configuration
static var configuration = CommandConfiguration( static let configuration = CommandConfiguration(
abstract: "Generate tags extension file.", abstract: "Generate tags extension file.",
version: ResgenSwiftVersion version: ResgenSwiftVersion
) )

View File

@@ -13,7 +13,7 @@ struct Twine: ParsableCommand {
// MARK: - Command Configuration // MARK: - Command Configuration
static var configuration = CommandConfiguration( static let configuration = CommandConfiguration(
abstract: "Generate strings with twine.", abstract: "Generate strings with twine.",
version: ResgenSwiftVersion version: ResgenSwiftVersion
) )

View File

@@ -11,7 +11,7 @@ import ToolCore
struct ResgenSwift: ParsableCommand { struct ResgenSwift: ParsableCommand {
static var configuration = CommandConfiguration( static let configuration = CommandConfiguration(
abstract: "A utility for generate ressources.", abstract: "A utility for generate ressources.",
version: ResgenSwiftVersion, version: ResgenSwiftVersion,