forked from SwiftGen/SwiftGen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SwiftGen#489 - Added option to generate Objective-C compatible String…
…s Swift code
- Loading branch information
1 parent
07583c7
commit 68cb890
Showing
7 changed files
with
282 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...xtures/Generated/Strings/flat-swift4-context-localizable-objc-compatible-customname.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// swiftlint:disable all | ||
// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen | ||
|
||
import Foundation | ||
|
||
// swiftlint:disable superfluous_disable_command | ||
// swiftlint:disable file_length | ||
|
||
// MARK: - Strings | ||
|
||
// swiftlint:disable function_parameter_count identifier_name line_length type_body_length | ||
@objcMembers | ||
internal final class XCTLoc: NSObject { | ||
/// Some alert body there | ||
internal static let alertMessage = XCTLoc.tr("Localizable", "alert_message") | ||
/// Title of the alert | ||
internal static let alertTitle = XCTLoc.tr("Localizable", "alert_title") | ||
/// These are %3$@'s %1$d %2$@. | ||
internal static func objectOwnership(_ p1: Int, _ p2: String, _ p3: String) -> String { | ||
return XCTLoc.tr("Localizable", "ObjectOwnership", p1, p2, p3) | ||
} | ||
/// Hello, my name is %@ and I'm %d | ||
internal static func `private`(_ p1: String, _ p2: Int) -> String { | ||
return XCTLoc.tr("Localizable", "private", p1, p2) | ||
} | ||
/// You have %d apples | ||
internal static func applesCount(_ p1: Int) -> String { | ||
return XCTLoc.tr("Localizable", "apples.count", p1) | ||
} | ||
/// Those %d bananas belong to %@. | ||
internal static func bananasOwner(_ p1: Int, _ p2: String) -> String { | ||
return XCTLoc.tr("Localizable", "bananas.owner", p1, p2) | ||
} | ||
/// Some Reserved Keyword there | ||
internal static let settingsNavigationBarSelf = XCTLoc.tr("Localizable", "settings.navigation-bar.self") | ||
/// DeepSettings | ||
internal static let settingsNavigationBarTitleDeeperThanWeCanHandleNoReallyThisIsDeep = XCTLoc.tr("Localizable", "settings.navigation-bar.title.deeper.than.we.can.handle.no.really.this.is.deep") | ||
/// Settings | ||
internal static let settingsNavigationBarTitleEvenDeeper = XCTLoc.tr("Localizable", "settings.navigation-bar.title.even.deeper") | ||
/// Here you can change some user profile settings. | ||
internal static let settingsUserProfileSectionFooterText = XCTLoc.tr("Localizable", "settings.user_profile_section.footer_text") | ||
/// User Profile Settings | ||
internal static let settingsUserProfileSectionHEADERTITLE = XCTLoc.tr("Localizable", "settings.user_profile_section.HEADER_TITLE") | ||
} | ||
// swiftlint:enable function_parameter_count identifier_name line_length type_body_length | ||
|
||
// MARK: - Implementation Details | ||
|
||
extension XCTLoc { | ||
private static func tr(_ table: String, _ key: String, _ args: CVarArg...) -> String { | ||
let format = NSLocalizedString(key, tableName: table, bundle: Bundle(for: BundleToken.self), comment: "") | ||
return String(format: format, locale: Locale.current, arguments: args) | ||
} | ||
} | ||
|
||
private final class BundleToken {} |
45 changes: 45 additions & 0 deletions
45
...tures/Generated/Strings/flat-swift4-context-localizable-objc-compatible-no-comments.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// swiftlint:disable all | ||
// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen | ||
|
||
import Foundation | ||
|
||
// swiftlint:disable superfluous_disable_command | ||
// swiftlint:disable file_length | ||
|
||
// MARK: - Strings | ||
|
||
// swiftlint:disable function_parameter_count identifier_name line_length type_body_length | ||
@objcMembers | ||
internal final class L10n: NSObject { | ||
internal static let alertMessage = L10n.tr("Localizable", "alert_message") | ||
internal static let alertTitle = L10n.tr("Localizable", "alert_title") | ||
internal static func objectOwnership(_ p1: Int, _ p2: String, _ p3: String) -> String { | ||
return L10n.tr("Localizable", "ObjectOwnership", p1, p2, p3) | ||
} | ||
internal static func `private`(_ p1: String, _ p2: Int) -> String { | ||
return L10n.tr("Localizable", "private", p1, p2) | ||
} | ||
internal static func applesCount(_ p1: Int) -> String { | ||
return L10n.tr("Localizable", "apples.count", p1) | ||
} | ||
internal static func bananasOwner(_ p1: Int, _ p2: String) -> String { | ||
return L10n.tr("Localizable", "bananas.owner", p1, p2) | ||
} | ||
internal static let settingsNavigationBarSelf = L10n.tr("Localizable", "settings.navigation-bar.self") | ||
internal static let settingsNavigationBarTitleDeeperThanWeCanHandleNoReallyThisIsDeep = L10n.tr("Localizable", "settings.navigation-bar.title.deeper.than.we.can.handle.no.really.this.is.deep") | ||
internal static let settingsNavigationBarTitleEvenDeeper = L10n.tr("Localizable", "settings.navigation-bar.title.even.deeper") | ||
internal static let settingsUserProfileSectionFooterText = L10n.tr("Localizable", "settings.user_profile_section.footer_text") | ||
internal static let settingsUserProfileSectionHEADERTITLE = L10n.tr("Localizable", "settings.user_profile_section.HEADER_TITLE") | ||
} | ||
// swiftlint:enable function_parameter_count identifier_name line_length type_body_length | ||
|
||
// MARK: - Implementation Details | ||
|
||
extension L10n { | ||
private static func tr(_ table: String, _ key: String, _ args: CVarArg...) -> String { | ||
let format = NSLocalizedString(key, tableName: table, bundle: Bundle(for: BundleToken.self), comment: "") | ||
return String(format: format, locale: Locale.current, arguments: args) | ||
} | ||
} | ||
|
||
private final class BundleToken {} |
56 changes: 56 additions & 0 deletions
56
...ures/Generated/Strings/flat-swift4-context-localizable-objc-compatible-publicAccess.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// swiftlint:disable all | ||
// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen | ||
|
||
import Foundation | ||
|
||
// swiftlint:disable superfluous_disable_command | ||
// swiftlint:disable file_length | ||
|
||
// MARK: - Strings | ||
|
||
// swiftlint:disable function_parameter_count identifier_name line_length type_body_length | ||
@objcMembers | ||
public final class L10n: NSObject { | ||
/// Some alert body there | ||
public static let alertMessage = L10n.tr("Localizable", "alert_message") | ||
/// Title of the alert | ||
public static let alertTitle = L10n.tr("Localizable", "alert_title") | ||
/// These are %3$@'s %1$d %2$@. | ||
public static func objectOwnership(_ p1: Int, _ p2: String, _ p3: String) -> String { | ||
return L10n.tr("Localizable", "ObjectOwnership", p1, p2, p3) | ||
} | ||
/// Hello, my name is %@ and I'm %d | ||
public static func `private`(_ p1: String, _ p2: Int) -> String { | ||
return L10n.tr("Localizable", "private", p1, p2) | ||
} | ||
/// You have %d apples | ||
public static func applesCount(_ p1: Int) -> String { | ||
return L10n.tr("Localizable", "apples.count", p1) | ||
} | ||
/// Those %d bananas belong to %@. | ||
public static func bananasOwner(_ p1: Int, _ p2: String) -> String { | ||
return L10n.tr("Localizable", "bananas.owner", p1, p2) | ||
} | ||
/// Some Reserved Keyword there | ||
public static let settingsNavigationBarSelf = L10n.tr("Localizable", "settings.navigation-bar.self") | ||
/// DeepSettings | ||
public static let settingsNavigationBarTitleDeeperThanWeCanHandleNoReallyThisIsDeep = L10n.tr("Localizable", "settings.navigation-bar.title.deeper.than.we.can.handle.no.really.this.is.deep") | ||
/// Settings | ||
public static let settingsNavigationBarTitleEvenDeeper = L10n.tr("Localizable", "settings.navigation-bar.title.even.deeper") | ||
/// Here you can change some user profile settings. | ||
public static let settingsUserProfileSectionFooterText = L10n.tr("Localizable", "settings.user_profile_section.footer_text") | ||
/// User Profile Settings | ||
public static let settingsUserProfileSectionHEADERTITLE = L10n.tr("Localizable", "settings.user_profile_section.HEADER_TITLE") | ||
} | ||
// swiftlint:enable function_parameter_count identifier_name line_length type_body_length | ||
|
||
// MARK: - Implementation Details | ||
|
||
extension L10n { | ||
private static func tr(_ table: String, _ key: String, _ args: CVarArg...) -> String { | ||
let format = NSLocalizedString(key, tableName: table, bundle: Bundle(for: BundleToken.self), comment: "") | ||
return String(format: format, locale: Locale.current, arguments: args) | ||
} | ||
} | ||
|
||
private final class BundleToken {} |
72 changes: 72 additions & 0 deletions
72
Tests/Fixtures/Generated/Strings/flat-swift4-context-multiple-objc-compatible.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// swiftlint:disable all | ||
// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen | ||
|
||
import Foundation | ||
|
||
// swiftlint:disable superfluous_disable_command | ||
// swiftlint:disable file_length | ||
|
||
// MARK: - Strings | ||
|
||
// swiftlint:disable function_parameter_count identifier_name line_length type_body_length | ||
@objcMembers | ||
internal final class L10n: NSObject { | ||
@objcMembers @objc(L10nLocalizable) | ||
internal final class Localizable: NSObject { | ||
/// Some alert body there | ||
internal static let alertMessage = L10n.tr("Localizable", "alert_message") | ||
/// Title of the alert | ||
internal static let alertTitle = L10n.tr("Localizable", "alert_title") | ||
/// These are %3$@'s %1$d %2$@. | ||
internal static func objectOwnership(_ p1: Int, _ p2: String, _ p3: String) -> String { | ||
return L10n.tr("Localizable", "ObjectOwnership", p1, p2, p3) | ||
} | ||
/// Hello, my name is %@ and I'm %d | ||
internal static func `private`(_ p1: String, _ p2: Int) -> String { | ||
return L10n.tr("Localizable", "private", p1, p2) | ||
} | ||
/// You have %d apples | ||
internal static func applesCount(_ p1: Int) -> String { | ||
return L10n.tr("Localizable", "apples.count", p1) | ||
} | ||
/// Those %d bananas belong to %@. | ||
internal static func bananasOwner(_ p1: Int, _ p2: String) -> String { | ||
return L10n.tr("Localizable", "bananas.owner", p1, p2) | ||
} | ||
/// Some Reserved Keyword there | ||
internal static let settingsNavigationBarSelf = L10n.tr("Localizable", "settings.navigation-bar.self") | ||
/// DeepSettings | ||
internal static let settingsNavigationBarTitleDeeperThanWeCanHandleNoReallyThisIsDeep = L10n.tr("Localizable", "settings.navigation-bar.title.deeper.than.we.can.handle.no.really.this.is.deep") | ||
/// Settings | ||
internal static let settingsNavigationBarTitleEvenDeeper = L10n.tr("Localizable", "settings.navigation-bar.title.even.deeper") | ||
/// Here you can change some user profile settings. | ||
internal static let settingsUserProfileSectionFooterText = L10n.tr("Localizable", "settings.user_profile_section.footer_text") | ||
/// User Profile Settings | ||
internal static let settingsUserProfileSectionHEADERTITLE = L10n.tr("Localizable", "settings.user_profile_section.HEADER_TITLE") | ||
} | ||
@objcMembers @objc(L10nLocMultiline) | ||
internal final class LocMultiline: NSObject { | ||
/// multi\nline | ||
internal static let multiline = L10n.tr("LocMultiline", "MULTILINE") | ||
/// test | ||
internal static let multiLineNKey = L10n.tr("LocMultiline", "multiLine\nKey") | ||
/// another\nmulti\n line | ||
internal static let multiline2 = L10n.tr("LocMultiline", "MULTILINE2") | ||
/// single line | ||
internal static let singleline = L10n.tr("LocMultiline", "SINGLELINE") | ||
/// another single line | ||
internal static let singleline2 = L10n.tr("LocMultiline", "SINGLELINE2") | ||
} | ||
} | ||
// swiftlint:enable function_parameter_count identifier_name line_length type_body_length | ||
|
||
// MARK: - Implementation Details | ||
|
||
extension L10n { | ||
private static func tr(_ table: String, _ key: String, _ args: CVarArg...) -> String { | ||
let format = NSLocalizedString(key, tableName: table, bundle: Bundle(for: BundleToken.self), comment: "") | ||
return String(format: format, locale: Locale.current, arguments: args) | ||
} | ||
} | ||
|
||
private final class BundleToken {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters