Skip to content

Commit

Permalink
Merge pull request #1027 from oxen-io/dev
Browse files Browse the repository at this point in the history
Release 2.8.0
  • Loading branch information
mpretty-cyro authored Sep 24, 2024
2 parents 83ec937 + a1c3d53 commit b994d52
Show file tree
Hide file tree
Showing 231 changed files with 392,552 additions and 52,179 deletions.
29 changes: 28 additions & 1 deletion Scripts/EmojiGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,33 @@ enum RemoteModel {
case symbols = "Symbols"
case flags = "Flags"
case components = "Component"

var localizedKey: String = {
switch self {
case .smileys:
return "Smileys"
case .people:
return "People"
case .smileysAndPeople:
return "Smileys"
case .animals:
return "Animals"
case .food:
return "Food"
case .activities:
return "Activities"
case .travel:
return "Travel"
case .objects:
return "Objects"
case .symbols:
return "Symbols"
case .flags:
return "Flags"
case .components:
return "Component"
}
}()
}

static func fetchEmojiData() throws -> Data {
Expand Down Expand Up @@ -551,7 +578,7 @@ extension EmojiGenerator {
for category in outputCategories {
fileHandle.writeLine("case .\(category):")
fileHandle.indent {
let stringKey = "EMOJI_CATEGORY_\("\(category)".uppercased())_NAME"
let stringKey = "emojiCategory\(category.localizedKey)"
let stringComment = "The name for the emoji category '\(category.rawValue)'"

fileHandle.writeLine("return NSLocalizedString(\"\(stringKey)\", comment: \"\(stringComment)\")")
Expand Down
262 changes: 155 additions & 107 deletions Scripts/LintLocalizableStrings.swift

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions Scripts/ProcessIP2CountryData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,19 +126,19 @@ class Processor {
guard keepRunning else { return }

/// Filter down the files to find the country name files
let localisedCountryNameFileUrls: [URL] = fileUrls.filter { fileUrl in
let localizedCountryNameFileUrls: [URL] = fileUrls.filter { fileUrl in
((try? fileUrl.resourceValues(forKeys: [.isDirectoryKey]))?.isDirectory == false) &&
fileUrl.lastPathComponent.lowercased().hasPrefix(countryNameFilePrefix.lowercased()) &&
fileUrl.lastPathComponent.lowercased().hasSuffix(".csv")
}

guard keepRunning else { return }

let languageCodes: String = localisedCountryNameFileUrls
let languageCodes: String = localizedCountryNameFileUrls
.map { url in String(url.lastPathComponent.dropFirst(countryNameFilePrefix.count).dropLast(".csv".count)) }
.sorted()
.joined(separator: ", ")
print("Found \(localisedCountryNameFileUrls.count) language files ✅ (\(languageCodes))")
print("Found \(localizedCountryNameFileUrls.count) language files ✅ (\(languageCodes))")

guard keepRunning else { return }

Expand Down Expand Up @@ -184,16 +184,16 @@ class Processor {

/// Structure of the data should be `geoname_id,locale_code,continent_code,continent_name,country_iso_code,country_name,is_in_european_union`
let languagesPrefix: String = "Processing languages: "
localisedCountryNameFileUrls.enumerated().forEach { fileIndex, fileUrl in
localizedCountryNameFileUrls.enumerated().forEach { fileIndex, fileUrl in
guard keepRunning else { return }
guard
let localisedData: Data = try? Data(contentsOf: fileUrl),
let localisedDataString: String = String(data: localisedData, encoding: .utf8)
else { fatalError("Could not load localised country name file") }
let localizedData: Data = try? Data(contentsOf: fileUrl),
let localizedDataString: String = String(data: localizedData, encoding: .utf8)
else { fatalError("Could not load localized country name file") }

/// Header line plus at least one line of content
let lines: [String] = localisedDataString.components(separatedBy: "\n")
guard lines.count > 1 else { fatalError("Localised country file had no content") }
let lines: [String] = localizedDataString.components(separatedBy: "\n")
guard lines.count > 1 else { fatalError("localized country file had no content") }

lines[1...].enumerated().forEach { index, line in
let values: [String] = parseCsvLine(line.trimmingCharacters(in: .whitespacesAndNewlines))
Expand All @@ -203,7 +203,7 @@ class Processor {
cache.countryLocationsGeonameId.append(values[0])
cache.countryLocationsCountryName.append(values[5].trimmingCharacters(in: CharacterSet(charactersIn: "\"")))

let progress = (Double((fileIndex * lines.count) + index) / Double(localisedCountryNameFileUrls.count * lines.count))
let progress = (Double((fileIndex * lines.count) + index) / Double(localizedCountryNameFileUrls.count * lines.count))
printProgressBar(prefix: languagesPrefix, progress: progress, total: (terminalWidth - 10))
}
}
Expand Down
Loading

0 comments on commit b994d52

Please sign in to comment.