feat(RES-58): Add new parameter "bundle" #19
@@ -247,23 +247,25 @@ enum StringsFileGenerator {
|
||||
sections: [Section],
|
||||
defaultLang lang: String,
|
||||
tags: [String],
|
||||
staticVar: Bool,
|
||||
isStatic: Bool,
|
||||
inputFilename: String,
|
||||
extensionName: String,
|
||||
extensionFilePath: String,
|
||||
extensionSuffix: String,
|
||||
visibility: ExtensionVisibility
|
||||
visibility: ExtensionVisibility,
|
||||
assetBundle: AssetBundle
|
||||
) {
|
||||
// Get extension content
|
||||
let extensionFileContent = Self.getExtensionContent(
|
||||
sections: sections,
|
||||
defaultLang: lang,
|
||||
tags: tags,
|
||||
staticVar: staticVar,
|
||||
isStatic: isStatic,
|
||||
inputFilename: inputFilename,
|
||||
extensionName: extensionName,
|
||||
extensionSuffix: extensionSuffix,
|
||||
visibility: visibility
|
||||
visibility: visibility,
|
||||
assetBundle: assetBundle
|
||||
)
|
||||
|
||||
// Write content
|
||||
@@ -283,11 +285,12 @@ enum StringsFileGenerator {
|
||||
sections: [Section],
|
||||
defaultLang lang: String,
|
||||
tags: [String],
|
||||
staticVar: Bool,
|
||||
isStatic: Bool,
|
||||
inputFilename: String,
|
||||
extensionName: String,
|
||||
extensionSuffix: String,
|
||||
visibility: ExtensionVisibility
|
||||
visibility: ExtensionVisibility,
|
||||
assetBundle: AssetBundle
|
||||
) -> String {
|
||||
[
|
||||
Self.getHeader(
|
||||
@@ -305,8 +308,9 @@ enum StringsFileGenerator {
|
||||
sections: sections,
|
||||
defaultLang: lang,
|
||||
tags: tags,
|
||||
staticVar: staticVar,
|
||||
visibility: visibility
|
||||
isStatic: isStatic,
|
||||
visibility: visibility,
|
||||
assetBundle: assetBundle
|
||||
),
|
||||
Self.getFooter()
|
||||
]
|
||||
@@ -379,8 +383,9 @@ enum StringsFileGenerator {
|
||||
sections: [Section],
|
||||
defaultLang lang: String,
|
||||
tags: [String],
|
||||
staticVar: Bool,
|
||||
visibility: ExtensionVisibility
|
||||
isStatic: Bool,
|
||||
visibility: ExtensionVisibility,
|
||||
assetBundle: AssetBundle
|
||||
) -> String {
|
||||
sections.compactMap { section in
|
||||
// Check that at least one string will be generated
|
||||
@@ -394,19 +399,12 @@ enum StringsFileGenerator {
|
||||
return nil // Go to next definition
|
||||
}
|
||||
|
||||
let property: String = {
|
||||
if staticVar {
|
||||
definition.getNSLocalizedStringStaticProperty(
|
||||
forLang: lang,
|
||||
visibility: visibility
|
||||
)
|
||||
} else {
|
||||
definition.getNSLocalizedStringProperty(
|
||||
forLang: lang,
|
||||
visibility: visibility
|
||||
)
|
||||
}
|
||||
}()
|
||||
let property = definition.getNSLocalizedStringProperty(
|
||||
forLang: lang,
|
||||
isStatic: isStatic,
|
||||
visibility: visibility,
|
||||
assetBundle: assetBundle
|
||||
)
|
||||
|
||||
return "\n\(property)"
|
||||
}
|
||||
|
@@ -15,7 +15,7 @@ enum TagsGenerator {
|
||||
sections: [Section],
|
||||
lang: String,
|
||||
tags: [String],
|
||||
staticVar: Bool,
|
||||
isStatic: Bool,
|
||||
extensionName: String,
|
||||
extensionFilePath: String,
|
||||
visibility: ExtensionVisibility
|
||||
@@ -25,7 +25,7 @@ enum TagsGenerator {
|
||||
sections: sections,
|
||||
lang: lang,
|
||||
tags: tags,
|
||||
staticVar: staticVar,
|
||||
isStatic: isStatic,
|
||||
extensionName: extensionName,
|
||||
visibility: visibility
|
||||
)
|
||||
@@ -47,20 +47,20 @@ enum TagsGenerator {
|
||||
sections: [Section],
|
||||
lang: String,
|
||||
tags: [String],
|
||||
staticVar: Bool,
|
||||
isStatic: Bool,
|
||||
extensionName: String,
|
||||
visibility: ExtensionVisibility
|
||||
) -> String {
|
||||
[
|
||||
Self.getHeader(
|
||||
extensionClassname: extensionName,
|
||||
staticVar: staticVar
|
||||
isStatic: isStatic
|
||||
),
|
||||
Self.getProperties(
|
||||
sections: sections,
|
||||
lang: lang,
|
||||
tags: tags,
|
||||
staticVar: staticVar,
|
||||
isStatic: isStatic,
|
||||
visibility: visibility
|
||||
),
|
||||
Self.getFooter()
|
||||
@@ -70,11 +70,11 @@ enum TagsGenerator {
|
||||
|
||||
// MARK: - Extension part
|
||||
|
||||
private static func getHeader(extensionClassname: String, staticVar: Bool) -> String {
|
||||
private static func getHeader(extensionClassname: String, isStatic: Bool) -> String {
|
||||
"""
|
||||
// Generated by ResgenSwift.Strings.\(Tags.toolName) \(ResgenSwiftVersion)
|
||||
|
||||
\(staticVar ? "typelias Tags = String\n\n" : "")import UIKit
|
||||
\(isStatic ? "typelias Tags = String\n\n" : "")import UIKit
|
||||
|
||||
extension \(extensionClassname) {
|
||||
"""
|
||||
@@ -84,7 +84,7 @@ enum TagsGenerator {
|
||||
sections: [Section],
|
||||
lang: String,
|
||||
tags: [String],
|
||||
staticVar: Bool,
|
||||
isStatic: Bool,
|
||||
visibility: ExtensionVisibility
|
||||
) -> String {
|
||||
sections
|
||||
@@ -100,11 +100,12 @@ enum TagsGenerator {
|
||||
return // Go to next definition
|
||||
}
|
||||
|
||||
if staticVar {
|
||||
res += "\n\n\(definition.getStaticProperty(forLang: lang, visibility: visibility))"
|
||||
} else {
|
||||
res += "\n\n\(definition.getProperty(forLang: lang, visibility: visibility))"
|
||||
}
|
||||
let property = definition.getProperty(
|
||||
forLang: lang,
|
||||
visibility: visibility,
|
||||
isStatic: isStatic
|
||||
)
|
||||
res += "\n\n\(property)"
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
@@ -105,7 +105,8 @@ class Definition {
|
||||
translation: String,
|
||||
isStatic: Bool,
|
||||
comment: String?,
|
||||
visibility: ExtensionVisibility
|
||||
visibility: ExtensionVisibility,
|
||||
assetBundle: AssetBundle
|
||||
) -> String {
|
||||
"""
|
||||
/// Translation in \(lang) :
|
||||
@@ -114,7 +115,7 @@ class Definition {
|
||||
/// Comment :
|
||||
/// \(comment?.isEmpty == false ? comment! : "No comment")
|
||||
\(visibility) \(isStatic ? "static " : "")var \(name): String {
|
||||
NSLocalizedString("\(name)", tableName: kStringsFileName, bundle: Bundle.main, value: "\(translation)", comment: "\(comment ?? "")")
|
||||
NSLocalizedString("\(name)", tableName: kStringsFileName, bundle: Bundle.\(assetBundle), value: "\(translation)", comment: "\(comment ?? "")")
|
||||
}
|
||||
"""
|
||||
}
|
||||
@@ -141,7 +142,12 @@ class Definition {
|
||||
"""
|
||||
}
|
||||
|
||||
func getNSLocalizedStringProperty(forLang lang: String, visibility: ExtensionVisibility) -> String {
|
||||
func getNSLocalizedStringProperty(
|
||||
forLang lang: String,
|
||||
isStatic: Bool,
|
||||
visibility: ExtensionVisibility,
|
||||
assetBundle: AssetBundle
|
||||
) -> String {
|
||||
guard let translation = translations[lang] else {
|
||||
let error = StringiumError.langNotDefined(lang, name, reference != nil)
|
||||
print(error.description)
|
||||
@@ -152,9 +158,10 @@ class Definition {
|
||||
let property = getBaseProperty(
|
||||
lang: lang,
|
||||
translation: translation,
|
||||
isStatic: false,
|
||||
isStatic: isStatic,
|
||||
comment: self.comment,
|
||||
visibility: visibility
|
||||
visibility: visibility,
|
||||
assetBundle: assetBundle
|
||||
)
|
||||
|
||||
// Generate method
|
||||
@@ -163,40 +170,7 @@ class Definition {
|
||||
method = getBaseMethod(
|
||||
lang: lang,
|
||||
translation: translation,
|
||||
isStatic: false,
|
||||
inputParameters: parameters.inputParameters,
|
||||
translationArguments: parameters.translationArguments,
|
||||
comment: self.comment,
|
||||
visibility: visibility
|
||||
)
|
||||
}
|
||||
|
||||
return property + method
|
||||
}
|
||||
|
||||
func getNSLocalizedStringStaticProperty(forLang lang: String, visibility: ExtensionVisibility) -> String {
|
||||
guard let translation = translations[lang] else {
|
||||
let error = StringiumError.langNotDefined(lang, name, reference != nil)
|
||||
print(error.description)
|
||||
Stringium.exit(withError: error)
|
||||
}
|
||||
|
||||
// Generate property
|
||||
let property = getBaseProperty(
|
||||
lang: lang,
|
||||
translation: translation,
|
||||
isStatic: true,
|
||||
comment: self.comment,
|
||||
visibility: visibility
|
||||
)
|
||||
|
||||
// Generate method
|
||||
var method = ""
|
||||
if let parameters = self.getStringParameters(input: translation) {
|
||||
method = getBaseMethod(
|
||||
lang: lang,
|
||||
translation: translation,
|
||||
isStatic: true,
|
||||
isStatic: isStatic,
|
||||
inputParameters: parameters.inputParameters,
|
||||
translationArguments: parameters.translationArguments,
|
||||
comment: self.comment,
|
||||
@@ -209,7 +183,11 @@ class Definition {
|
||||
|
||||
// MARK: - Raw strings
|
||||
|
||||
func getProperty(forLang lang: String, visibility: ExtensionVisibility) -> String {
|
||||
func getProperty(
|
||||
forLang lang: String,
|
||||
visibility: ExtensionVisibility,
|
||||
isStatic: Bool
|
||||
) -> String {
|
||||
guard let translation = translations[lang] else {
|
||||
let error = StringiumError.langNotDefined(lang, name, reference != nil)
|
||||
print(error.description)
|
||||
@@ -222,26 +200,7 @@ class Definition {
|
||||
///
|
||||
/// Comment :
|
||||
/// \(comment?.isEmpty == false ? comment! : "No comment")
|
||||
\(visibility) var \(name): String {
|
||||
"\(translation)"
|
||||
}
|
||||
"""
|
||||
}
|
||||
|
||||
func getStaticProperty(forLang lang: String, visibility: ExtensionVisibility) -> String {
|
||||
guard let translation = translations[lang] else {
|
||||
let error = StringiumError.langNotDefined(lang, name, reference != nil)
|
||||
print(error.description)
|
||||
Stringium.exit(withError: error)
|
||||
}
|
||||
|
||||
return """
|
||||
/// Translation in \(lang) :
|
||||
/// \(translation)
|
||||
///
|
||||
/// Comment :
|
||||
/// \(comment?.isEmpty == false ? comment! : "No comment")
|
||||
\(visibility) static var \(name): String {
|
||||
\(visibility) \(isStatic ? "static " : "")var \(name): String {
|
||||
"\(translation)"
|
||||
}
|
||||
"""
|
||||
|
@@ -68,12 +68,13 @@ struct Stringium: ParsableCommand {
|
||||
sections: sections,
|
||||
defaultLang: options.defaultLang,
|
||||
tags: options.tags,
|
||||
staticVar: options.staticMembers,
|
||||
isStatic: options.staticMembers,
|
||||
inputFilename: options.inputFilenameWithoutExt,
|
||||
extensionName: extensionName,
|
||||
extensionFilePath: extensionFilePath,
|
||||
extensionSuffix: options.extensionSuffix ?? "",
|
||||
visibility: options.extensionVisibility
|
||||
visibility: options.extensionVisibility,
|
||||
assetBundle: options.assetBundle
|
||||
)
|
||||
}
|
||||
|
||||
|
@@ -57,6 +57,11 @@ struct StringiumOptions: ParsableArguments {
|
||||
)
|
||||
var extensionVisibility: ExtensionVisibility = .internal
|
||||
|
||||
@Option(
|
||||
help: "Bundle where the asset are generated"
|
||||
)
|
||||
var assetBundle: AssetBundle = .main
|
||||
|
||||
@Option(
|
||||
help: "Path where to generate the extension.",
|
||||
transform: { $0.replaceTiltWithHomeDirectoryPath() }
|
||||
|
@@ -47,7 +47,7 @@ struct Tags: ParsableCommand {
|
||||
sections: sections,
|
||||
lang: options.lang,
|
||||
tags: ["ios", "iosonly", Self.noTranslationTag],
|
||||
staticVar: options.staticMembers,
|
||||
isStatic: options.staticMembers,
|
||||
extensionName: options.extensionName,
|
||||
extensionFilePath: options.extensionFilePath,
|
||||
visibility: options.extensionVisibility
|
||||
|
26
Sources/ToolCore/AssetBundle.swift
Normal file
26
Sources/ToolCore/AssetBundle.swift
Normal file
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// AssetBundle.swift
|
||||
// ResgenSwift
|
||||
//
|
||||
// Created by Thibaut Schmitt on 21/07/2025.
|
||||
//
|
||||
|
||||
import ArgumentParser
|
||||
|
||||
package enum AssetBundle: String, CustomStringConvertible, ExpressibleByArgument {
|
||||
|
||||
case main
|
||||
case module
|
||||
|
||||
// MARK: - CustomStringConvertible
|
||||
|
||||
package var description: String {
|
||||
switch self {
|
||||
case .main:
|
||||
"main"
|
||||
|
||||
case .module:
|
||||
"module"
|
||||
}
|
||||
}
|
||||
}
|
@@ -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 = """
|
||||
|
@@ -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)")
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
@@ -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 {
|
||||
|
@@ -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
|
||||
)
|
||||
|
Reference in New Issue
Block a user