Skip to content

Commit

Permalink
SwiftGen#489 - Fixed Swiftlint false-positive for Obj-C compatible St…
Browse files Browse the repository at this point in the history
…rings
  • Loading branch information
lukaskukacka committed Sep 28, 2018
1 parent 68cb890 commit cc6f4ad
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ internal final class XCTLoc: NSObject {
// MARK: - Implementation Details

extension XCTLoc {
private static func tr(_ table: String, _ key: String) -> String {
return NSLocalizedString(key, tableName: table, bundle: Bundle(for: BundleToken.self), comment: "")
}

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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ internal final class L10n: NSObject {
// MARK: - Implementation Details

extension L10n {
private static func tr(_ table: String, _ key: String) -> String {
return NSLocalizedString(key, tableName: table, bundle: Bundle(for: BundleToken.self), comment: "")
}

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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ public final class L10n: NSObject {
// MARK: - Implementation Details

extension L10n {
private static func tr(_ table: String, _ key: String) -> String {
return NSLocalizedString(key, tableName: table, bundle: Bundle(for: BundleToken.self), comment: "")
}

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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Foundation
@objcMembers
internal final class L10n: NSObject {
@objcMembers @objc(L10nLocalizable)
internal final class Localizable: NSObject {
internal final class Localizable: NSObject { // swiftlint:disable:this attributes
/// Some alert body there
internal static let alertMessage = L10n.tr("Localizable", "alert_message")
/// Title of the alert
Expand Down Expand Up @@ -45,7 +45,7 @@ internal final class L10n: NSObject {
internal static let settingsUserProfileSectionHEADERTITLE = L10n.tr("Localizable", "settings.user_profile_section.HEADER_TITLE")
}
@objcMembers @objc(L10nLocMultiline)
internal final class LocMultiline: NSObject {
internal final class LocMultiline: NSObject { // swiftlint:disable:this attributes
/// multi\nline
internal static let multiline = L10n.tr("LocMultiline", "MULTILINE")
/// test
Expand All @@ -63,6 +63,10 @@ internal final class L10n: NSObject {
// MARK: - Implementation Details

extension L10n {
private static func tr(_ table: String, _ key: String) -> String {
return NSLocalizedString(key, tableName: table, bundle: Bundle(for: BundleToken.self), comment: "")
}

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)
Expand Down
4 changes: 2 additions & 2 deletions templates/strings/flat-swift4.stencil
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ import Foundation
{% set typeName %}{{table.name|swiftIdentifier:"pretty"|escapeReservedKeywords}}{% endset %}
{% if param.objcCompatible %}
@objcMembers @objc({{rootTypeName}}{{typeName}})
{{accessModifier}} final class {{typeName}}: NSObject {
{{accessModifier}} final class {{typeName}}: NSObject { // swiftlint:disable:this attributes
{% else %}
{{accessModifier}} enum {{table.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} {
{{accessModifier}} enum {{typeName}} {
{% endif %}
{% filter indent:2 %}{% call recursiveBlock table.name table.levels %}{% endfilter %}
}
Expand Down

0 comments on commit cc6f4ad

Please sign in to comment.