feat(RES-58): Add new parameter "bundle" #19
@@ -247,23 +247,25 @@ enum StringsFileGenerator {
|
|||||||
sections: [Section],
|
sections: [Section],
|
||||||
defaultLang lang: String,
|
defaultLang lang: String,
|
||||||
tags: [String],
|
tags: [String],
|
||||||
staticVar: Bool,
|
isStatic: Bool,
|
||||||
inputFilename: String,
|
inputFilename: String,
|
||||||
extensionName: String,
|
extensionName: String,
|
||||||
extensionFilePath: String,
|
extensionFilePath: String,
|
||||||
extensionSuffix: String,
|
extensionSuffix: String,
|
||||||
visibility: ExtensionVisibility
|
visibility: ExtensionVisibility,
|
||||||
|
assetBundle: AssetBundle
|
||||||
) {
|
) {
|
||||||
// Get extension content
|
// Get extension content
|
||||||
let extensionFileContent = Self.getExtensionContent(
|
let extensionFileContent = Self.getExtensionContent(
|
||||||
sections: sections,
|
sections: sections,
|
||||||
defaultLang: lang,
|
defaultLang: lang,
|
||||||
tags: tags,
|
tags: tags,
|
||||||
staticVar: staticVar,
|
isStatic: isStatic,
|
||||||
inputFilename: inputFilename,
|
inputFilename: inputFilename,
|
||||||
extensionName: extensionName,
|
extensionName: extensionName,
|
||||||
extensionSuffix: extensionSuffix,
|
extensionSuffix: extensionSuffix,
|
||||||
visibility: visibility
|
visibility: visibility,
|
||||||
|
assetBundle: assetBundle
|
||||||
)
|
)
|
||||||
|
|
||||||
// Write content
|
// Write content
|
||||||
@@ -283,11 +285,12 @@ enum StringsFileGenerator {
|
|||||||
sections: [Section],
|
sections: [Section],
|
||||||
defaultLang lang: String,
|
defaultLang lang: String,
|
||||||
tags: [String],
|
tags: [String],
|
||||||
staticVar: Bool,
|
isStatic: Bool,
|
||||||
inputFilename: String,
|
inputFilename: String,
|
||||||
extensionName: String,
|
extensionName: String,
|
||||||
extensionSuffix: String,
|
extensionSuffix: String,
|
||||||
visibility: ExtensionVisibility
|
visibility: ExtensionVisibility,
|
||||||
|
assetBundle: AssetBundle
|
||||||
) -> String {
|
) -> String {
|
||||||
[
|
[
|
||||||
Self.getHeader(
|
Self.getHeader(
|
||||||
@@ -305,8 +308,9 @@ enum StringsFileGenerator {
|
|||||||
sections: sections,
|
sections: sections,
|
||||||
defaultLang: lang,
|
defaultLang: lang,
|
||||||
tags: tags,
|
tags: tags,
|
||||||
staticVar: staticVar,
|
isStatic: isStatic,
|
||||||
visibility: visibility
|
visibility: visibility,
|
||||||
|
assetBundle: assetBundle
|
||||||
),
|
),
|
||||||
Self.getFooter()
|
Self.getFooter()
|
||||||
]
|
]
|
||||||
@@ -379,8 +383,9 @@ enum StringsFileGenerator {
|
|||||||
sections: [Section],
|
sections: [Section],
|
||||||
defaultLang lang: String,
|
defaultLang lang: String,
|
||||||
tags: [String],
|
tags: [String],
|
||||||
staticVar: Bool,
|
isStatic: Bool,
|
||||||
visibility: ExtensionVisibility
|
visibility: ExtensionVisibility,
|
||||||
|
assetBundle: AssetBundle
|
||||||
) -> String {
|
) -> String {
|
||||||
sections.compactMap { section in
|
sections.compactMap { section in
|
||||||
// Check that at least one string will be generated
|
// Check that at least one string will be generated
|
||||||
@@ -394,19 +399,12 @@ enum StringsFileGenerator {
|
|||||||
return nil // Go to next definition
|
return nil // Go to next definition
|
||||||
}
|
}
|
||||||
|
|
||||||
let property: String = {
|
let property = definition.getNSLocalizedStringProperty(
|
||||||
if staticVar {
|
|
||||||
definition.getNSLocalizedStringStaticProperty(
|
|
||||||
forLang: lang,
|
forLang: lang,
|
||||||
visibility: visibility
|
isStatic: isStatic,
|
||||||
|
visibility: visibility,
|
||||||
|
assetBundle: assetBundle
|
||||||
)
|
)
|
||||||
} else {
|
|
||||||
definition.getNSLocalizedStringProperty(
|
|
||||||
forLang: lang,
|
|
||||||
visibility: visibility
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
return "\n\(property)"
|
return "\n\(property)"
|
||||||
}
|
}
|
||||||
|
@@ -15,7 +15,7 @@ enum TagsGenerator {
|
|||||||
sections: [Section],
|
sections: [Section],
|
||||||
lang: String,
|
lang: String,
|
||||||
tags: [String],
|
tags: [String],
|
||||||
staticVar: Bool,
|
isStatic: Bool,
|
||||||
extensionName: String,
|
extensionName: String,
|
||||||
extensionFilePath: String,
|
extensionFilePath: String,
|
||||||
visibility: ExtensionVisibility
|
visibility: ExtensionVisibility
|
||||||
@@ -25,7 +25,7 @@ enum TagsGenerator {
|
|||||||
sections: sections,
|
sections: sections,
|
||||||
lang: lang,
|
lang: lang,
|
||||||
tags: tags,
|
tags: tags,
|
||||||
staticVar: staticVar,
|
isStatic: isStatic,
|
||||||
extensionName: extensionName,
|
extensionName: extensionName,
|
||||||
visibility: visibility
|
visibility: visibility
|
||||||
)
|
)
|
||||||
@@ -47,20 +47,20 @@ enum TagsGenerator {
|
|||||||
sections: [Section],
|
sections: [Section],
|
||||||
lang: String,
|
lang: String,
|
||||||
tags: [String],
|
tags: [String],
|
||||||
staticVar: Bool,
|
isStatic: Bool,
|
||||||
extensionName: String,
|
extensionName: String,
|
||||||
visibility: ExtensionVisibility
|
visibility: ExtensionVisibility
|
||||||
) -> String {
|
) -> String {
|
||||||
[
|
[
|
||||||
Self.getHeader(
|
Self.getHeader(
|
||||||
extensionClassname: extensionName,
|
extensionClassname: extensionName,
|
||||||
staticVar: staticVar
|
isStatic: isStatic
|
||||||
),
|
),
|
||||||
Self.getProperties(
|
Self.getProperties(
|
||||||
sections: sections,
|
sections: sections,
|
||||||
lang: lang,
|
lang: lang,
|
||||||
tags: tags,
|
tags: tags,
|
||||||
staticVar: staticVar,
|
isStatic: isStatic,
|
||||||
visibility: visibility
|
visibility: visibility
|
||||||
),
|
),
|
||||||
Self.getFooter()
|
Self.getFooter()
|
||||||
@@ -70,11 +70,11 @@ enum TagsGenerator {
|
|||||||
|
|
||||||
// MARK: - Extension part
|
// 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)
|
// 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) {
|
extension \(extensionClassname) {
|
||||||
"""
|
"""
|
||||||
@@ -84,7 +84,7 @@ enum TagsGenerator {
|
|||||||
sections: [Section],
|
sections: [Section],
|
||||||
lang: String,
|
lang: String,
|
||||||
tags: [String],
|
tags: [String],
|
||||||
staticVar: Bool,
|
isStatic: Bool,
|
||||||
visibility: ExtensionVisibility
|
visibility: ExtensionVisibility
|
||||||
) -> String {
|
) -> String {
|
||||||
sections
|
sections
|
||||||
@@ -100,11 +100,12 @@ enum TagsGenerator {
|
|||||||
return // Go to next definition
|
return // Go to next definition
|
||||||
}
|
}
|
||||||
|
|
||||||
if staticVar {
|
let property = definition.getProperty(
|
||||||
res += "\n\n\(definition.getStaticProperty(forLang: lang, visibility: visibility))"
|
forLang: lang,
|
||||||
} else {
|
visibility: visibility,
|
||||||
res += "\n\n\(definition.getProperty(forLang: lang, visibility: visibility))"
|
isStatic: isStatic
|
||||||
}
|
)
|
||||||
|
res += "\n\n\(property)"
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
@@ -105,7 +105,8 @@ class Definition {
|
|||||||
translation: String,
|
translation: String,
|
||||||
isStatic: Bool,
|
isStatic: Bool,
|
||||||
comment: String?,
|
comment: String?,
|
||||||
visibility: ExtensionVisibility
|
visibility: ExtensionVisibility,
|
||||||
|
assetBundle: AssetBundle
|
||||||
) -> String {
|
) -> String {
|
||||||
"""
|
"""
|
||||||
/// Translation in \(lang) :
|
/// Translation in \(lang) :
|
||||||
@@ -114,7 +115,7 @@ class Definition {
|
|||||||
/// Comment :
|
/// Comment :
|
||||||
/// \(comment?.isEmpty == false ? comment! : "No comment")
|
/// \(comment?.isEmpty == false ? comment! : "No comment")
|
||||||
\(visibility) \(isStatic ? "static " : "")var \(name): String {
|
\(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 {
|
guard let translation = translations[lang] else {
|
||||||
let error = StringiumError.langNotDefined(lang, name, reference != nil)
|
let error = StringiumError.langNotDefined(lang, name, reference != nil)
|
||||||
print(error.description)
|
print(error.description)
|
||||||
@@ -152,9 +158,10 @@ class Definition {
|
|||||||
let property = getBaseProperty(
|
let property = getBaseProperty(
|
||||||
lang: lang,
|
lang: lang,
|
||||||
translation: translation,
|
translation: translation,
|
||||||
isStatic: false,
|
isStatic: isStatic,
|
||||||
comment: self.comment,
|
comment: self.comment,
|
||||||
visibility: visibility
|
visibility: visibility,
|
||||||
|
assetBundle: assetBundle
|
||||||
)
|
)
|
||||||
|
|
||||||
// Generate method
|
// Generate method
|
||||||
@@ -163,40 +170,7 @@ class Definition {
|
|||||||
method = getBaseMethod(
|
method = getBaseMethod(
|
||||||
lang: lang,
|
lang: lang,
|
||||||
translation: translation,
|
translation: translation,
|
||||||
isStatic: false,
|
isStatic: isStatic,
|
||||||
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,
|
|
||||||
inputParameters: parameters.inputParameters,
|
inputParameters: parameters.inputParameters,
|
||||||
translationArguments: parameters.translationArguments,
|
translationArguments: parameters.translationArguments,
|
||||||
comment: self.comment,
|
comment: self.comment,
|
||||||
@@ -209,7 +183,11 @@ class Definition {
|
|||||||
|
|
||||||
// MARK: - Raw strings
|
// 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 {
|
guard let translation = translations[lang] else {
|
||||||
let error = StringiumError.langNotDefined(lang, name, reference != nil)
|
let error = StringiumError.langNotDefined(lang, name, reference != nil)
|
||||||
print(error.description)
|
print(error.description)
|
||||||
@@ -222,26 +200,7 @@ class Definition {
|
|||||||
///
|
///
|
||||||
/// Comment :
|
/// Comment :
|
||||||
/// \(comment?.isEmpty == false ? comment! : "No comment")
|
/// \(comment?.isEmpty == false ? comment! : "No comment")
|
||||||
\(visibility) var \(name): String {
|
\(visibility) \(isStatic ? "static " : "")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 {
|
|
||||||
"\(translation)"
|
"\(translation)"
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
@@ -68,12 +68,13 @@ struct Stringium: ParsableCommand {
|
|||||||
sections: sections,
|
sections: sections,
|
||||||
defaultLang: options.defaultLang,
|
defaultLang: options.defaultLang,
|
||||||
tags: options.tags,
|
tags: options.tags,
|
||||||
staticVar: options.staticMembers,
|
isStatic: options.staticMembers,
|
||||||
inputFilename: options.inputFilenameWithoutExt,
|
inputFilename: options.inputFilenameWithoutExt,
|
||||||
extensionName: extensionName,
|
extensionName: extensionName,
|
||||||
extensionFilePath: extensionFilePath,
|
extensionFilePath: extensionFilePath,
|
||||||
extensionSuffix: options.extensionSuffix ?? "",
|
extensionSuffix: options.extensionSuffix ?? "",
|
||||||
visibility: options.extensionVisibility
|
visibility: options.extensionVisibility,
|
||||||
|
assetBundle: options.assetBundle
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -57,6 +57,11 @@ struct StringiumOptions: ParsableArguments {
|
|||||||
)
|
)
|
||||||
var extensionVisibility: ExtensionVisibility = .internal
|
var extensionVisibility: ExtensionVisibility = .internal
|
||||||
|
|
||||||
|
@Option(
|
||||||
|
help: "Bundle where the asset are generated"
|
||||||
|
)
|
||||||
|
var assetBundle: AssetBundle = .main
|
||||||
|
|
||||||
@Option(
|
@Option(
|
||||||
help: "Path where to generate the extension.",
|
help: "Path where to generate the extension.",
|
||||||
transform: { $0.replaceTiltWithHomeDirectoryPath() }
|
transform: { $0.replaceTiltWithHomeDirectoryPath() }
|
||||||
|
@@ -47,7 +47,7 @@ struct Tags: ParsableCommand {
|
|||||||
sections: sections,
|
sections: sections,
|
||||||
lang: options.lang,
|
lang: options.lang,
|
||||||
tags: ["ios", "iosonly", Self.noTranslationTag],
|
tags: ["ios", "iosonly", Self.noTranslationTag],
|
||||||
staticVar: options.staticMembers,
|
isStatic: options.staticMembers,
|
||||||
extensionName: options.extensionName,
|
extensionName: options.extensionName,
|
||||||
extensionFilePath: options.extensionFilePath,
|
extensionFilePath: options.extensionFilePath,
|
||||||
visibility: options.extensionVisibility
|
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
|
// When
|
||||||
let propertyFr = definition.getNSLocalizedStringProperty(forLang: "fr", visibility: .public)
|
let propertyFr = definition.getNSLocalizedStringProperty(
|
||||||
let propertyEn = definition.getNSLocalizedStringProperty(forLang: "en", visibility: .public)
|
forLang: "fr",
|
||||||
let propertyEnUs = definition.getNSLocalizedStringProperty(forLang: "en-us", visibility: .public)
|
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
|
// Expect
|
||||||
let expectFr = """
|
let expectFr = """
|
||||||
@@ -149,9 +164,24 @@ final class DefinitionTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let propertyFr = definition.getNSLocalizedStringProperty(forLang: "fr", visibility: .private)
|
let propertyFr = definition.getNSLocalizedStringProperty(
|
||||||
let propertyEn = definition.getNSLocalizedStringProperty(forLang: "en", visibility: .private)
|
forLang: "fr",
|
||||||
let propertyEnUs = definition.getNSLocalizedStringProperty(forLang: "en-us", visibility: .private)
|
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
|
// Expect
|
||||||
let expectFr = """
|
let expectFr = """
|
||||||
@@ -203,9 +233,24 @@ final class DefinitionTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let propertyFr = definition.getNSLocalizedStringProperty(forLang: "fr", visibility: .public)
|
let propertyFr = definition.getNSLocalizedStringProperty(
|
||||||
let propertyEn = definition.getNSLocalizedStringProperty(forLang: "en", visibility: .public)
|
forLang: "fr",
|
||||||
let propertyEnUs = definition.getNSLocalizedStringProperty(forLang: "en-us", visibility: .public)
|
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
|
// Expect
|
||||||
let expectFr = """
|
let expectFr = """
|
||||||
@@ -246,7 +291,7 @@ final class DefinitionTests: XCTestCase {
|
|||||||
XCTAssertEqual(propertyEnUs.adaptForXCTest(), expectEnUs.adaptForXCTest())
|
XCTAssertEqual(propertyEnUs.adaptForXCTest(), expectEnUs.adaptForXCTest())
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - getNSLocalizedStringStaticProperty
|
// MARK: - getNSLocalizedStringProperty - static
|
||||||
|
|
||||||
func testGeneratedNSLocalizedStringStaticProperty() {
|
func testGeneratedNSLocalizedStringStaticProperty() {
|
||||||
// Given
|
// Given
|
||||||
@@ -260,9 +305,24 @@ final class DefinitionTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let propertyFr = definition.getNSLocalizedStringStaticProperty(forLang: "fr", visibility: .public)
|
let propertyFr = definition.getNSLocalizedStringProperty(
|
||||||
let propertyEn = definition.getNSLocalizedStringStaticProperty(forLang: "en", visibility: .public)
|
forLang: "fr",
|
||||||
let propertyEnUs = definition.getNSLocalizedStringStaticProperty(forLang: "en-us", visibility: .public)
|
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
|
// Expect
|
||||||
let expectFr = """
|
let expectFr = """
|
||||||
@@ -315,9 +375,24 @@ final class DefinitionTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let propertyFr = definition.getNSLocalizedStringStaticProperty(forLang: "fr", visibility: .internal)
|
let propertyFr = definition.getNSLocalizedStringProperty(
|
||||||
let propertyEn = definition.getNSLocalizedStringStaticProperty(forLang: "en", visibility: .internal)
|
forLang: "fr",
|
||||||
let propertyEnUs = definition.getNSLocalizedStringStaticProperty(forLang: "en-us", visibility: .internal)
|
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
|
// Expect
|
||||||
let expectFr = """
|
let expectFr = """
|
||||||
@@ -369,9 +444,24 @@ final class DefinitionTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let propertyFr = definition.getNSLocalizedStringStaticProperty(forLang: "fr", visibility: .internal)
|
let propertyFr = definition.getNSLocalizedStringProperty(
|
||||||
let propertyEn = definition.getNSLocalizedStringStaticProperty(forLang: "en", visibility: .internal)
|
forLang: "fr",
|
||||||
let propertyEnUs = definition.getNSLocalizedStringStaticProperty(forLang: "en-us", visibility: .internal)
|
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
|
// Expect
|
||||||
let expectFr = """
|
let expectFr = """
|
||||||
@@ -422,7 +512,12 @@ final class DefinitionTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let propertyFr = definition.getNSLocalizedStringProperty(forLang: "fr", visibility: .internal)
|
let propertyFr = definition.getNSLocalizedStringProperty(
|
||||||
|
forLang: "fr",
|
||||||
|
isStatic: false,
|
||||||
|
visibility: .internal,
|
||||||
|
assetBundle: .main
|
||||||
|
)
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expectFr = """
|
let expectFr = """
|
||||||
@@ -458,7 +553,12 @@ final class DefinitionTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let propertyFr = definition.getNSLocalizedStringProperty(forLang: "fr", visibility: .private)
|
let propertyFr = definition.getNSLocalizedStringProperty(
|
||||||
|
forLang: "fr",
|
||||||
|
isStatic: false,
|
||||||
|
visibility: .private,
|
||||||
|
assetBundle: .main
|
||||||
|
)
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expectFr = """
|
let expectFr = """
|
||||||
@@ -495,8 +595,18 @@ final class DefinitionTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let propertyFr = definition.getNSLocalizedStringProperty(forLang: "fr", visibility: .public)
|
let propertyFr = definition.getNSLocalizedStringProperty(
|
||||||
let propertyEn = definition.getNSLocalizedStringProperty(forLang: "en", visibility: .public)
|
forLang: "fr",
|
||||||
|
isStatic: false,
|
||||||
|
visibility: .public,
|
||||||
|
assetBundle: .main
|
||||||
|
)
|
||||||
|
let propertyEn = definition.getNSLocalizedStringProperty(
|
||||||
|
forLang: "en",
|
||||||
|
isStatic: false,
|
||||||
|
visibility: .public,
|
||||||
|
assetBundle: .main
|
||||||
|
)
|
||||||
|
|
||||||
let expectFr = """
|
let expectFr = """
|
||||||
/// Translation in fr :
|
/// Translation in fr :
|
||||||
@@ -556,9 +666,21 @@ final class DefinitionTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let propertyFr = definition.getProperty(forLang: "fr", visibility: .public)
|
let propertyFr = definition.getProperty(
|
||||||
let propertyEn = definition.getProperty(forLang: "en", visibility: .public)
|
forLang: "fr",
|
||||||
let propertyEnUs = definition.getProperty(forLang: "en-us", visibility: .public)
|
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
|
// Expect
|
||||||
let expectFr = """
|
let expectFr = """
|
||||||
@@ -611,9 +733,21 @@ final class DefinitionTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let propertyFr = definition.getProperty(forLang: "fr", visibility: .package)
|
let propertyFr = definition.getProperty(
|
||||||
let propertyEn = definition.getProperty(forLang: "en", visibility: .package)
|
forLang: "fr",
|
||||||
let propertyEnUs = definition.getProperty(forLang: "en-us", visibility: .package)
|
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
|
// Expect
|
||||||
let expectFr = """
|
let expectFr = """
|
||||||
@@ -665,9 +799,21 @@ final class DefinitionTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let propertyFr = definition.getProperty(forLang: "fr", visibility: .private)
|
let propertyFr = definition.getProperty(
|
||||||
let propertyEn = definition.getProperty(forLang: "en", visibility: .private)
|
forLang: "fr",
|
||||||
let propertyEnUs = definition.getProperty(forLang: "en-us", visibility: .private)
|
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
|
// Expect
|
||||||
let expectFr = """
|
let expectFr = """
|
||||||
@@ -722,9 +868,21 @@ final class DefinitionTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let propertyFr = definition.getStaticProperty(forLang: "fr", visibility: .internal)
|
let propertyFr = definition.getProperty(
|
||||||
let propertyEn = definition.getStaticProperty(forLang: "en", visibility: .internal)
|
forLang: "fr",
|
||||||
let propertyEnUs = definition.getStaticProperty(forLang: "en-us", visibility: .internal)
|
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
|
// Expect
|
||||||
let expectFr = """
|
let expectFr = """
|
||||||
@@ -777,9 +935,21 @@ final class DefinitionTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let propertyFr = definition.getStaticProperty(forLang: "fr", visibility: .internal)
|
let propertyFr = definition.getProperty(
|
||||||
let propertyEn = definition.getStaticProperty(forLang: "en", visibility: .internal)
|
forLang: "fr",
|
||||||
let propertyEnUs = definition.getStaticProperty(forLang: "en-us", visibility: .internal)
|
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
|
// Expect
|
||||||
let expectFr = """
|
let expectFr = """
|
||||||
@@ -831,9 +1001,21 @@ final class DefinitionTests: XCTestCase {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// When
|
// When
|
||||||
let propertyFr = definition.getStaticProperty(forLang: "fr", visibility: .internal)
|
let propertyFr = definition.getProperty(
|
||||||
let propertyEn = definition.getStaticProperty(forLang: "en", visibility: .internal)
|
forLang: "fr",
|
||||||
let propertyEnUs = definition.getStaticProperty(forLang: "en-us", visibility: .internal)
|
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
|
// Expect
|
||||||
let expectFr = """
|
let expectFr = """
|
||||||
|
@@ -20,7 +20,8 @@ extension StringsFileGeneratorTests {
|
|||||||
s2DefOneComment: String = "",
|
s2DefOneComment: String = "",
|
||||||
s2DefTwoFr: String = "Section Deux - Definition Deux",
|
s2DefTwoFr: String = "Section Deux - Definition Deux",
|
||||||
s2DefTwoComment: String = "",
|
s2DefTwoComment: String = "",
|
||||||
visibility: ExtensionVisibility = .internal
|
visibility: ExtensionVisibility = .internal,
|
||||||
|
assetBundle: AssetBundle = .main
|
||||||
) -> String {
|
) -> String {
|
||||||
"""
|
"""
|
||||||
// Generated by ResgenSwift.Strings.Stringium \(ResgenSwiftVersion)
|
// Generated by ResgenSwift.Strings.Stringium \(ResgenSwiftVersion)
|
||||||
@@ -55,7 +56,7 @@ extension StringsFileGeneratorTests {
|
|||||||
/// Comment :
|
/// Comment :
|
||||||
/// \(s1DefOneComment.isEmpty ? "No comment" : s1DefOneComment)
|
/// \(s1DefOneComment.isEmpty ? "No comment" : s1DefOneComment)
|
||||||
\(visibility) \(staticVar ? "static " : "")var s1_def_one: String {
|
\(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 :
|
/// Translation in fr :
|
||||||
@@ -64,7 +65,7 @@ extension StringsFileGeneratorTests {
|
|||||||
/// Comment :
|
/// Comment :
|
||||||
/// \(s1DefTwoComment.isEmpty ? "No comment" : s1DefTwoComment)
|
/// \(s1DefTwoComment.isEmpty ? "No comment" : s1DefTwoComment)
|
||||||
\(visibility) \(staticVar ? "static " : "")var s1_def_two: String {
|
\(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
|
// MARK: - section_two
|
||||||
@@ -75,7 +76,7 @@ extension StringsFileGeneratorTests {
|
|||||||
/// Comment :
|
/// Comment :
|
||||||
/// \(s2DefOneComment.isEmpty ? "No comment" : s2DefOneComment)
|
/// \(s2DefOneComment.isEmpty ? "No comment" : s2DefOneComment)
|
||||||
\(visibility) \(staticVar ? "static " : "")var s2_def_one: String {
|
\(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 :
|
/// Translation in fr :
|
||||||
@@ -84,7 +85,7 @@ extension StringsFileGeneratorTests {
|
|||||||
/// Comment :
|
/// Comment :
|
||||||
/// \(s2DefTwoComment.isEmpty ? "No comment" : s2DefTwoComment)
|
/// \(s2DefTwoComment.isEmpty ? "No comment" : s2DefTwoComment)
|
||||||
\(visibility) \(staticVar ? "static " : "")var s2_def_two: String {
|
\(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],
|
sections: [sectionOne, sectionTwo],
|
||||||
defaultLang: "fr",
|
defaultLang: "fr",
|
||||||
tags: ["ios", "iosonly", "notranslation"],
|
tags: ["ios", "iosonly", "notranslation"],
|
||||||
staticVar: false,
|
isStatic: false,
|
||||||
inputFilename: "myInputFilename",
|
inputFilename: "myInputFilename",
|
||||||
extensionName: "GenStrings",
|
extensionName: "GenStrings",
|
||||||
extensionSuffix: "strings",
|
extensionSuffix: "strings",
|
||||||
visibility: .internal
|
visibility: .internal,
|
||||||
|
assetBundle: .main
|
||||||
)
|
)
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
@@ -411,11 +412,12 @@ final class StringsFileGeneratorTests: XCTestCase {
|
|||||||
sections: [sectionOne, sectionTwo],
|
sections: [sectionOne, sectionTwo],
|
||||||
defaultLang: "fr",
|
defaultLang: "fr",
|
||||||
tags: ["ios", "iosonly", "notranslation"],
|
tags: ["ios", "iosonly", "notranslation"],
|
||||||
staticVar: false,
|
isStatic: false,
|
||||||
inputFilename: "myInputFilename",
|
inputFilename: "myInputFilename",
|
||||||
extensionName: "GenStrings",
|
extensionName: "GenStrings",
|
||||||
extensionSuffix: "strings",
|
extensionSuffix: "strings",
|
||||||
visibility: .public
|
visibility: .public,
|
||||||
|
assetBundle: .main
|
||||||
)
|
)
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
@@ -445,17 +447,19 @@ final class StringsFileGeneratorTests: XCTestCase {
|
|||||||
sections: [sectionOne, sectionTwo],
|
sections: [sectionOne, sectionTwo],
|
||||||
defaultLang: "fr",
|
defaultLang: "fr",
|
||||||
tags: ["ios", "iosonly", "notranslation"],
|
tags: ["ios", "iosonly", "notranslation"],
|
||||||
staticVar: true,
|
isStatic: true,
|
||||||
inputFilename: "myInputFilename",
|
inputFilename: "myInputFilename",
|
||||||
extensionName: "GenStrings",
|
extensionName: "GenStrings",
|
||||||
extensionSuffix: "strings",
|
extensionSuffix: "strings",
|
||||||
visibility: .package
|
visibility: .package,
|
||||||
|
assetBundle: .module
|
||||||
)
|
)
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expect = Self.getExtensionContentExpectation(
|
let expect = Self.getExtensionContentExpectation(
|
||||||
staticVar: true,
|
staticVar: true,
|
||||||
visibility: .package
|
visibility: .package,
|
||||||
|
assetBundle: .module
|
||||||
)
|
)
|
||||||
|
|
||||||
if extensionContent != expect {
|
if extensionContent != expect {
|
||||||
@@ -480,11 +484,12 @@ final class StringsFileGeneratorTests: XCTestCase {
|
|||||||
sections: [sectionOne, sectionTwo],
|
sections: [sectionOne, sectionTwo],
|
||||||
defaultLang: "fr",
|
defaultLang: "fr",
|
||||||
tags: ["ios", "iosonly", "notranslation"],
|
tags: ["ios", "iosonly", "notranslation"],
|
||||||
staticVar: true,
|
isStatic: true,
|
||||||
inputFilename: "myInputFilename",
|
inputFilename: "myInputFilename",
|
||||||
extensionName: "GenStrings",
|
extensionName: "GenStrings",
|
||||||
extensionSuffix: "strings",
|
extensionSuffix: "strings",
|
||||||
visibility: .internal
|
visibility: .internal,
|
||||||
|
assetBundle: .module
|
||||||
)
|
)
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
@@ -494,7 +499,8 @@ final class StringsFileGeneratorTests: XCTestCase {
|
|||||||
s1DefTwoComment: "This is a comment",
|
s1DefTwoComment: "This is a comment",
|
||||||
s2DefOneComment: "This is a comment",
|
s2DefOneComment: "This is a comment",
|
||||||
s2DefTwoComment: "This is a comment",
|
s2DefTwoComment: "This is a comment",
|
||||||
visibility: .internal
|
visibility: .internal,
|
||||||
|
assetBundle: .module
|
||||||
)
|
)
|
||||||
|
|
||||||
if extensionContent != expect {
|
if extensionContent != expect {
|
||||||
|
@@ -49,7 +49,7 @@ final class TagsGeneratorTests: XCTestCase {
|
|||||||
sections: [sectionOne, sectionTwo, sectionThree],
|
sections: [sectionOne, sectionTwo, sectionThree],
|
||||||
lang: "ium",
|
lang: "ium",
|
||||||
tags: ["ios", "iosonly"],
|
tags: ["ios", "iosonly"],
|
||||||
staticVar: false,
|
isStatic: false,
|
||||||
extensionName: "GenTags",
|
extensionName: "GenTags",
|
||||||
visibility: .public
|
visibility: .public
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user