Swift & Xcode Tips & Solutions


See all

Articles: Easily Create a Swift Array of Days of the Week/Month, Localized as Well

Posted by: david on Wednesday/January 13/2016 - 03:22 PM
Swift Xcode IOS
I wanted to create an array in Swift that contained the names of every day of the week, e.g. Sunday, Monday, Tuesday, etc. Obviously, I can do something like the following:

let daysOfWeek = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", Saturday"]
But the problem was that I also wanted those names to be localized into other languages without having to manually create one for each. I knew that iOS Objective C/Swift supported automatically translating date names using ​NSDateFormatter, but I wondered if there was a way to achieve what I want without passing and converting actual, specific dates....


Articles: Xcode Swift Localization Problem Solved

Posted by: david on Friday/November 20/2015 - 04:46 PM
Swift Xcode IOS


​So I was working on Xcode 7.1.1 (using Swift 2.1) on my new app, and decided to localize it. I'm relatively new to Swift and iOS development, but so far. so good. I wanted to share a couple of "gotchas" I ran into while trying to internationalize my app. My biggest first stumbling block was not naming the localization strings file correctly. It has to be named:

Localizable.strings

When I created my strings file, I had named it "localization.strings", and was wondering why in the world the NSLocalizedString() was not converting the key....