Handle bundle for Stringium
All checks were successful
gitea-openium/resgen.swift/pipeline/head This commit looks good

This commit is contained in:
2025-07-22 09:10:45 +02:00
parent 5ad219ae89
commit 3510b60e97
11 changed files with 335 additions and 156 deletions

View File

@@ -20,7 +20,8 @@ extension StringsFileGeneratorTests {
s2DefOneComment: String = "",
s2DefTwoFr: String = "Section Deux - Definition Deux",
s2DefTwoComment: String = "",
visibility: ExtensionVisibility = .internal
visibility: ExtensionVisibility = .internal,
assetBundle: AssetBundle = .main
) -> String {
"""
// Generated by ResgenSwift.Strings.Stringium \(ResgenSwiftVersion)
@@ -55,7 +56,7 @@ extension StringsFileGeneratorTests {
/// Comment :
/// \(s1DefOneComment.isEmpty ? "No comment" : s1DefOneComment)
\(visibility) \(staticVar ? "static " : "")var s1_def_one: String {
NSLocalizedString("s1_def_one", tableName: kStringsFileName, bundle: Bundle.main, value: "Section Un - Definition Un", comment: "\(s1DefOneComment)")
NSLocalizedString("s1_def_one", tableName: kStringsFileName, bundle: Bundle.\(assetBundle), value: "Section Un - Definition Un", comment: "\(s1DefOneComment)")
}
/// Translation in fr :
@@ -64,7 +65,7 @@ extension StringsFileGeneratorTests {
/// Comment :
/// \(s1DefTwoComment.isEmpty ? "No comment" : s1DefTwoComment)
\(visibility) \(staticVar ? "static " : "")var s1_def_two: String {
NSLocalizedString("s1_def_two", tableName: kStringsFileName, bundle: Bundle.main, value: "Section Un - Definition Deux", comment: "\(s1DefTwoComment)")
NSLocalizedString("s1_def_two", tableName: kStringsFileName, bundle: Bundle.\(assetBundle), value: "Section Un - Definition Deux", comment: "\(s1DefTwoComment)")
}
// MARK: - section_two
@@ -75,7 +76,7 @@ extension StringsFileGeneratorTests {
/// Comment :
/// \(s2DefOneComment.isEmpty ? "No comment" : s2DefOneComment)
\(visibility) \(staticVar ? "static " : "")var s2_def_one: String {
NSLocalizedString("s2_def_one", tableName: kStringsFileName, bundle: Bundle.main, value: "Section Deux - Definition Un", comment: "\(s2DefOneComment)")
NSLocalizedString("s2_def_one", tableName: kStringsFileName, bundle: Bundle.\(assetBundle), value: "Section Deux - Definition Un", comment: "\(s2DefOneComment)")
}
/// Translation in fr :
@@ -84,7 +85,7 @@ extension StringsFileGeneratorTests {
/// Comment :
/// \(s2DefTwoComment.isEmpty ? "No comment" : s2DefTwoComment)
\(visibility) \(staticVar ? "static " : "")var s2_def_two: String {
NSLocalizedString("s2_def_two", tableName: kStringsFileName, bundle: Bundle.main, value: "Section Deux - Definition Deux", comment: "\(s2DefTwoComment)")
NSLocalizedString("s2_def_two", tableName: kStringsFileName, bundle: Bundle.\(assetBundle), value: "Section Deux - Definition Deux", comment: "\(s2DefTwoComment)")
}
}
"""

View File

@@ -377,11 +377,12 @@ final class StringsFileGeneratorTests: XCTestCase {
sections: [sectionOne, sectionTwo],
defaultLang: "fr",
tags: ["ios", "iosonly", "notranslation"],
staticVar: false,
isStatic: false,
inputFilename: "myInputFilename",
extensionName: "GenStrings",
extensionSuffix: "strings",
visibility: .internal
visibility: .internal,
assetBundle: .main
)
// Expect
@@ -411,11 +412,12 @@ final class StringsFileGeneratorTests: XCTestCase {
sections: [sectionOne, sectionTwo],
defaultLang: "fr",
tags: ["ios", "iosonly", "notranslation"],
staticVar: false,
isStatic: false,
inputFilename: "myInputFilename",
extensionName: "GenStrings",
extensionSuffix: "strings",
visibility: .public
visibility: .public,
assetBundle: .main
)
// Expect
@@ -445,17 +447,19 @@ final class StringsFileGeneratorTests: XCTestCase {
sections: [sectionOne, sectionTwo],
defaultLang: "fr",
tags: ["ios", "iosonly", "notranslation"],
staticVar: true,
isStatic: true,
inputFilename: "myInputFilename",
extensionName: "GenStrings",
extensionSuffix: "strings",
visibility: .package
visibility: .package,
assetBundle: .module
)
// Expect
let expect = Self.getExtensionContentExpectation(
staticVar: true,
visibility: .package
visibility: .package,
assetBundle: .module
)
if extensionContent != expect {
@@ -480,11 +484,12 @@ final class StringsFileGeneratorTests: XCTestCase {
sections: [sectionOne, sectionTwo],
defaultLang: "fr",
tags: ["ios", "iosonly", "notranslation"],
staticVar: true,
isStatic: true,
inputFilename: "myInputFilename",
extensionName: "GenStrings",
extensionSuffix: "strings",
visibility: .internal
visibility: .internal,
assetBundle: .module
)
// Expect
@@ -494,7 +499,8 @@ final class StringsFileGeneratorTests: XCTestCase {
s1DefTwoComment: "This is a comment",
s2DefOneComment: "This is a comment",
s2DefTwoComment: "This is a comment",
visibility: .internal
visibility: .internal,
assetBundle: .module
)
if extensionContent != expect {