xcstrings #10
@ -84,7 +84,21 @@ class Definition {
|
|||||||
return (inputParameters: inputParameters, translationArguments: translationArguments)
|
return (inputParameters: inputParameters, translationArguments: translationArguments)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func getBaseProperty(lang: String, translation: String, isStatic: Bool) -> String {
|
private func getBaseProperty(lang: String, translation: String, isStatic: Bool, comment: String?) -> String {
|
||||||
|
|
||||||
|
if let comment, !comment.isEmpty {
|
||||||
|
|||||||
|
return
|
||||||
|
"""
|
||||||
|
/// Translation in \(lang) :
|
||||||
|
/// \(translation)
|
||||||
|
/// \(comment)
|
||||||
|
\(isStatic ? "static ": "")var \(name): String {
|
||||||
|
NSLocalizedString("\(name)", tableName: kStringsFileName, bundle: Bundle.main, value: "\(translation)", comment: "\(comment)")
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
"""
|
"""
|
||||||
/// Translation in \(lang) :
|
/// Translation in \(lang) :
|
||||||
/// \(translation)
|
/// \(translation)
|
||||||
@ -94,7 +108,23 @@ class Definition {
|
|||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
private func getBaseMethod(lang: String, translation: String, isStatic: Bool, inputParameters: [String], translationArguments: [String]) -> String {
|
private func getBaseMethod(lang: String, translation: String, isStatic: Bool, inputParameters: [String], translationArguments: [String], comment: String?) -> String {
|
||||||
|
|
||||||
|
if let comment, !comment.isEmpty {
|
||||||
|
return
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
/// Translation in \(lang) :
|
||||||
|
/// \(translation)
|
||||||
|
/// \(comment)
|
||||||
|
\(isStatic ? "static ": "")func \(name)(\(inputParameters.joined(separator: ", "))) -> String {
|
||||||
|
String(format: \(isStatic ? "Self" : "self").\(name), \(translationArguments.joined(separator: ", ")))
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
@ -114,7 +144,12 @@ class Definition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Generate property
|
// Generate property
|
||||||
let property = getBaseProperty(lang: lang, translation: translation, isStatic: false)
|
let property = getBaseProperty(
|
||||||
|
lang: lang,
|
||||||
|
translation: translation,
|
||||||
|
isStatic: false,
|
||||||
|
comment: self.comment
|
||||||
|
)
|
||||||
|
|
||||||
// Generate method
|
// Generate method
|
||||||
var method = ""
|
var method = ""
|
||||||
@ -123,7 +158,8 @@ class Definition {
|
|||||||
translation: translation,
|
translation: translation,
|
||||||
isStatic: false,
|
isStatic: false,
|
||||||
inputParameters: parameters.inputParameters,
|
inputParameters: parameters.inputParameters,
|
||||||
translationArguments: parameters.translationArguments)
|
translationArguments: parameters.translationArguments,
|
||||||
|
comment: self.comment)
|
||||||
}
|
}
|
||||||
|
|
||||||
return property + method
|
return property + method
|
||||||
@ -137,7 +173,12 @@ class Definition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Generate property
|
// Generate property
|
||||||
let property = getBaseProperty(lang: lang, translation: translation, isStatic: true)
|
let property = getBaseProperty(
|
||||||
|
lang: lang,
|
||||||
|
translation: translation,
|
||||||
|
isStatic: true,
|
||||||
|
comment: self.comment
|
||||||
|
)
|
||||||
|
|
||||||
// Generate method
|
// Generate method
|
||||||
var method = ""
|
var method = ""
|
||||||
@ -146,7 +187,8 @@ class Definition {
|
|||||||
translation: translation,
|
translation: translation,
|
||||||
isStatic: true,
|
isStatic: true,
|
||||||
inputParameters: parameters.inputParameters,
|
inputParameters: parameters.inputParameters,
|
||||||
translationArguments: parameters.translationArguments)
|
translationArguments: parameters.translationArguments,
|
||||||
|
comment: self.comment)
|
||||||
}
|
}
|
||||||
|
|
||||||
return property + method
|
return property + method
|
||||||
@ -161,6 +203,17 @@ class Definition {
|
|||||||
Stringium.exit(withError: error)
|
Stringium.exit(withError: error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let comment, !comment.isEmpty {
|
||||||
|
return """
|
||||||
|
/// Translation in \(lang) :
|
||||||
|
/// \(translation)
|
||||||
|
/// \(comment)
|
||||||
|
var \(name): String {
|
||||||
|
"\(translation)"
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
|
||||||
return """
|
return """
|
||||||
/// Translation in \(lang) :
|
/// Translation in \(lang) :
|
||||||
/// \(translation)
|
/// \(translation)
|
||||||
@ -177,6 +230,17 @@ class Definition {
|
|||||||
Stringium.exit(withError: error)
|
Stringium.exit(withError: error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let comment, !comment.isEmpty {
|
||||||
|
return """
|
||||||
|
/// Translation in \(lang) :
|
||||||
|
/// \(translation)
|
||||||
|
/// \(comment)
|
||||||
|
static var \(name): String {
|
||||||
|
"\(translation)"
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
|
||||||
return """
|
return """
|
||||||
/// Translation in \(lang) :
|
/// Translation in \(lang) :
|
||||||
/// \(translation)
|
/// \(translation)
|
||||||
|
@ -96,6 +96,55 @@ final class DefinitionTests: XCTestCase {
|
|||||||
let propertyEn = definition.getNSLocalizedStringProperty(forLang: "en")
|
let propertyEn = definition.getNSLocalizedStringProperty(forLang: "en")
|
||||||
let propertyEnUs = definition.getNSLocalizedStringProperty(forLang: "en-us")
|
let propertyEnUs = definition.getNSLocalizedStringProperty(forLang: "en-us")
|
||||||
|
|
||||||
|
// Expect
|
||||||
|
let expectFr = """
|
||||||
|
/// Translation in fr :
|
||||||
|
/// C'est la traduction francaise
|
||||||
|
/// This is a comment
|
||||||
|
var definition_name: String {
|
||||||
|
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "C'est la traduction francaise", comment: "This is a comment")
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
let expectEn = """
|
||||||
|
/// Translation in en :
|
||||||
|
/// This is the english translation
|
||||||
|
/// This is a comment
|
||||||
|
var definition_name: String {
|
||||||
|
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "This is the english translation", comment: "This is a comment")
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
let expectEnUs = """
|
||||||
|
/// Translation in en-us :
|
||||||
|
/// This is the english us translation
|
||||||
|
/// This is a comment
|
||||||
|
var definition_name: String {
|
||||||
|
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "This is the english us translation", comment: "This is a comment")
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
XCTAssertEqual(propertyFr.adaptForXCTest(), expectFr.adaptForXCTest())
|
||||||
|
XCTAssertEqual(propertyEn.adaptForXCTest(), expectEn.adaptForXCTest())
|
||||||
|
XCTAssertEqual(propertyEnUs.adaptForXCTest(), expectEnUs.adaptForXCTest())
|
||||||
|
}
|
||||||
|
|
||||||
|
func testGeneratedNSLocalizedStringPropertyWithEmptyComment() {
|
||||||
|
// Given
|
||||||
|
let definition = Definition(name: "definition_name")
|
||||||
|
definition.tags = ["ios","iosonly","notranslation"]
|
||||||
|
definition.comment = ""
|
||||||
|
definition.translations = [
|
||||||
|
"fr": "C'est la traduction francaise",
|
||||||
|
"en": "This is the english translation",
|
||||||
|
"en-us": "This is the english us translation"
|
||||||
|
]
|
||||||
|
|
||||||
|
// When
|
||||||
|
let propertyFr = definition.getNSLocalizedStringProperty(forLang: "fr")
|
||||||
|
let propertyEn = definition.getNSLocalizedStringProperty(forLang: "en")
|
||||||
|
let propertyEnUs = definition.getNSLocalizedStringProperty(forLang: "en-us")
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expectFr = """
|
let expectFr = """
|
||||||
/// Translation in fr :
|
/// Translation in fr :
|
||||||
@ -126,6 +175,53 @@ final class DefinitionTests: XCTestCase {
|
|||||||
XCTAssertEqual(propertyEnUs.adaptForXCTest(), expectEnUs.adaptForXCTest())
|
XCTAssertEqual(propertyEnUs.adaptForXCTest(), expectEnUs.adaptForXCTest())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testGeneratedNSLocalizedStringPropertyWithNoComment() {
|
||||||
|
// Given
|
||||||
|
let definition = Definition(name: "definition_name")
|
||||||
|
definition.tags = ["ios","iosonly","notranslation"]
|
||||||
|
definition.translations = [
|
||||||
|
"fr": "C'est la traduction francaise",
|
||||||
|
"en": "This is the english translation",
|
||||||
|
"en-us": "This is the english us translation"
|
||||||
|
]
|
||||||
|
|
||||||
|
// When
|
||||||
|
let propertyFr = definition.getNSLocalizedStringProperty(forLang: "fr")
|
||||||
|
let propertyEn = definition.getNSLocalizedStringProperty(forLang: "en")
|
||||||
|
let propertyEnUs = definition.getNSLocalizedStringProperty(forLang: "en-us")
|
||||||
|
|
||||||
|
// Expect
|
||||||
|
let expectFr = """
|
||||||
|
/// Translation in fr :
|
||||||
|
/// C'est la traduction francaise
|
||||||
|
var definition_name: String {
|
||||||
|
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "C'est la traduction francaise", comment: "")
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
let expectEn = """
|
||||||
|
/// Translation in en :
|
||||||
|
/// This is the english translation
|
||||||
|
var definition_name: String {
|
||||||
|
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "This is the english translation", comment: "")
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
let expectEnUs = """
|
||||||
|
/// Translation in en-us :
|
||||||
|
/// This is the english us translation
|
||||||
|
var definition_name: String {
|
||||||
|
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "This is the english us translation", comment: "")
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
XCTAssertEqual(propertyFr.adaptForXCTest(), expectFr.adaptForXCTest())
|
||||||
|
XCTAssertEqual(propertyEn.adaptForXCTest(), expectEn.adaptForXCTest())
|
||||||
|
XCTAssertEqual(propertyEnUs.adaptForXCTest(), expectEnUs.adaptForXCTest())
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - getNSLocalizedStringStaticProperty
|
||||||
|
|
||||||
func testGeneratedNSLocalizedStringStaticProperty() {
|
func testGeneratedNSLocalizedStringStaticProperty() {
|
||||||
// Given
|
// Given
|
||||||
let definition = Definition(name: "definition_name")
|
let definition = Definition(name: "definition_name")
|
||||||
@ -142,6 +238,100 @@ final class DefinitionTests: XCTestCase {
|
|||||||
let propertyEn = definition.getNSLocalizedStringStaticProperty(forLang: "en")
|
let propertyEn = definition.getNSLocalizedStringStaticProperty(forLang: "en")
|
||||||
let propertyEnUs = definition.getNSLocalizedStringStaticProperty(forLang: "en-us")
|
let propertyEnUs = definition.getNSLocalizedStringStaticProperty(forLang: "en-us")
|
||||||
|
|
||||||
|
// Expect
|
||||||
|
let expectFr = """
|
||||||
|
/// Translation in fr :
|
||||||
|
/// C'est la traduction francaise
|
||||||
|
/// This is a comment
|
||||||
|
static var definition_name: String {
|
||||||
|
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "C'est la traduction francaise", comment: "This is a comment")
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
let expectEn = """
|
||||||
|
/// Translation in en :
|
||||||
|
/// This is the english translation
|
||||||
|
/// This is a comment
|
||||||
|
static var definition_name: String {
|
||||||
|
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "This is the english translation", comment: "This is a comment")
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
let expectEnUs = """
|
||||||
|
/// Translation in en-us :
|
||||||
|
/// This is the english us translation
|
||||||
|
/// This is a comment
|
||||||
|
static var definition_name: String {
|
||||||
|
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "This is the english us translation", comment: "This is a comment")
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
XCTAssertEqual(propertyFr.adaptForXCTest(), expectFr.adaptForXCTest())
|
||||||
|
XCTAssertEqual(propertyEn.adaptForXCTest(), expectEn.adaptForXCTest())
|
||||||
|
XCTAssertEqual(propertyEnUs.adaptForXCTest(), expectEnUs.adaptForXCTest())
|
||||||
|
}
|
||||||
|
|
||||||
|
func testGeneratedNSLocalizedStringStaticPropertyWithEmptyComment() {
|
||||||
|
// Given
|
||||||
|
let definition = Definition(name: "definition_name")
|
||||||
|
definition.tags = ["ios","iosonly","notranslation"]
|
||||||
|
definition.comment = ""
|
||||||
|
definition.translations = [
|
||||||
|
"fr": "C'est la traduction francaise",
|
||||||
|
"en": "This is the english translation",
|
||||||
|
"en-us": "This is the english us translation"
|
||||||
|
]
|
||||||
|
|
||||||
|
// When
|
||||||
|
let propertyFr = definition.getNSLocalizedStringStaticProperty(forLang: "fr")
|
||||||
|
let propertyEn = definition.getNSLocalizedStringStaticProperty(forLang: "en")
|
||||||
|
let propertyEnUs = definition.getNSLocalizedStringStaticProperty(forLang: "en-us")
|
||||||
|
|
||||||
|
// Expect
|
||||||
|
let expectFr = """
|
||||||
|
/// Translation in fr :
|
||||||
|
/// C'est la traduction francaise
|
||||||
|
static var definition_name: String {
|
||||||
|
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "C'est la traduction francaise", comment: "")
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
let expectEn = """
|
||||||
|
/// Translation in en :
|
||||||
|
/// This is the english translation
|
||||||
|
static var definition_name: String {
|
||||||
|
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "This is the english translation", comment: "")
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
let expectEnUs = """
|
||||||
|
/// Translation in en-us :
|
||||||
|
/// This is the english us translation
|
||||||
|
static var definition_name: String {
|
||||||
|
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "This is the english us translation", comment: "")
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
XCTAssertEqual(propertyFr.adaptForXCTest(), expectFr.adaptForXCTest())
|
||||||
|
XCTAssertEqual(propertyEn.adaptForXCTest(), expectEn.adaptForXCTest())
|
||||||
|
XCTAssertEqual(propertyEnUs.adaptForXCTest(), expectEnUs.adaptForXCTest())
|
||||||
|
}
|
||||||
|
|
||||||
|
func testGeneratedNSLocalizedStringStaticPropertyWithNoComment() {
|
||||||
|
// Given
|
||||||
|
let definition = Definition(name: "definition_name")
|
||||||
|
definition.tags = ["ios","iosonly","notranslation"]
|
||||||
|
definition.translations = [
|
||||||
|
"fr": "C'est la traduction francaise",
|
||||||
|
"en": "This is the english translation",
|
||||||
|
"en-us": "This is the english us translation"
|
||||||
|
]
|
||||||
|
|
||||||
|
// When
|
||||||
|
let propertyFr = definition.getNSLocalizedStringStaticProperty(forLang: "fr")
|
||||||
|
let propertyEn = definition.getNSLocalizedStringStaticProperty(forLang: "en")
|
||||||
|
let propertyEnUs = definition.getNSLocalizedStringStaticProperty(forLang: "en-us")
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expectFr = """
|
let expectFr = """
|
||||||
/// Translation in fr :
|
/// Translation in fr :
|
||||||
@ -188,12 +378,14 @@ final class DefinitionTests: XCTestCase {
|
|||||||
let expectFr = """
|
let expectFr = """
|
||||||
/// Translation in fr :
|
/// Translation in fr :
|
||||||
/// Welcome "%@" !
|
/// Welcome "%@" !
|
||||||
|
/// This is a comment
|
||||||
var definition_name: String {
|
var definition_name: String {
|
||||||
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "Welcome \"%@\" !", comment: "")
|
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "Welcome \"%@\" !", comment: "This is a comment")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Translation in fr :
|
/// Translation in fr :
|
||||||
/// Welcome "%@" !
|
/// Welcome "%@" !
|
||||||
|
/// This is a comment
|
||||||
func definition_name(arg0: String) -> String {
|
func definition_name(arg0: String) -> String {
|
||||||
String(format: self.definition_name, arg0)
|
String(format: self.definition_name, arg0)
|
||||||
}
|
}
|
||||||
@ -218,12 +410,14 @@ final class DefinitionTests: XCTestCase {
|
|||||||
let expectFr = """
|
let expectFr = """
|
||||||
/// Translation in fr :
|
/// Translation in fr :
|
||||||
/// Welcome "%@" ! Your age is %d :) Your weight is %f ;-)
|
/// Welcome "%@" ! Your age is %d :) Your weight is %f ;-)
|
||||||
|
/// This is a comment
|
||||||
var definition_name: String {
|
var definition_name: String {
|
||||||
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "Welcome \"%@\" ! Your age is %d :) Your weight is %f ;-)", comment: "")
|
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "Welcome \"%@\" ! Your age is %d :) Your weight is %f ;-)", comment: "This is a comment")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Translation in fr :
|
/// Translation in fr :
|
||||||
/// Welcome "%@" ! Your age is %d :) Your weight is %f ;-)
|
/// Welcome "%@" ! Your age is %d :) Your weight is %f ;-)
|
||||||
|
/// This is a comment
|
||||||
func definition_name(arg0: String, arg1: Int, arg2: Double) -> String {
|
func definition_name(arg0: String, arg1: Int, arg2: Double) -> String {
|
||||||
String(format: self.definition_name, arg0, arg1, arg2)
|
String(format: self.definition_name, arg0, arg1, arg2)
|
||||||
}
|
}
|
||||||
@ -249,12 +443,14 @@ final class DefinitionTests: XCTestCase {
|
|||||||
let expectFr = """
|
let expectFr = """
|
||||||
/// Translation in fr :
|
/// Translation in fr :
|
||||||
/// Vous %%: %1$@ %2$@ Age: %3$d
|
/// Vous %%: %1$@ %2$@ Age: %3$d
|
||||||
|
/// This is a comment
|
||||||
var definition_name: String {
|
var definition_name: String {
|
||||||
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "Vous %%: %1$@ %2$@ Age: %3$d", comment: "")
|
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "Vous %%: %1$@ %2$@ Age: %3$d", comment: "This is a comment")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Translation in fr :
|
/// Translation in fr :
|
||||||
/// Vous %%: %1$@ %2$@ Age: %3$d
|
/// Vous %%: %1$@ %2$@ Age: %3$d
|
||||||
|
/// This is a comment
|
||||||
func definition_name(arg0: String, arg1: String, arg2: Int) -> String {
|
func definition_name(arg0: String, arg1: String, arg2: Int) -> String {
|
||||||
String(format: self.definition_name, arg0, arg1, arg2)
|
String(format: self.definition_name, arg0, arg1, arg2)
|
||||||
}
|
}
|
||||||
@ -263,12 +459,14 @@ final class DefinitionTests: XCTestCase {
|
|||||||
let expectEn = """
|
let expectEn = """
|
||||||
/// Translation in en :
|
/// Translation in en :
|
||||||
/// You %%: %2$@ %1$@ Age: %3$d
|
/// You %%: %2$@ %1$@ Age: %3$d
|
||||||
|
/// This is a comment
|
||||||
var definition_name: String {
|
var definition_name: String {
|
||||||
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "You %%: %2$@ %1$@ Age: %3$d", comment: "")
|
NSLocalizedString("definition_name", tableName: kStringsFileName, bundle: Bundle.main, value: "You %%: %2$@ %1$@ Age: %3$d", comment: "This is a comment")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Translation in en :
|
/// Translation in en :
|
||||||
/// You %%: %2$@ %1$@ Age: %3$d
|
/// You %%: %2$@ %1$@ Age: %3$d
|
||||||
|
/// This is a comment
|
||||||
func definition_name(arg0: String, arg1: String, arg2: Int) -> String {
|
func definition_name(arg0: String, arg1: String, arg2: Int) -> String {
|
||||||
String(format: self.definition_name, arg0, arg1, arg2)
|
String(format: self.definition_name, arg0, arg1, arg2)
|
||||||
}
|
}
|
||||||
@ -296,6 +494,55 @@ final class DefinitionTests: XCTestCase {
|
|||||||
let propertyEn = definition.getProperty(forLang: "en")
|
let propertyEn = definition.getProperty(forLang: "en")
|
||||||
let propertyEnUs = definition.getProperty(forLang: "en-us")
|
let propertyEnUs = definition.getProperty(forLang: "en-us")
|
||||||
|
|
||||||
|
// Expect
|
||||||
|
let expectFr = """
|
||||||
|
/// Translation in fr :
|
||||||
|
/// C'est la traduction francaise
|
||||||
|
/// This is a comment
|
||||||
|
var definition_name: String {
|
||||||
|
"C'est la traduction francaise"
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
let expectEn = """
|
||||||
|
/// Translation in en :
|
||||||
|
/// This is the english translation
|
||||||
|
/// This is a comment
|
||||||
|
var definition_name: String {
|
||||||
|
"This is the english translation"
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
let expectEnUs = """
|
||||||
|
/// Translation in en-us :
|
||||||
|
/// This is the english us translation
|
||||||
|
/// This is a comment
|
||||||
|
var definition_name: String {
|
||||||
|
"This is the english us translation"
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
XCTAssertEqual(propertyFr.adaptForXCTest(), expectFr.adaptForXCTest())
|
||||||
|
XCTAssertEqual(propertyEn.adaptForXCTest(), expectEn.adaptForXCTest())
|
||||||
|
XCTAssertEqual(propertyEnUs.adaptForXCTest(), expectEnUs.adaptForXCTest())
|
||||||
|
}
|
||||||
|
|
||||||
|
func testGeneratedRawPropertyWithEmptyComment() {
|
||||||
|
// Given
|
||||||
|
let definition = Definition(name: "definition_name")
|
||||||
|
definition.tags = ["ios","iosonly","notranslation"]
|
||||||
|
definition.comment = ""
|
||||||
|
definition.translations = [
|
||||||
|
"fr": "C'est la traduction francaise",
|
||||||
|
"en": "This is the english translation",
|
||||||
|
"en-us": "This is the english us translation"
|
||||||
|
]
|
||||||
|
|
||||||
|
// When
|
||||||
|
let propertyFr = definition.getProperty(forLang: "fr")
|
||||||
|
let propertyEn = definition.getProperty(forLang: "en")
|
||||||
|
let propertyEnUs = definition.getProperty(forLang: "en-us")
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expectFr = """
|
let expectFr = """
|
||||||
/// Translation in fr :
|
/// Translation in fr :
|
||||||
@ -326,6 +573,53 @@ final class DefinitionTests: XCTestCase {
|
|||||||
XCTAssertEqual(propertyEnUs.adaptForXCTest(), expectEnUs.adaptForXCTest())
|
XCTAssertEqual(propertyEnUs.adaptForXCTest(), expectEnUs.adaptForXCTest())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testGeneratedRawPropertyWithNoComment() {
|
||||||
|
// Given
|
||||||
|
let definition = Definition(name: "definition_name")
|
||||||
|
definition.tags = ["ios","iosonly","notranslation"]
|
||||||
|
definition.translations = [
|
||||||
|
"fr": "C'est la traduction francaise",
|
||||||
|
"en": "This is the english translation",
|
||||||
|
"en-us": "This is the english us translation"
|
||||||
|
]
|
||||||
|
|
||||||
|
// When
|
||||||
|
let propertyFr = definition.getProperty(forLang: "fr")
|
||||||
|
let propertyEn = definition.getProperty(forLang: "en")
|
||||||
|
let propertyEnUs = definition.getProperty(forLang: "en-us")
|
||||||
|
|
||||||
|
// Expect
|
||||||
|
let expectFr = """
|
||||||
|
/// Translation in fr :
|
||||||
|
/// C'est la traduction francaise
|
||||||
|
var definition_name: String {
|
||||||
|
"C'est la traduction francaise"
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
let expectEn = """
|
||||||
|
/// Translation in en :
|
||||||
|
/// This is the english translation
|
||||||
|
var definition_name: String {
|
||||||
|
"This is the english translation"
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
let expectEnUs = """
|
||||||
|
/// Translation in en-us :
|
||||||
|
/// This is the english us translation
|
||||||
|
var definition_name: String {
|
||||||
|
"This is the english us translation"
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
XCTAssertEqual(propertyFr.adaptForXCTest(), expectFr.adaptForXCTest())
|
||||||
|
XCTAssertEqual(propertyEn.adaptForXCTest(), expectEn.adaptForXCTest())
|
||||||
|
XCTAssertEqual(propertyEnUs.adaptForXCTest(), expectEnUs.adaptForXCTest())
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Raw static properties
|
||||||
|
|
||||||
func testGeneratedRawStaticProperty() {
|
func testGeneratedRawStaticProperty() {
|
||||||
// Given
|
// Given
|
||||||
let definition = Definition(name: "definition_name")
|
let definition = Definition(name: "definition_name")
|
||||||
@ -342,6 +636,100 @@ final class DefinitionTests: XCTestCase {
|
|||||||
let propertyEn = definition.getStaticProperty(forLang: "en")
|
let propertyEn = definition.getStaticProperty(forLang: "en")
|
||||||
let propertyEnUs = definition.getStaticProperty(forLang: "en-us")
|
let propertyEnUs = definition.getStaticProperty(forLang: "en-us")
|
||||||
|
|
||||||
|
// Expect
|
||||||
|
let expectFr = """
|
||||||
|
/// Translation in fr :
|
||||||
|
/// C'est la traduction francaise
|
||||||
|
/// This is a comment
|
||||||
|
static var definition_name: String {
|
||||||
|
"C'est la traduction francaise"
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
let expectEn = """
|
||||||
|
/// Translation in en :
|
||||||
|
/// This is the english translation
|
||||||
|
/// This is a comment
|
||||||
|
static var definition_name: String {
|
||||||
|
"This is the english translation"
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
let expectEnUs = """
|
||||||
|
/// Translation in en-us :
|
||||||
|
/// This is the english us translation
|
||||||
|
/// This is a comment
|
||||||
|
static var definition_name: String {
|
||||||
|
"This is the english us translation"
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
XCTAssertEqual(propertyFr.adaptForXCTest(), expectFr.adaptForXCTest())
|
||||||
|
XCTAssertEqual(propertyEn.adaptForXCTest(), expectEn.adaptForXCTest())
|
||||||
|
XCTAssertEqual(propertyEnUs.adaptForXCTest(), expectEnUs.adaptForXCTest())
|
||||||
|
}
|
||||||
|
|
||||||
|
func testGeneratedRawStaticPropertyWithEmptyComment() {
|
||||||
|
// Given
|
||||||
|
let definition = Definition(name: "definition_name")
|
||||||
|
definition.tags = ["ios","iosonly","notranslation"]
|
||||||
|
definition.comment = ""
|
||||||
|
definition.translations = [
|
||||||
|
"fr": "C'est la traduction francaise",
|
||||||
|
"en": "This is the english translation",
|
||||||
|
"en-us": "This is the english us translation"
|
||||||
|
]
|
||||||
|
|
||||||
|
// When
|
||||||
|
let propertyFr = definition.getStaticProperty(forLang: "fr")
|
||||||
|
let propertyEn = definition.getStaticProperty(forLang: "en")
|
||||||
|
let propertyEnUs = definition.getStaticProperty(forLang: "en-us")
|
||||||
|
|
||||||
|
// Expect
|
||||||
|
let expectFr = """
|
||||||
|
/// Translation in fr :
|
||||||
|
/// C'est la traduction francaise
|
||||||
|
static var definition_name: String {
|
||||||
|
"C'est la traduction francaise"
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
let expectEn = """
|
||||||
|
/// Translation in en :
|
||||||
|
/// This is the english translation
|
||||||
|
static var definition_name: String {
|
||||||
|
"This is the english translation"
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
let expectEnUs = """
|
||||||
|
/// Translation in en-us :
|
||||||
|
/// This is the english us translation
|
||||||
|
static var definition_name: String {
|
||||||
|
"This is the english us translation"
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
XCTAssertEqual(propertyFr.adaptForXCTest(), expectFr.adaptForXCTest())
|
||||||
|
XCTAssertEqual(propertyEn.adaptForXCTest(), expectEn.adaptForXCTest())
|
||||||
|
XCTAssertEqual(propertyEnUs.adaptForXCTest(), expectEnUs.adaptForXCTest())
|
||||||
|
}
|
||||||
|
|
||||||
|
func testGeneratedRawStaticPropertyWithNoComment() {
|
||||||
|
// Given
|
||||||
|
let definition = Definition(name: "definition_name")
|
||||||
|
definition.tags = ["ios","iosonly","notranslation"]
|
||||||
|
definition.translations = [
|
||||||
|
"fr": "C'est la traduction francaise",
|
||||||
|
"en": "This is the english translation",
|
||||||
|
"en-us": "This is the english us translation"
|
||||||
|
]
|
||||||
|
|
||||||
|
// When
|
||||||
|
let propertyFr = definition.getStaticProperty(forLang: "fr")
|
||||||
|
let propertyEn = definition.getStaticProperty(forLang: "en")
|
||||||
|
let propertyEnUs = definition.getStaticProperty(forLang: "en-us")
|
||||||
|
|
||||||
// Expect
|
// Expect
|
||||||
let expectFr = """
|
let expectFr = """
|
||||||
/// Translation in fr :
|
/// Translation in fr :
|
||||||
|
@ -13,13 +13,16 @@ import ToolCore
|
|||||||
|
|
||||||
final class StringsFileGeneratorTests: XCTestCase {
|
final class StringsFileGeneratorTests: XCTestCase {
|
||||||
|
|
||||||
private func getDefinition(name: String, translations: [String: String], tags: [String]) -> Definition {
|
private func getDefinition(name: String, translations: [String: String], tags: [String], comment: String? = nil) -> Definition {
|
||||||
let definition = Definition(name: name)
|
let definition = Definition(name: name)
|
||||||
definition.tags = tags
|
definition.tags = tags
|
||||||
definition.translations = translations
|
definition.translations = translations
|
||||||
|
definition.comment = comment
|
||||||
return definition
|
return definition
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - Strings File Content
|
||||||
|
|
||||||
func testGenerateStringsFileContent() {
|
func testGenerateStringsFileContent() {
|
||||||
// Given
|
// Given
|
||||||
let sectionOne = Section(name: "section_one")
|
let sectionOne = Section(name: "section_one")
|
||||||
@ -100,6 +103,91 @@ final class StringsFileGeneratorTests: XCTestCase {
|
|||||||
XCTAssertEqual(stringsFileContentEn.adaptForXCTest(), expectEn.adaptForXCTest())
|
XCTAssertEqual(stringsFileContentEn.adaptForXCTest(), expectEn.adaptForXCTest())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testGenerateStringsFileContentWithComment() {
|
||||||
|
// Given
|
||||||
|
let sectionOne = Section(name: "section_one")
|
||||||
|
sectionOne.definitions = [
|
||||||
|
getDefinition(name: "s1_def_one",
|
||||||
|
translations: ["fr": "Section Un - Definition Un",
|
||||||
|
"en": "Section One - Definition One"],
|
||||||
|
tags: ["ios","iosonly"],
|
||||||
|
comment: "This is a comment"),
|
||||||
|
getDefinition(name: "s1_def_two",
|
||||||
|
translations: ["fr": "Section Un - Definition Deux",
|
||||||
|
"en": "Section One - Definition Two"],
|
||||||
|
tags: ["ios","iosonly"],
|
||||||
|
comment: "This is a comment")
|
||||||
|
]
|
||||||
|
|
||||||
|
let sectionTwo = Section(name: "section_two")
|
||||||
|
sectionTwo.definitions = [
|
||||||
|
getDefinition(name: "s2_def_one",
|
||||||
|
translations: ["fr": "Section Deux - Definition Un",
|
||||||
|
"en": "Section Two - Definition One"],
|
||||||
|
tags: ["ios","iosonly"],
|
||||||
|
comment: "This is a comment"),
|
||||||
|
getDefinition(name: "s2_def_two",
|
||||||
|
translations: ["fr": "Section Deux - Definition Deux"],
|
||||||
|
tags: ["notranslation"],
|
||||||
|
comment: "This is a comment")
|
||||||
|
]
|
||||||
|
|
||||||
|
// When
|
||||||
|
let stringsFileContentFr = StringsFileGenerator.generateStringsFileContent(lang: "fr",
|
||||||
|
defaultLang: "fr",
|
||||||
|
tags: ["ios", "iosonly", "notranslation"],
|
||||||
|
sections: [sectionOne, sectionTwo])
|
||||||
|
let stringsFileContentEn = StringsFileGenerator.generateStringsFileContent(lang: "en",
|
||||||
|
defaultLang: "fr",
|
||||||
|
tags: ["ios", "iosonly", "notranslation"],
|
||||||
|
sections: [sectionOne, sectionTwo])
|
||||||
|
|
||||||
|
// Expect
|
||||||
|
let expectFr = """
|
||||||
|
/**
|
||||||
|
* Apple Strings File
|
||||||
|
* Generated by ResgenSwift \(ResgenSwiftVersion)
|
||||||
|
* Language: fr
|
||||||
|
*/
|
||||||
|
|
||||||
|
/********** section_one **********/
|
||||||
|
|
||||||
|
"s1_def_one" = "Section Un - Definition Un";
|
||||||
|
|
||||||
|
"s1_def_two" = "Section Un - Definition Deux";
|
||||||
|
|
||||||
|
/********** section_two **********/
|
||||||
|
|
||||||
|
"s2_def_one" = "Section Deux - Definition Un";
|
||||||
|
|
||||||
|
"s2_def_two" = "Section Deux - Definition Deux";
|
||||||
|
"""
|
||||||
|
|
||||||
|
let expectEn = """
|
||||||
|
/**
|
||||||
|
* Apple Strings File
|
||||||
|
* Generated by ResgenSwift \(ResgenSwiftVersion)
|
||||||
|
* Language: en
|
||||||
|
*/
|
||||||
|
|
||||||
|
/********** section_one **********/
|
||||||
|
|
||||||
|
"s1_def_one" = "Section One - Definition One";
|
||||||
|
|
||||||
|
"s1_def_two" = "Section One - Definition Two";
|
||||||
|
|
||||||
|
/********** section_two **********/
|
||||||
|
|
||||||
|
"s2_def_one" = "Section Two - Definition One";
|
||||||
|
|
||||||
|
"s2_def_two" = "Section Deux - Definition Deux";
|
||||||
|
"""
|
||||||
|
|
||||||
|
XCTAssertEqual(stringsFileContentFr.adaptForXCTest(), expectFr.adaptForXCTest())
|
||||||
|
XCTAssertEqual(stringsFileContentEn.adaptForXCTest(), expectEn.adaptForXCTest())
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Extension Content
|
||||||
func testGeneratedExtensionContent() {
|
func testGeneratedExtensionContent() {
|
||||||
// Given
|
// Given
|
||||||
let sectionOne = Section(name: "section_one")
|
let sectionOne = Section(name: "section_one")
|
||||||
@ -196,6 +284,111 @@ final class StringsFileGeneratorTests: XCTestCase {
|
|||||||
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testGeneratedExtensionContentWithComment() {
|
||||||
|
// Given
|
||||||
|
let sectionOne = Section(name: "section_one")
|
||||||
|
sectionOne.definitions = [
|
||||||
|
getDefinition(name: "s1_def_one",
|
||||||
|
translations: ["fr": "Section Un - Definition Un",
|
||||||
|
"en": "Section One - Definition One"],
|
||||||
|
tags: ["ios","iosonly"],
|
||||||
|
comment: "This is a comment"),
|
||||||
|
getDefinition(name: "s1_def_two",
|
||||||
|
translations: ["fr": "Section Un - Definition Deux",
|
||||||
|
"en": "Section One - Definition Two"],
|
||||||
|
tags: ["ios","iosonly"],
|
||||||
|
comment: "This is a comment")
|
||||||
|
]
|
||||||
|
|
||||||
|
let sectionTwo = Section(name: "section_two")
|
||||||
|
sectionTwo.definitions = [
|
||||||
|
getDefinition(name: "s2_def_one",
|
||||||
|
translations: ["fr": "Section Deux - Definition Un",
|
||||||
|
"en": "Section Two - Definition One"],
|
||||||
|
tags: ["ios","iosonly"],
|
||||||
|
comment: "This is a comment"),
|
||||||
|
getDefinition(name: "s2_def_two",
|
||||||
|
translations: ["fr": "Section Deux - Definition Deux"],
|
||||||
|
tags: ["notranslation"],
|
||||||
|
comment: "This is a comment")
|
||||||
|
]
|
||||||
|
|
||||||
|
// When
|
||||||
|
let extensionContent = StringsFileGenerator.getExtensionContent(sections: [sectionOne, sectionTwo],
|
||||||
|
defaultLang: "fr",
|
||||||
|
tags: ["ios", "iosonly", "notranslation"],
|
||||||
|
staticVar: false,
|
||||||
|
inputFilename: "myInputFilename",
|
||||||
|
extensionName: "GenStrings",
|
||||||
|
extensionSuffix: "strings")
|
||||||
|
|
||||||
|
// Expect
|
||||||
|
let expect = """
|
||||||
|
// Generated by ResgenSwift.Strings.Stringium \(ResgenSwiftVersion)
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
fileprivate let kStringsFileName = "myInputFilename"
|
||||||
|
|
||||||
|
extension GenStrings {
|
||||||
|
|
||||||
|
enum KeyStrings: String {
|
||||||
|
case s1_def_one = "s1_def_one"
|
||||||
|
case s1_def_two = "s1_def_two"
|
||||||
|
case s2_def_one = "s2_def_one"
|
||||||
|
case s2_def_two = "s2_def_two"
|
||||||
|
|
||||||
|
var keyPath: KeyPath<GenStrings, String> {
|
||||||
|
switch self {
|
||||||
|
case .s1_def_one: return \\GenStrings.s1_def_one
|
||||||
|
case .s1_def_two: return \\GenStrings.s1_def_two
|
||||||
|
case .s2_def_one: return \\GenStrings.s2_def_one
|
||||||
|
case .s2_def_two: return \\GenStrings.s2_def_two
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - section_one
|
||||||
|
|
||||||
|
/// Translation in fr :
|
||||||
|
/// Section Un - Definition Un
|
||||||
|
/// This is a comment
|
||||||
|
var s1_def_one: String {
|
||||||
|
NSLocalizedString("s1_def_one", tableName: kStringsFileName, bundle: Bundle.main, value: "Section Un - Definition Un", comment: "This is a comment")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Translation in fr :
|
||||||
|
/// Section Un - Definition Deux
|
||||||
|
/// This is a comment
|
||||||
|
var s1_def_two: String {
|
||||||
|
NSLocalizedString("s1_def_two", tableName: kStringsFileName, bundle: Bundle.main, value: "Section Un - Definition Deux", comment: "This is a comment")
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - section_two
|
||||||
|
|
||||||
|
/// Translation in fr :
|
||||||
|
/// Section Deux - Definition Un
|
||||||
|
/// This is a comment
|
||||||
|
var s2_def_one: String {
|
||||||
|
NSLocalizedString("s2_def_one", tableName: kStringsFileName, bundle: Bundle.main, value: "Section Deux - Definition Un", comment: "This is a comment")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Translation in fr :
|
||||||
|
/// Section Deux - Definition Deux
|
||||||
|
/// This is a comment
|
||||||
|
var s2_def_two: String {
|
||||||
|
NSLocalizedString("s2_def_two", tableName: kStringsFileName, bundle: Bundle.main, value: "Section Deux - Definition Deux", comment: "This is a comment")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
if extensionContent != expect {
|
||||||
|
print(prettyFirstDifferenceBetweenStrings(s1: extensionContent, s2: expect))
|
||||||
|
}
|
||||||
|
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Extension Content Static
|
||||||
func testGeneratedExtensionContentWithStaticVar() {
|
func testGeneratedExtensionContentWithStaticVar() {
|
||||||
// Given
|
// Given
|
||||||
let sectionOne = Section(name: "section_one")
|
let sectionOne = Section(name: "section_one")
|
||||||
@ -291,5 +484,109 @@ final class StringsFileGeneratorTests: XCTestCase {
|
|||||||
}
|
}
|
||||||
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testGeneratedExtensionContentWithStaticVarWithComment() {
|
||||||
|
// Given
|
||||||
|
let sectionOne = Section(name: "section_one")
|
||||||
|
sectionOne.definitions = [
|
||||||
|
getDefinition(name: "s1_def_one",
|
||||||
|
translations: ["fr": "Section Un - Definition Un",
|
||||||
|
"en": "Section One - Definition One"],
|
||||||
|
tags: ["ios","iosonly"],
|
||||||
|
comment: "This is a comment"),
|
||||||
|
getDefinition(name: "s1_def_two",
|
||||||
|
translations: ["fr": "Section Un - Definition Deux",
|
||||||
|
"en": "Section One - Definition Two"],
|
||||||
|
tags: ["ios","iosonly"],
|
||||||
|
comment: "This is a comment")
|
||||||
|
]
|
||||||
|
|
||||||
|
let sectionTwo = Section(name: "section_two")
|
||||||
|
sectionTwo.definitions = [
|
||||||
|
getDefinition(name: "s2_def_one",
|
||||||
|
translations: ["fr": "Section Deux - Definition Un",
|
||||||
|
"en": "Section Two - Definition One"],
|
||||||
|
tags: ["ios","iosonly"],
|
||||||
|
comment: "This is a comment"),
|
||||||
|
getDefinition(name: "s2_def_two",
|
||||||
|
translations: ["fr": "Section Deux - Definition Deux"],
|
||||||
|
tags: ["notranslation"],
|
||||||
|
comment: "This is a comment")
|
||||||
|
]
|
||||||
|
|
||||||
|
// When
|
||||||
|
let extensionContent = StringsFileGenerator.getExtensionContent(sections: [sectionOne, sectionTwo],
|
||||||
|
defaultLang: "fr",
|
||||||
|
tags: ["ios", "iosonly", "notranslation"],
|
||||||
|
staticVar: true,
|
||||||
|
inputFilename: "myInputFilename",
|
||||||
|
extensionName: "GenStrings",
|
||||||
|
extensionSuffix: "strings")
|
||||||
|
|
||||||
|
// Expect
|
||||||
|
let expect = """
|
||||||
|
// Generated by ResgenSwift.Strings.Stringium \(ResgenSwiftVersion)
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
fileprivate let kStringsFileName = "myInputFilename"
|
||||||
|
|
||||||
|
extension GenStrings {
|
||||||
|
|
||||||
|
enum KeyStrings: String {
|
||||||
|
case s1_def_one = "s1_def_one"
|
||||||
|
case s1_def_two = "s1_def_two"
|
||||||
|
case s2_def_one = "s2_def_one"
|
||||||
|
case s2_def_two = "s2_def_two"
|
||||||
|
|
||||||
|
var keyPath: KeyPath<GenStrings, String> {
|
||||||
|
switch self {
|
||||||
|
case .s1_def_one: return \\GenStrings.s1_def_one
|
||||||
|
case .s1_def_two: return \\GenStrings.s1_def_two
|
||||||
|
case .s2_def_one: return \\GenStrings.s2_def_one
|
||||||
|
case .s2_def_two: return \\GenStrings.s2_def_two
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - section_one
|
||||||
|
|
||||||
|
/// Translation in fr :
|
||||||
|
/// Section Un - Definition Un
|
||||||
|
/// This is a comment
|
||||||
|
static var s1_def_one: String {
|
||||||
|
NSLocalizedString("s1_def_one", tableName: kStringsFileName, bundle: Bundle.main, value: "Section Un - Definition Un", comment: "This is a comment")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Translation in fr :
|
||||||
|
/// Section Un - Definition Deux
|
||||||
|
/// This is a comment
|
||||||
|
static var s1_def_two: String {
|
||||||
|
NSLocalizedString("s1_def_two", tableName: kStringsFileName, bundle: Bundle.main, value: "Section Un - Definition Deux", comment: "This is a comment")
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - section_two
|
||||||
|
|
||||||
|
/// Translation in fr :
|
||||||
|
/// Section Deux - Definition Un
|
||||||
|
/// This is a comment
|
||||||
|
static var s2_def_one: String {
|
||||||
|
NSLocalizedString("s2_def_one", tableName: kStringsFileName, bundle: Bundle.main, value: "Section Deux - Definition Un", comment: "This is a comment")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Translation in fr :
|
||||||
|
/// Section Deux - Definition Deux
|
||||||
|
/// This is a comment
|
||||||
|
static var s2_def_two: String {
|
||||||
|
NSLocalizedString("s2_def_two", tableName: kStringsFileName, bundle: Bundle.main, value: "Section Deux - Definition Deux", comment: "This is a comment")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
if extensionContent != expect {
|
||||||
|
print(prettyFirstDifferenceBetweenStrings(s1: extensionContent, s2: expect))
|
||||||
|
}
|
||||||
|
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user
On va simplifier et éviter la duplcation de la property. Mets toujours le commentaire :
et dans la property tu peux toujours mettre
, comment: "\(comment ?? "")"