I have written this masterpiece with Chatgpt var weights = ["English"] + Array(Set(Locale.availableIdentifiers.compactMap{ Locale(identifier: })).sorted() as? [String] ?? [] And yes I didn't even know this could be done in a single line.