Skip to content

Commit

Permalink
Standardize locale format
Browse files Browse the repository at this point in the history
  • Loading branch information
SlayterDev committed Jul 19, 2024
1 parent 6db80af commit 87ef435
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
27 changes: 27 additions & 0 deletions Sources/Common/Extensions/LocaleExtensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//

Check failure on line 1 in Sources/Common/Extensions/LocaleExtensions.swift

View workflow job for this annotation

GitHub Actions / Run SwiftLint

Header comments should be consistent with project patterns (file_header)
// LocaleExtensions.swift
// DuckDuckGo
//
// Copyright © 2024 DuckDuckGo. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import Foundation

public extension Locale {
var localeIdentifierAsJsonFormat: String {
let baseIdentifier = self.identifier.components(separatedBy: "@").first ?? self.identifier
return baseIdentifier.replacingOccurrences(of: "_", with: "-")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public struct BrokenSiteReport {
let vpnOn: Bool
let jsPerformance: [Double]?
let userRefreshCount: Int
let localeIdentifier: String
let locale: Locale
#if os(iOS)
let siteType: SiteType
let atb: String
Expand Down Expand Up @@ -125,7 +125,7 @@ public struct BrokenSiteReport {
vpnOn: Bool,
jsPerformance: [Double]?,
userRefreshCount: Int,
localeIdentifier: String = Locale.current.identifier
locale: Locale = Locale.current
) {
self.siteUrl = siteUrl
self.category = category
Expand All @@ -147,7 +147,7 @@ public struct BrokenSiteReport {
self.vpnOn = vpnOn
self.jsPerformance = jsPerformance
self.userRefreshCount = userRefreshCount
self.localeIdentifier = localeIdentifier
self.locale = locale
}
#endif

Expand Down Expand Up @@ -177,7 +177,7 @@ public struct BrokenSiteReport {
jsPerformance: [Double]?,
userRefreshCount: Int,
variant: String,
localeIdentifier: String = Locale.current.identifier
locale: Locale = Locale.current
) {
self.siteUrl = siteUrl
self.category = category
Expand All @@ -203,7 +203,7 @@ public struct BrokenSiteReport {
self.jsPerformance = jsPerformance
self.userRefreshCount = userRefreshCount
self.variant = variant
self.localeIdentifier = localeIdentifier
self.locale = locale
}
#endif

Expand All @@ -226,7 +226,7 @@ public struct BrokenSiteReport {
"openerContext": openerContext?.rawValue ?? "",
"vpnOn": vpnOn.description,
"userRefreshCount": String(userRefreshCount),
"locale": localeIdentifier
"locale": locale.localeIdentifierAsJsonFormat
]

if mode == .regular {
Expand Down

0 comments on commit 87ef435

Please sign in to comment.