From 67c06393f00b8cd79cdd74491148313e13007e55 Mon Sep 17 00:00:00 2001 From: Liam Nichols Date: Thu, 16 May 2024 22:52:08 +0100 Subject: [PATCH] Expose properties from generated structs for custom use (#71) * Remove locale property from generated struct * Expose properties and helpers of generated struct type --- Sources/StringGenerator/StringGenerator.swift | 76 +++---------------- .../testGenerate.FormatSpecifiers.swift | 33 ++------ .../testGenerate.Localizable.swift | 24 ++---- .../testGenerate.Multiline.swift | 21 ++--- .../testGenerate.Positional.swift | 23 ++---- .../GenerateTests/testGenerate.Simple.swift | 21 ++--- .../testGenerate.Substitution.swift | 21 ++--- .../testGenerate.Variations.swift | 22 ++---- ...teWithPackageAccessLevel.Localizable.swift | 24 ++---- ...ateWithPublicAccessLevel.Localizable.swift | 24 ++---- 10 files changed, 84 insertions(+), 205 deletions(-) diff --git a/Sources/StringGenerator/StringGenerator.swift b/Sources/StringGenerator/StringGenerator.swift index 160f0dd..be9d294 100644 --- a/Sources/StringGenerator/StringGenerator.swift +++ b/Sources/StringGenerator/StringGenerator.swift @@ -70,9 +70,6 @@ public struct StringGenerator { ) { // BundleDescription EnumDeclSyntax( - modifiers: [ - DeclModifierSyntax(name: .keyword(.fileprivate)) - ], name: .type(.BundleDescription), memberBlockBuilder: { EnumCaseDeclSyntax { @@ -104,9 +101,6 @@ public struct StringGenerator { // Argument EnumDeclSyntax( - modifiers: [ - DeclModifierSyntax(name: .keyword(.fileprivate)) - ], name: .type(.Argument), memberBlockBuilder: { // case object(String) @@ -170,9 +164,6 @@ public struct StringGenerator { // Properties VariableDeclSyntax( - modifiers: [ - DeclModifierSyntax(name: .keyword(.fileprivate)), - ], .let, name: PatternSyntax(IdentifierPatternSyntax(identifier: "key")), type: TypeAnnotationSyntax( @@ -180,9 +171,6 @@ public struct StringGenerator { ) ) VariableDeclSyntax( - modifiers: [ - DeclModifierSyntax(name: .keyword(.fileprivate)), - ], .let, name: PatternSyntax(IdentifierPatternSyntax(identifier: "arguments")), type: TypeAnnotationSyntax( @@ -190,9 +178,6 @@ public struct StringGenerator { ) ) VariableDeclSyntax( - modifiers: [ - DeclModifierSyntax(name: .keyword(.fileprivate)), - ], .let, name: PatternSyntax(IdentifierPatternSyntax(identifier: "table")), type: TypeAnnotationSyntax( @@ -200,17 +185,6 @@ public struct StringGenerator { ) ) VariableDeclSyntax( - modifiers: [ - DeclModifierSyntax(name: .keyword(.fileprivate)), - ], - .let, - name: PatternSyntax(IdentifierPatternSyntax(identifier: "locale")), - type: TypeAnnotationSyntax(type: .identifier(.Locale)) - ) - VariableDeclSyntax( - modifiers: [ - DeclModifierSyntax(name: .keyword(.fileprivate)), - ], .let, name: PatternSyntax(IdentifierPatternSyntax(identifier: "bundle")), type: TypeAnnotationSyntax(type: .identifier(.BundleDescription)) @@ -235,10 +209,6 @@ public struct StringGenerator { firstName: "table", type: OptionalTypeSyntax(wrappedType: .identifier(.String)) ) - FunctionParameterSyntax( - firstName: "locale", - type: .identifier(.Locale) - ) FunctionParameterSyntax( firstName: "bundle", type: .identifier(.BundleDescription) @@ -271,14 +241,6 @@ public struct StringGenerator { operator: AssignmentExprSyntax(), rightOperand: DeclReferenceExprSyntax(baseName: "table") ) - InfixOperatorExprSyntax( - leftOperand: MemberAccessExprSyntax( - base: DeclReferenceExprSyntax(baseName: .keyword(.`self`)), - name: "locale" - ), - operator: AssignmentExprSyntax(), - rightOperand: DeclReferenceExprSyntax(baseName: "locale") - ) InfixOperatorExprSyntax( leftOperand: MemberAccessExprSyntax( base: DeclReferenceExprSyntax(baseName: .keyword(.`self`)), @@ -595,7 +557,6 @@ public struct StringGenerator { func generateStringsTableArgumentValueExtension() -> ExtensionDeclSyntax { ExtensionDeclSyntax( - accessLevel: .private, extendedType: MemberTypeSyntax( baseType: localTableMemberType, name: .type(.Argument) @@ -707,7 +668,6 @@ public struct StringGenerator { func generateBundleExtension() -> ExtensionDeclSyntax { ExtensionDeclSyntax( - accessLevel: .private, extendedType: .identifier(.Bundle) ) { FunctionDeclSyntax( @@ -1060,14 +1020,14 @@ public struct StringGenerator { name: .keyword(.`init`) ) ) { + // localizable.key, LabeledExprSyntax( - label: nil, expression: MemberAccessExprSyntax( base: DeclReferenceExprSyntax(baseName: variableToken), declName: DeclReferenceExprSyntax(baseName: "key") ) ) - + // defaultValue: localizable.defaultValue, LabeledExprSyntax( label: "defaultValue", expression: MemberAccessExprSyntax( @@ -1075,7 +1035,7 @@ public struct StringGenerator { declName: DeclReferenceExprSyntax(baseName: "defaultValue") ) ) - + // table: localizable.table, LabeledExprSyntax( label: "table", expression: MemberAccessExprSyntax( @@ -1083,15 +1043,7 @@ public struct StringGenerator { declName: DeclReferenceExprSyntax(baseName: "table") ) ) - - LabeledExprSyntax( - label: "locale", - expression: MemberAccessExprSyntax( - base: DeclReferenceExprSyntax(baseName: variableToken), - declName: DeclReferenceExprSyntax(baseName: "locale") - ) - ) - + // bundle: .from(description: localizable.bundle) LabeledExprSyntax( label: "bundle", expression: FunctionCallExprSyntax( @@ -1319,22 +1271,18 @@ extension Resource { baseName: .keyword(.Self) ) ) { - LabeledExprSyntax(label: "key", expression: keyExpr) - - LabeledExprSyntax(label: "arguments", expression: argumentsExpr) - LabeledExprSyntax( - label: "table", - expression: StringLiteralExprSyntax(content: table) + label: "key", + expression: keyExpr ) - LabeledExprSyntax( - label: "locale", - expression: MemberAccessExprSyntax( - name: .identifier("current") - ) + label: "arguments", + expression: argumentsExpr + ) + LabeledExprSyntax( + label: "table", + expression: StringLiteralExprSyntax(content: table) ) - LabeledExprSyntax( label: "bundle", expression: MemberAccessExprSyntax( diff --git a/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerate.FormatSpecifiers.swift b/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerate.FormatSpecifiers.swift index fac5aa3..085181f 100644 --- a/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerate.FormatSpecifiers.swift +++ b/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerate.FormatSpecifiers.swift @@ -9,13 +9,13 @@ extension String { /// value // "Test %" /// ``` internal struct FormatSpecifiers { - fileprivate enum BundleDescription { + enum BundleDescription { case main case atURL(URL) case forClass(AnyClass) } - fileprivate enum Argument { + enum Argument { case object(String) case int(Int) case uint(UInt) @@ -23,23 +23,20 @@ extension String { case float(Float) } - fileprivate let key: StaticString - fileprivate let arguments: [Argument] - fileprivate let table: String? - fileprivate let locale: Locale - fileprivate let bundle: BundleDescription + let key: StaticString + let arguments: [Argument] + let table: String? + let bundle: BundleDescription fileprivate init( key: StaticString, arguments: [Argument], table: String?, - locale: Locale, bundle: BundleDescription ) { self.key = key self.arguments = arguments self.table = table - self.locale = locale self.bundle = bundle } } @@ -70,7 +67,6 @@ extension String.FormatSpecifiers { .object(arg1) ], table: "FormatSpecifiers", - locale: .current, bundle: .current ) } @@ -89,7 +85,6 @@ extension String.FormatSpecifiers { .int(arg1) ], table: "FormatSpecifiers", - locale: .current, bundle: .current ) } @@ -108,7 +103,6 @@ extension String.FormatSpecifiers { .int(arg1) ], table: "FormatSpecifiers", - locale: .current, bundle: .current ) } @@ -127,7 +121,6 @@ extension String.FormatSpecifiers { .double(arg1) ], table: "FormatSpecifiers", - locale: .current, bundle: .current ) } @@ -146,7 +139,6 @@ extension String.FormatSpecifiers { .double(arg1) ], table: "FormatSpecifiers", - locale: .current, bundle: .current ) } @@ -165,7 +157,6 @@ extension String.FormatSpecifiers { .int(arg1) ], table: "FormatSpecifiers", - locale: .current, bundle: .current ) } @@ -184,7 +175,6 @@ extension String.FormatSpecifiers { .uint(arg1) ], table: "FormatSpecifiers", - locale: .current, bundle: .current ) } @@ -201,7 +191,6 @@ extension String.FormatSpecifiers { key: "percentage", arguments: [], table: "FormatSpecifiers", - locale: .current, bundle: .current ) } @@ -218,7 +207,6 @@ extension String.FormatSpecifiers { key: "percentage_escaped", arguments: [], table: "FormatSpecifiers", - locale: .current, bundle: .current ) } @@ -235,7 +223,6 @@ extension String.FormatSpecifiers { key: "percentage_escaped_space_o", arguments: [], table: "FormatSpecifiers", - locale: .current, bundle: .current ) } @@ -252,7 +239,6 @@ extension String.FormatSpecifiers { key: "percentage_space_o", arguments: [], table: "FormatSpecifiers", - locale: .current, bundle: .current ) } @@ -271,7 +257,6 @@ extension String.FormatSpecifiers { .uint(arg1) ], table: "FormatSpecifiers", - locale: .current, bundle: .current ) } @@ -290,7 +275,6 @@ extension String.FormatSpecifiers { .uint(arg1) ], table: "FormatSpecifiers", - locale: .current, bundle: .current ) } @@ -319,7 +303,7 @@ private extension String.FormatSpecifiers { } } -private extension String.FormatSpecifiers.Argument { +extension String.FormatSpecifiers.Argument { var value: CVarArg { switch self { case .int(let value): @@ -351,7 +335,7 @@ private extension String.FormatSpecifiers.BundleDescription { } } -private extension Bundle { +extension Bundle { static func from(description: String.FormatSpecifiers.BundleDescription) -> Bundle? { switch description { case .main: @@ -542,7 +526,6 @@ extension LocalizedStringResource { formatSpecifiers.key, defaultValue: formatSpecifiers.defaultValue, table: formatSpecifiers.table, - locale: formatSpecifiers.locale, bundle: .from(description: formatSpecifiers.bundle) ) } diff --git a/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerate.Localizable.swift b/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerate.Localizable.swift index f397291..65a72ae 100644 --- a/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerate.Localizable.swift +++ b/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerate.Localizable.swift @@ -9,13 +9,13 @@ extension String { /// value // "Default Value" /// ``` internal struct Localizable { - fileprivate enum BundleDescription { + enum BundleDescription { case main case atURL(URL) case forClass(AnyClass) } - fileprivate enum Argument { + enum Argument { case object(String) case int(Int) case uint(UInt) @@ -23,23 +23,20 @@ extension String { case float(Float) } - fileprivate let key: StaticString - fileprivate let arguments: [Argument] - fileprivate let table: String? - fileprivate let locale: Locale - fileprivate let bundle: BundleDescription + let key: StaticString + let arguments: [Argument] + let table: String? + let bundle: BundleDescription fileprivate init( key: StaticString, arguments: [Argument], table: String?, - locale: Locale, bundle: BundleDescription ) { self.key = key self.arguments = arguments self.table = table - self.locale = locale self.bundle = bundle } } @@ -68,7 +65,6 @@ extension String.Localizable { key: "Key", arguments: [], table: "Localizable", - locale: .current, bundle: .current ) } @@ -83,7 +79,6 @@ extension String.Localizable { key: "myDeviceVariant", arguments: [], table: "Localizable", - locale: .current, bundle: .current ) } @@ -100,7 +95,6 @@ extension String.Localizable { .int(arg1) ], table: "Localizable", - locale: .current, bundle: .current ) } @@ -118,7 +112,6 @@ extension String.Localizable { .int(arg2) ], table: "Localizable", - locale: .current, bundle: .current ) } @@ -147,7 +140,7 @@ private extension String.Localizable { } } -private extension String.Localizable.Argument { +extension String.Localizable.Argument { var value: CVarArg { switch self { case .int(let value): @@ -179,7 +172,7 @@ private extension String.Localizable.BundleDescription { } } -private extension Bundle { +extension Bundle { static func from(description: String.Localizable.BundleDescription) -> Bundle? { switch description { case .main: @@ -265,7 +258,6 @@ extension LocalizedStringResource { localizable.key, defaultValue: localizable.defaultValue, table: localizable.table, - locale: localizable.locale, bundle: .from(description: localizable.bundle) ) } diff --git a/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerate.Multiline.swift b/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerate.Multiline.swift index b1e85dc..3904daa 100644 --- a/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerate.Multiline.swift +++ b/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerate.Multiline.swift @@ -9,13 +9,13 @@ extension String { /// value // "Options:\n- One\n- Two\n- Three" /// ``` internal struct Multiline { - fileprivate enum BundleDescription { + enum BundleDescription { case main case atURL(URL) case forClass(AnyClass) } - fileprivate enum Argument { + enum Argument { case object(String) case int(Int) case uint(UInt) @@ -23,23 +23,20 @@ extension String { case float(Float) } - fileprivate let key: StaticString - fileprivate let arguments: [Argument] - fileprivate let table: String? - fileprivate let locale: Locale - fileprivate let bundle: BundleDescription + let key: StaticString + let arguments: [Argument] + let table: String? + let bundle: BundleDescription fileprivate init( key: StaticString, arguments: [Argument], table: String?, - locale: Locale, bundle: BundleDescription ) { self.key = key self.arguments = arguments self.table = table - self.locale = locale self.bundle = bundle } } @@ -73,7 +70,6 @@ extension String.Multiline { key: "multiline", arguments: [], table: "Multiline", - locale: .current, bundle: .current ) } @@ -102,7 +98,7 @@ private extension String.Multiline { } } -private extension String.Multiline.Argument { +extension String.Multiline.Argument { var value: CVarArg { switch self { case .int(let value): @@ -134,7 +130,7 @@ private extension String.Multiline.BundleDescription { } } -private extension Bundle { +extension Bundle { static func from(description: String.Multiline.BundleDescription) -> Bundle? { switch description { case .main: @@ -198,7 +194,6 @@ extension LocalizedStringResource { multiline.key, defaultValue: multiline.defaultValue, table: multiline.table, - locale: multiline.locale, bundle: .from(description: multiline.bundle) ) } diff --git a/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerate.Positional.swift b/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerate.Positional.swift index 71cf27f..4cf3af1 100644 --- a/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerate.Positional.swift +++ b/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerate.Positional.swift @@ -9,13 +9,13 @@ extension String { /// value // "bar" /// ``` internal struct Positional { - fileprivate enum BundleDescription { + enum BundleDescription { case main case atURL(URL) case forClass(AnyClass) } - fileprivate enum Argument { + enum Argument { case object(String) case int(Int) case uint(UInt) @@ -23,23 +23,20 @@ extension String { case float(Float) } - fileprivate let key: StaticString - fileprivate let arguments: [Argument] - fileprivate let table: String? - fileprivate let locale: Locale - fileprivate let bundle: BundleDescription + let key: StaticString + let arguments: [Argument] + let table: String? + let bundle: BundleDescription fileprivate init( key: StaticString, arguments: [Argument], table: String?, - locale: Locale, bundle: BundleDescription ) { self.key = key self.arguments = arguments self.table = table - self.locale = locale self.bundle = bundle } } @@ -71,7 +68,6 @@ extension String.Positional { .object(arg2) ], table: "Positional", - locale: .current, bundle: .current ) } @@ -90,7 +86,6 @@ extension String.Positional { .int(arg1) ], table: "Positional", - locale: .current, bundle: .current ) } @@ -109,7 +104,6 @@ extension String.Positional { .object(arg1) ], table: "Positional", - locale: .current, bundle: .current ) } @@ -138,7 +132,7 @@ private extension String.Positional { } } -private extension String.Positional.Argument { +extension String.Positional.Argument { var value: CVarArg { switch self { case .int(let value): @@ -170,7 +164,7 @@ private extension String.Positional.BundleDescription { } } -private extension Bundle { +extension Bundle { static func from(description: String.Positional.BundleDescription) -> Bundle? { switch description { case .main: @@ -251,7 +245,6 @@ extension LocalizedStringResource { positional.key, defaultValue: positional.defaultValue, table: positional.table, - locale: positional.locale, bundle: .from(description: positional.bundle) ) } diff --git a/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerate.Simple.swift b/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerate.Simple.swift index 723bafe..69a4514 100644 --- a/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerate.Simple.swift +++ b/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerate.Simple.swift @@ -9,13 +9,13 @@ extension String { /// value // "My Value" /// ``` internal struct Simple { - fileprivate enum BundleDescription { + enum BundleDescription { case main case atURL(URL) case forClass(AnyClass) } - fileprivate enum Argument { + enum Argument { case object(String) case int(Int) case uint(UInt) @@ -23,23 +23,20 @@ extension String { case float(Float) } - fileprivate let key: StaticString - fileprivate let arguments: [Argument] - fileprivate let table: String? - fileprivate let locale: Locale - fileprivate let bundle: BundleDescription + let key: StaticString + let arguments: [Argument] + let table: String? + let bundle: BundleDescription fileprivate init( key: StaticString, arguments: [Argument], table: String?, - locale: Locale, bundle: BundleDescription ) { self.key = key self.arguments = arguments self.table = table - self.locale = locale self.bundle = bundle } } @@ -68,7 +65,6 @@ extension String.Simple { key: "SimpleKey", arguments: [], table: "Simple", - locale: .current, bundle: .current ) } @@ -97,7 +93,7 @@ private extension String.Simple { } } -private extension String.Simple.Argument { +extension String.Simple.Argument { var value: CVarArg { switch self { case .int(let value): @@ -129,7 +125,7 @@ private extension String.Simple.BundleDescription { } } -private extension Bundle { +extension Bundle { static func from(description: String.Simple.BundleDescription) -> Bundle? { switch description { case .main: @@ -188,7 +184,6 @@ extension LocalizedStringResource { simple.key, defaultValue: simple.defaultValue, table: simple.table, - locale: simple.locale, bundle: .from(description: simple.bundle) ) } diff --git a/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerate.Substitution.swift b/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerate.Substitution.swift index d56fb79..f3fc808 100644 --- a/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerate.Substitution.swift +++ b/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerate.Substitution.swift @@ -9,13 +9,13 @@ extension String { /// value // "bar" /// ``` internal struct Substitution { - fileprivate enum BundleDescription { + enum BundleDescription { case main case atURL(URL) case forClass(AnyClass) } - fileprivate enum Argument { + enum Argument { case object(String) case int(Int) case uint(UInt) @@ -23,23 +23,20 @@ extension String { case float(Float) } - fileprivate let key: StaticString - fileprivate let arguments: [Argument] - fileprivate let table: String? - fileprivate let locale: Locale - fileprivate let bundle: BundleDescription + let key: StaticString + let arguments: [Argument] + let table: String? + let bundle: BundleDescription fileprivate init( key: StaticString, arguments: [Argument], table: String?, - locale: Locale, bundle: BundleDescription ) { self.key = key self.arguments = arguments self.table = table - self.locale = locale self.bundle = bundle } } @@ -72,7 +69,6 @@ extension String.Substitution { .int(arg3) ], table: "Substitution", - locale: .current, bundle: .current ) } @@ -101,7 +97,7 @@ private extension String.Substitution { } } -private extension String.Substitution.Argument { +extension String.Substitution.Argument { var value: CVarArg { switch self { case .int(let value): @@ -133,7 +129,7 @@ private extension String.Substitution.BundleDescription { } } -private extension Bundle { +extension Bundle { static func from(description: String.Substitution.BundleDescription) -> Bundle? { switch description { case .main: @@ -192,7 +188,6 @@ extension LocalizedStringResource { substitution.key, defaultValue: substitution.defaultValue, table: substitution.table, - locale: substitution.locale, bundle: .from(description: substitution.bundle) ) } diff --git a/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerate.Variations.swift b/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerate.Variations.swift index 12a318f..390443e 100644 --- a/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerate.Variations.swift +++ b/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerate.Variations.swift @@ -9,13 +9,13 @@ extension String { /// value // "Tap to open" /// ``` internal struct Variations { - fileprivate enum BundleDescription { + enum BundleDescription { case main case atURL(URL) case forClass(AnyClass) } - fileprivate enum Argument { + enum Argument { case object(String) case int(Int) case uint(UInt) @@ -23,23 +23,20 @@ extension String { case float(Float) } - fileprivate let key: StaticString - fileprivate let arguments: [Argument] - fileprivate let table: String? - fileprivate let locale: Locale - fileprivate let bundle: BundleDescription + let key: StaticString + let arguments: [Argument] + let table: String? + let bundle: BundleDescription fileprivate init( key: StaticString, arguments: [Argument], table: String?, - locale: Locale, bundle: BundleDescription ) { self.key = key self.arguments = arguments self.table = table - self.locale = locale self.bundle = bundle } } @@ -68,7 +65,6 @@ extension String.Variations { key: "String.Device", arguments: [], table: "Variations", - locale: .current, bundle: .current ) } @@ -85,7 +81,6 @@ extension String.Variations { .int(arg1) ], table: "Variations", - locale: .current, bundle: .current ) } @@ -114,7 +109,7 @@ private extension String.Variations { } } -private extension String.Variations.Argument { +extension String.Variations.Argument { var value: CVarArg { switch self { case .int(let value): @@ -146,7 +141,7 @@ private extension String.Variations.BundleDescription { } } -private extension Bundle { +extension Bundle { static func from(description: String.Variations.BundleDescription) -> Bundle? { switch description { case .main: @@ -214,7 +209,6 @@ extension LocalizedStringResource { variations.key, defaultValue: variations.defaultValue, table: variations.table, - locale: variations.locale, bundle: .from(description: variations.bundle) ) } diff --git a/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerateWithPackageAccessLevel.Localizable.swift b/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerateWithPackageAccessLevel.Localizable.swift index c2498e8..66cf42a 100644 --- a/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerateWithPackageAccessLevel.Localizable.swift +++ b/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerateWithPackageAccessLevel.Localizable.swift @@ -9,13 +9,13 @@ extension String { /// value // "Default Value" /// ``` package struct Localizable { - fileprivate enum BundleDescription { + enum BundleDescription { case main case atURL(URL) case forClass(AnyClass) } - fileprivate enum Argument { + enum Argument { case object(String) case int(Int) case uint(UInt) @@ -23,23 +23,20 @@ extension String { case float(Float) } - fileprivate let key: StaticString - fileprivate let arguments: [Argument] - fileprivate let table: String? - fileprivate let locale: Locale - fileprivate let bundle: BundleDescription + let key: StaticString + let arguments: [Argument] + let table: String? + let bundle: BundleDescription fileprivate init( key: StaticString, arguments: [Argument], table: String?, - locale: Locale, bundle: BundleDescription ) { self.key = key self.arguments = arguments self.table = table - self.locale = locale self.bundle = bundle } } @@ -68,7 +65,6 @@ extension String.Localizable { key: "Key", arguments: [], table: "Localizable", - locale: .current, bundle: .current ) } @@ -83,7 +79,6 @@ extension String.Localizable { key: "myDeviceVariant", arguments: [], table: "Localizable", - locale: .current, bundle: .current ) } @@ -100,7 +95,6 @@ extension String.Localizable { .int(arg1) ], table: "Localizable", - locale: .current, bundle: .current ) } @@ -118,7 +112,6 @@ extension String.Localizable { .int(arg2) ], table: "Localizable", - locale: .current, bundle: .current ) } @@ -147,7 +140,7 @@ private extension String.Localizable { } } -private extension String.Localizable.Argument { +extension String.Localizable.Argument { var value: CVarArg { switch self { case .int(let value): @@ -179,7 +172,7 @@ private extension String.Localizable.BundleDescription { } } -private extension Bundle { +extension Bundle { static func from(description: String.Localizable.BundleDescription) -> Bundle? { switch description { case .main: @@ -265,7 +258,6 @@ extension LocalizedStringResource { localizable.key, defaultValue: localizable.defaultValue, table: localizable.table, - locale: localizable.locale, bundle: .from(description: localizable.bundle) ) } diff --git a/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerateWithPublicAccessLevel.Localizable.swift b/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerateWithPublicAccessLevel.Localizable.swift index 7251048..dec6e12 100644 --- a/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerateWithPublicAccessLevel.Localizable.swift +++ b/Tests/XCStringsToolTests/__Snapshots__/GenerateTests/testGenerateWithPublicAccessLevel.Localizable.swift @@ -9,13 +9,13 @@ extension String { /// value // "Default Value" /// ``` public struct Localizable { - fileprivate enum BundleDescription { + enum BundleDescription { case main case atURL(URL) case forClass(AnyClass) } - fileprivate enum Argument { + enum Argument { case object(String) case int(Int) case uint(UInt) @@ -23,23 +23,20 @@ extension String { case float(Float) } - fileprivate let key: StaticString - fileprivate let arguments: [Argument] - fileprivate let table: String? - fileprivate let locale: Locale - fileprivate let bundle: BundleDescription + let key: StaticString + let arguments: [Argument] + let table: String? + let bundle: BundleDescription fileprivate init( key: StaticString, arguments: [Argument], table: String?, - locale: Locale, bundle: BundleDescription ) { self.key = key self.arguments = arguments self.table = table - self.locale = locale self.bundle = bundle } } @@ -68,7 +65,6 @@ extension String.Localizable { key: "Key", arguments: [], table: "Localizable", - locale: .current, bundle: .current ) } @@ -83,7 +79,6 @@ extension String.Localizable { key: "myDeviceVariant", arguments: [], table: "Localizable", - locale: .current, bundle: .current ) } @@ -100,7 +95,6 @@ extension String.Localizable { .int(arg1) ], table: "Localizable", - locale: .current, bundle: .current ) } @@ -118,7 +112,6 @@ extension String.Localizable { .int(arg2) ], table: "Localizable", - locale: .current, bundle: .current ) } @@ -147,7 +140,7 @@ private extension String.Localizable { } } -private extension String.Localizable.Argument { +extension String.Localizable.Argument { var value: CVarArg { switch self { case .int(let value): @@ -179,7 +172,7 @@ private extension String.Localizable.BundleDescription { } } -private extension Bundle { +extension Bundle { static func from(description: String.Localizable.BundleDescription) -> Bundle? { switch description { case .main: @@ -265,7 +258,6 @@ extension LocalizedStringResource { localizable.key, defaultValue: localizable.defaultValue, table: localizable.table, - locale: localizable.locale, bundle: .from(description: localizable.bundle) ) }