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

@@ -94,9 +94,24 @@ final class DefinitionTests: XCTestCase {
]
// When
let propertyFr = definition.getNSLocalizedStringProperty(forLang: "fr", visibility: .public)
let propertyEn = definition.getNSLocalizedStringProperty(forLang: "en", visibility: .public)
let propertyEnUs = definition.getNSLocalizedStringProperty(forLang: "en-us", visibility: .public)
let propertyFr = definition.getNSLocalizedStringProperty(
forLang: "fr",
isStatic: false,
visibility: .public,
assetBundle: .main
)
let propertyEn = definition.getNSLocalizedStringProperty(
forLang: "en",
isStatic: false,
visibility: .public,
assetBundle: .main
)
let propertyEnUs = definition.getNSLocalizedStringProperty(
forLang: "en-us",
isStatic: false,
visibility: .public,
assetBundle: .main
)
// Expect
let expectFr = """
@@ -149,9 +164,24 @@ final class DefinitionTests: XCTestCase {
]
// When
let propertyFr = definition.getNSLocalizedStringProperty(forLang: "fr", visibility: .private)
let propertyEn = definition.getNSLocalizedStringProperty(forLang: "en", visibility: .private)
let propertyEnUs = definition.getNSLocalizedStringProperty(forLang: "en-us", visibility: .private)
let propertyFr = definition.getNSLocalizedStringProperty(
forLang: "fr",
isStatic: false,
visibility: .private,
assetBundle: .main
)
let propertyEn = definition.getNSLocalizedStringProperty(
forLang: "en",
isStatic: false,
visibility: .private,
assetBundle: .main
)
let propertyEnUs = definition.getNSLocalizedStringProperty(
forLang: "en-us",
isStatic: false,
visibility: .private,
assetBundle: .main
)
// Expect
let expectFr = """
@@ -203,9 +233,24 @@ final class DefinitionTests: XCTestCase {
]
// When
let propertyFr = definition.getNSLocalizedStringProperty(forLang: "fr", visibility: .public)
let propertyEn = definition.getNSLocalizedStringProperty(forLang: "en", visibility: .public)
let propertyEnUs = definition.getNSLocalizedStringProperty(forLang: "en-us", visibility: .public)
let propertyFr = definition.getNSLocalizedStringProperty(
forLang: "fr",
isStatic: false,
visibility: .public,
assetBundle: .main
)
let propertyEn = definition.getNSLocalizedStringProperty(
forLang: "en",
isStatic: false,
visibility: .public,
assetBundle: .main
)
let propertyEnUs = definition.getNSLocalizedStringProperty(
forLang: "en-us",
isStatic: false,
visibility: .public,
assetBundle: .main
)
// Expect
let expectFr = """
@@ -246,7 +291,7 @@ final class DefinitionTests: XCTestCase {
XCTAssertEqual(propertyEnUs.adaptForXCTest(), expectEnUs.adaptForXCTest())
}
// MARK: - getNSLocalizedStringStaticProperty
// MARK: - getNSLocalizedStringProperty - static
func testGeneratedNSLocalizedStringStaticProperty() {
// Given
@@ -260,9 +305,24 @@ final class DefinitionTests: XCTestCase {
]
// When
let propertyFr = definition.getNSLocalizedStringStaticProperty(forLang: "fr", visibility: .public)
let propertyEn = definition.getNSLocalizedStringStaticProperty(forLang: "en", visibility: .public)
let propertyEnUs = definition.getNSLocalizedStringStaticProperty(forLang: "en-us", visibility: .public)
let propertyFr = definition.getNSLocalizedStringProperty(
forLang: "fr",
isStatic: true,
visibility: .public,
assetBundle: .main
)
let propertyEn = definition.getNSLocalizedStringProperty(
forLang: "en",
isStatic: true,
visibility: .public,
assetBundle: .main
)
let propertyEnUs = definition.getNSLocalizedStringProperty(
forLang: "en-us",
isStatic: true,
visibility: .public,
assetBundle: .main
)
// Expect
let expectFr = """
@@ -315,9 +375,24 @@ final class DefinitionTests: XCTestCase {
]
// When
let propertyFr = definition.getNSLocalizedStringStaticProperty(forLang: "fr", visibility: .internal)
let propertyEn = definition.getNSLocalizedStringStaticProperty(forLang: "en", visibility: .internal)
let propertyEnUs = definition.getNSLocalizedStringStaticProperty(forLang: "en-us", visibility: .internal)
let propertyFr = definition.getNSLocalizedStringProperty(
forLang: "fr",
isStatic: true,
visibility: .internal,
assetBundle: .main
)
let propertyEn = definition.getNSLocalizedStringProperty(
forLang: "en",
isStatic: true,
visibility: .internal,
assetBundle: .main
)
let propertyEnUs = definition.getNSLocalizedStringProperty(
forLang: "en-us",
isStatic: true,
visibility: .internal,
assetBundle: .main
)
// Expect
let expectFr = """
@@ -369,9 +444,24 @@ final class DefinitionTests: XCTestCase {
]
// When
let propertyFr = definition.getNSLocalizedStringStaticProperty(forLang: "fr", visibility: .internal)
let propertyEn = definition.getNSLocalizedStringStaticProperty(forLang: "en", visibility: .internal)
let propertyEnUs = definition.getNSLocalizedStringStaticProperty(forLang: "en-us", visibility: .internal)
let propertyFr = definition.getNSLocalizedStringProperty(
forLang: "fr",
isStatic: true,
visibility: .internal,
assetBundle: .main
)
let propertyEn = definition.getNSLocalizedStringProperty(
forLang: "en",
isStatic: true,
visibility: .internal,
assetBundle: .main
)
let propertyEnUs = definition.getNSLocalizedStringProperty(
forLang: "en-us",
isStatic: true,
visibility: .internal,
assetBundle: .main
)
// Expect
let expectFr = """
@@ -422,7 +512,12 @@ final class DefinitionTests: XCTestCase {
]
// When
let propertyFr = definition.getNSLocalizedStringProperty(forLang: "fr", visibility: .internal)
let propertyFr = definition.getNSLocalizedStringProperty(
forLang: "fr",
isStatic: false,
visibility: .internal,
assetBundle: .main
)
// Expect
let expectFr = """
@@ -458,7 +553,12 @@ final class DefinitionTests: XCTestCase {
]
// When
let propertyFr = definition.getNSLocalizedStringProperty(forLang: "fr", visibility: .private)
let propertyFr = definition.getNSLocalizedStringProperty(
forLang: "fr",
isStatic: false,
visibility: .private,
assetBundle: .main
)
// Expect
let expectFr = """
@@ -495,8 +595,18 @@ final class DefinitionTests: XCTestCase {
]
// When
let propertyFr = definition.getNSLocalizedStringProperty(forLang: "fr", visibility: .public)
let propertyEn = definition.getNSLocalizedStringProperty(forLang: "en", visibility: .public)
let propertyFr = definition.getNSLocalizedStringProperty(
forLang: "fr",
isStatic: false,
visibility: .public,
assetBundle: .main
)
let propertyEn = definition.getNSLocalizedStringProperty(
forLang: "en",
isStatic: false,
visibility: .public,
assetBundle: .main
)
let expectFr = """
/// Translation in fr :
@@ -556,9 +666,21 @@ final class DefinitionTests: XCTestCase {
]
// When
let propertyFr = definition.getProperty(forLang: "fr", visibility: .public)
let propertyEn = definition.getProperty(forLang: "en", visibility: .public)
let propertyEnUs = definition.getProperty(forLang: "en-us", visibility: .public)
let propertyFr = definition.getProperty(
forLang: "fr",
visibility: .public,
isStatic: false
)
let propertyEn = definition.getProperty(
forLang: "en",
visibility: .public,
isStatic: false
)
let propertyEnUs = definition.getProperty(
forLang: "en-us",
visibility: .public,
isStatic: false
)
// Expect
let expectFr = """
@@ -611,9 +733,21 @@ final class DefinitionTests: XCTestCase {
]
// When
let propertyFr = definition.getProperty(forLang: "fr", visibility: .package)
let propertyEn = definition.getProperty(forLang: "en", visibility: .package)
let propertyEnUs = definition.getProperty(forLang: "en-us", visibility: .package)
let propertyFr = definition.getProperty(
forLang: "fr",
visibility: .package,
isStatic: false
)
let propertyEn = definition.getProperty(
forLang: "en",
visibility: .package,
isStatic: false
)
let propertyEnUs = definition.getProperty(
forLang: "en-us",
visibility: .package,
isStatic: false
)
// Expect
let expectFr = """
@@ -665,9 +799,21 @@ final class DefinitionTests: XCTestCase {
]
// When
let propertyFr = definition.getProperty(forLang: "fr", visibility: .private)
let propertyEn = definition.getProperty(forLang: "en", visibility: .private)
let propertyEnUs = definition.getProperty(forLang: "en-us", visibility: .private)
let propertyFr = definition.getProperty(
forLang: "fr",
visibility: .private,
isStatic: false
)
let propertyEn = definition.getProperty(
forLang: "en",
visibility: .private,
isStatic: false
)
let propertyEnUs = definition.getProperty(
forLang: "en-us",
visibility: .private,
isStatic: false
)
// Expect
let expectFr = """
@@ -722,9 +868,21 @@ final class DefinitionTests: XCTestCase {
]
// When
let propertyFr = definition.getStaticProperty(forLang: "fr", visibility: .internal)
let propertyEn = definition.getStaticProperty(forLang: "en", visibility: .internal)
let propertyEnUs = definition.getStaticProperty(forLang: "en-us", visibility: .internal)
let propertyFr = definition.getProperty(
forLang: "fr",
visibility: .internal,
isStatic: true
)
let propertyEn = definition.getProperty(
forLang: "en",
visibility: .internal,
isStatic: true
)
let propertyEnUs = definition.getProperty(
forLang: "en-us",
visibility: .internal,
isStatic: true
)
// Expect
let expectFr = """
@@ -777,9 +935,21 @@ final class DefinitionTests: XCTestCase {
]
// When
let propertyFr = definition.getStaticProperty(forLang: "fr", visibility: .internal)
let propertyEn = definition.getStaticProperty(forLang: "en", visibility: .internal)
let propertyEnUs = definition.getStaticProperty(forLang: "en-us", visibility: .internal)
let propertyFr = definition.getProperty(
forLang: "fr",
visibility: .internal,
isStatic: true
)
let propertyEn = definition.getProperty(
forLang: "en",
visibility: .internal,
isStatic: true
)
let propertyEnUs = definition.getProperty(
forLang: "en-us",
visibility: .internal,
isStatic: true
)
// Expect
let expectFr = """
@@ -831,9 +1001,21 @@ final class DefinitionTests: XCTestCase {
]
// When
let propertyFr = definition.getStaticProperty(forLang: "fr", visibility: .internal)
let propertyEn = definition.getStaticProperty(forLang: "en", visibility: .internal)
let propertyEnUs = definition.getStaticProperty(forLang: "en-us", visibility: .internal)
let propertyFr = definition.getProperty(
forLang: "fr",
visibility: .internal,
isStatic: true
)
let propertyEn = definition.getProperty(
forLang: "en",
visibility: .internal,
isStatic: true
)
let propertyEnUs = definition.getProperty(
forLang: "en-us",
visibility: .internal,
isStatic: true
)
// Expect
let expectFr = """

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 {

View File

@@ -49,7 +49,7 @@ final class TagsGeneratorTests: XCTestCase {
sections: [sectionOne, sectionTwo, sectionThree],
lang: "ium",
tags: ["ios", "iosonly"],
staticVar: false,
isStatic: false,
extensionName: "GenTags",
visibility: .public
)