Skip to content

Commit cda0835

Browse files
RISCfutureclaude
andcommitted
Use plain string literals on Linux instead of String(localized:)
String(localized:) is not available on Linux Foundation. Use plain string literals in the #else blocks. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent acccbe5 commit cda0835

File tree

1 file changed

+26
-32
lines changed

1 file changed

+26
-32
lines changed

Sources/SwiftNASR/Error.swift

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,13 @@ extension Error: LocalizedError {
123123
#if canImport(Darwin)
124124
return String(localized: "Couldn’t load distribution.", comment: "error description")
125125
#else
126-
return String(localized: "Couldn’t load distribution.")
126+
return "Couldn’t load distribution."
127127
#endif
128128
case .badResponse, .noData, .downloadFailed:
129129
#if canImport(Darwin)
130130
return String(localized: "Couldn’t download distribution.", comment: "error description")
131131
#else
132-
return String(localized: "Couldn’t download distribution.")
132+
return "Couldn’t download distribution."
133133
#endif
134134
case .unknownARTCC, .unknownARTCCFrequency, .unknownFieldId,
135135
.unknownFrequencyFieldId, .invalidFrequency, .unknownFSS,
@@ -138,13 +138,13 @@ extension Error: LocalizedError {
138138
#if canImport(Darwin)
139139
return String(localized: "Couldn’t parse distribution data.", comment: "error description")
140140
#else
141-
return String(localized: "Couldn’t parse distribution data.")
141+
return "Couldn’t parse distribution data."
142142
#endif
143143
case .notYetLoaded:
144144
#if canImport(Darwin)
145145
return String(localized: "This NASR has not been loaded yet.", comment: "error description")
146146
#else
147-
return String(localized: "This NASR has not been loaded yet.")
147+
return "This NASR has not been loaded yet."
148148
#endif
149149
}
150150
}
@@ -158,7 +158,7 @@ extension Error: LocalizedError {
158158
comment: "failure reason"
159159
)
160160
#else
161-
return String(localized: "Called .load() on a null distribution.")
161+
return "Called .load() on a null distribution."
162162
#endif
163163
case .badResponse(let response):
164164
#if canImport(Darwin)
@@ -167,13 +167,13 @@ extension Error: LocalizedError {
167167
comment: "failure reason"
168168
)
169169
#else
170-
return String(localized: "Bad response: \(response.description).")
170+
return "Bad response: \(response.description)."
171171
#endif
172172
case .downloadFailed(let reason):
173173
#if canImport(Darwin)
174174
return String(localized: "Download failed: \(reason)", comment: "failure reason")
175175
#else
176-
return String(localized: "Download failed: \(reason)")
176+
return "Download failed: \(reason)"
177177
#endif
178178
case .noSuchFilePrefix(let prefix):
179179
#if canImport(Darwin)
@@ -182,13 +182,13 @@ extension Error: LocalizedError {
182182
comment: "failure reason"
183183
)
184184
#else
185-
return String(localized: "Couldn’t find file in archive with prefix ‘\(prefix).’")
185+
return "Couldn’t find file in archive with prefix ‘\(prefix).’"
186186
#endif
187187
case .noData:
188188
#if canImport(Darwin)
189189
return String(localized: "No data was downloaded.", comment: "failure reason")
190190
#else
191-
return String(localized: "No data was downloaded.")
191+
return "No data was downloaded."
192192
#endif
193193
case .unknownARTCC(let ID):
194194
#if canImport(Darwin)
@@ -197,7 +197,7 @@ extension Error: LocalizedError {
197197
comment: "failure reason"
198198
)
199199
#else
200-
return String(localized: "Referenced undefined ARTCC record with ID ‘\(ID)’.")
200+
return "Referenced undefined ARTCC record with ID ‘\(ID)’."
201201
#endif
202202
case let .unknownARTCCFrequency(frequency, ARTCC):
203203
#if canImport(Darwin)
@@ -206,7 +206,7 @@ extension Error: LocalizedError {
206206
comment: "failure reason"
207207
)
208208
#else
209-
return String(localized: "Referenced undefined frequency ‘\(frequency)’ for ARTCC \(ARTCC.code).")
209+
return "Referenced undefined frequency ‘\(frequency)’ for ARTCC \(ARTCC.code)."
210210
#endif
211211
case let .unknownFieldId(fieldId, ARTCC):
212212
#if canImport(Darwin)
@@ -215,7 +215,7 @@ extension Error: LocalizedError {
215215
comment: "failure reason"
216216
)
217217
#else
218-
return String(localized: "Unknown field ID ‘\(fieldId)’ at ‘\(ARTCC.code) \(ARTCC.locationName)’.")
218+
return "Unknown field ID ‘\(fieldId)’ at ‘\(ARTCC.code) \(ARTCC.locationName)’."
219219
#endif
220220
case let .unknownFrequencyFieldId(fieldId, frequency, ARTCC):
221221
#if canImport(Darwin)
@@ -225,16 +225,13 @@ extension Error: LocalizedError {
225225
comment: "failure reason"
226226
)
227227
#else
228-
return String(
229-
localized:
230-
"Unknown field ID '\(fieldId)' for \(frequency.frequencyKHz) kHz at '\(ARTCC.code) \(ARTCC.locationName)'."
231-
)
228+
return "Unknown field ID '\(fieldId)' for \(frequency.frequencyKHz) kHz at '\(ARTCC.code) \(ARTCC.locationName)'."
232229
#endif
233230
case .invalidFrequency(let string):
234231
#if canImport(Darwin)
235232
return String(localized: "Invalid frequency ‘\(string)’.", comment: "failure reason")
236233
#else
237-
return String(localized: "Invalid frequency ‘\(string)’.")
234+
return "Invalid frequency ‘\(string)’."
238235
#endif
239236
case .unknownFSS(let ID):
240237
#if canImport(Darwin)
@@ -243,7 +240,7 @@ extension Error: LocalizedError {
243240
comment: "failure reason"
244241
)
245242
#else
246-
return String(localized: "Continuation record references unknown FSS ‘\(ID)’.")
243+
return "Continuation record references unknown FSS ‘\(ID)’."
247244
#endif
248245
case .notYetLoaded:
249246
#if canImport(Darwin)
@@ -252,7 +249,7 @@ extension Error: LocalizedError {
252249
comment: "failure reason"
253250
)
254251
#else
255-
return String(localized: "Attempted to access NASR data before .load() was called.")
252+
return "Attempted to access NASR data before .load() was called."
256253
#endif
257254
case .noSuchFile(let path):
258255
#if canImport(Darwin)
@@ -261,13 +258,13 @@ extension Error: LocalizedError {
261258
comment: "failure reason"
262259
)
263260
#else
264-
return String(localized: "No such file in distribution: \(path).")
261+
return "No such file in distribution: \(path)."
265262
#endif
266263
case .invalidRunwaySurface(let string):
267264
#if canImport(Darwin)
268265
return String(localized: "Unknown runway surface ‘\(string)’.", comment: "failure reason")
269266
#else
270-
return String(localized: "Unknown runway surface ‘\(string)’.")
267+
return "Unknown runway surface ‘\(string)’."
271268
#endif
272269
case .invalidPavementClassification(let string):
273270
#if canImport(Darwin)
@@ -276,25 +273,25 @@ extension Error: LocalizedError {
276273
comment: "failure reason"
277274
)
278275
#else
279-
return String(localized: "Unknown pavement classification ‘\(string)’ for PCN.")
276+
return "Unknown pavement classification ‘\(string)’ for PCN."
280277
#endif
281278
case .invalidVGSI(let string):
282279
#if canImport(Darwin)
283280
return String(localized: "Unknown VGSI identifier ‘\(string)’.", comment: "failure reason")
284281
#else
285-
return String(localized: "Unknown VGSI identifier ‘\(string)’.")
282+
return "Unknown VGSI identifier ‘\(string)’."
286283
#endif
287284
case .unknownNavaid(let string):
288285
#if canImport(Darwin)
289286
return String(localized: "Unknown navaid ‘\(string)’.", comment: "failure reason")
290287
#else
291-
return String(localized: "Unknown navaid ‘\(string)’.")
288+
return "Unknown navaid ‘\(string)’."
292289
#endif
293290
case .invalidAltitudeFormat(let string):
294291
#if canImport(Darwin)
295292
return String(localized: "Invalid altitude format ‘\(string)’.", comment: "failure reason")
296293
#else
297-
return String(localized: "Invalid altitude format ‘\(string)’.")
294+
return "Invalid altitude format ‘\(string)’."
298295
#endif
299296
}
300297
}
@@ -309,10 +306,7 @@ extension Error: LocalizedError {
309306
comment: "recovery suggestion"
310307
)
311308
#else
312-
return String(
313-
localized:
314-
"Do not call .load() on a NullDistribution. Use NullDistribution for distributions that were previously loaded and serialized to disk."
315-
)
309+
return "Do not call .load() on a NullDistribution. Use NullDistribution for distributions that were previously loaded and serialized to disk."
316310
#endif
317311
case .badResponse, .noData, .downloadFailed:
318312
#if canImport(Darwin)
@@ -321,7 +315,7 @@ extension Error: LocalizedError {
321315
comment: "recovery suggestion"
322316
)
323317
#else
324-
return String(localized: "Verify that the URL to the distribution is correct and accessible.")
318+
return "Verify that the URL to the distribution is correct and accessible."
325319
#endif
326320
case .unknownARTCC, .unknownARTCCFrequency, .unknownFieldId,
327321
.unknownFrequencyFieldId, .invalidFrequency, .unknownFSS,
@@ -334,7 +328,7 @@ extension Error: LocalizedError {
334328
comment: "recovery suggestion"
335329
)
336330
#else
337-
return String(localized: "The NASR FADDS format may have changed, requiring an update to SwiftNASR.")
331+
return "The NASR FADDS format may have changed, requiring an update to SwiftNASR."
338332
#endif
339333
case .notYetLoaded:
340334
#if canImport(Darwin)
@@ -343,7 +337,7 @@ extension Error: LocalizedError {
343337
comment: "recovery suggestion"
344338
)
345339
#else
346-
return String(localized: "Call .load() before accessing NASR data.")
340+
return "Call .load() before accessing NASR data."
347341
#endif
348342
}
349343
}

0 commit comments

Comments
 (0)