Localizing HarmoniQ

As a developer and a polyglot, one might assume that I would naturally embrace localizing HarmoniQ. Despite designing the application with localization in mind, I somehow found myself dreading the actual task of localizing it. My limited understanding of how localization worked in Xcode and on devices only amplified my apprehension. The journey turned out to be both challenging and rewarding, leading to significant improvements that convinced me to release it as the official version 1.0.

Screenshot of HarmoniQ app showing language selection and localization features

Starting with String Catalogs

Based on Xcode and Apple’s current localization documentation, I chose to use String Catalogs — which seems to be the standard and most up-to-date approach — to manage localization in HarmoniQ. By default, the OS determines the best match between the languages supported by the app and the device’s language preferences. The existing framework is simple and loads strings in the device’s preferred language, and changing the device’s language settings restarts all applications. However, there were some things I immediately didn’t like:

  1. Unhelpful Default Strings: When a key isn’t found, the default behavior is to return the key string itself. Displaying “welcome.message” isn’t very user-friendly.
  2. Lack of User Control: While language detection is seamless, users aren’t able to select a language independently of their device settings — a feature I’ve observed in many applications.

A Localization Framework

After careful consideration, I decided to build my own framework to simplify my approach to localization. This initiative also prompted me to review most files in my project, adjusting accessibilityLabels and text implementations. Having started this project with no prior experience in Swift or mobile app development, revisiting my earlier code helped me elevate large swathes of my application to meet my high standards.

The core of the framework is to provide JIT (just in time) localized values of localized data whenever localized properties are requested. The framework also includes a LanguageManager that manages both device and user preferences to determine the current language and retrieve strings from the appropriate bundle. For example, the LanguageManager uses the device language preferences but also allows the user to select any language supported by the app.

Xcode Hurdles

While developing HarmoniQ, I’ve been repeatedly astounded by odd behaviors I’ve observed in Xcode. For example, there is a recurring issue where the header displays a different file from the one that is actually open for editing. I’ve adapted my workflow to minimize disruption from these issues, including often simply using VS Code in lieu of Xcode. Still, I admit that I’m rather befuddled. Some of these oversights, such as the one I just described, seem to have significant or even critical implications for an IDE.

As the String Catalog JSON grew larger, editing values in Xcode became increasingly problematic. To circumvent this, I wrote a simple parser to extract all keys and supported languages into separate CSV files. With creative prompt engineering in the comment field for strings, LLM tools do the bulk of the translation work very quickly, and all it takes is a short Python script to reassemble the String Catalog JSON for Xcode.

Excellence in Localization and Accessibility

One of my goals is to have HarmoniQ featured by Apple in the App Store. Beyond the intrinsic value of supporting multiple languages as a global citizen, Apple places high importance on localization and accessibility in apps they feature. I am committed to excelling in both areas. The latest version of HarmoniQ, now live in the App Store, supports UK English, Spanish, and French — reflecting the locales from which the app has been downloaded so far.

Looking ahead, I am exploring Dynamic Type, a feature that allows users to adjust the default text size on their devices for better readability. Thanks to the localization framework I’ve developed, translating HarmoniQ into other languages has become incredibly easy. From now on, expect to see new languages and improved translations released frequently alongside regular updates. I also have some exciting surprises in store, which I’ve shared with several users over the past month. Keep an eye out for the latest updates, and enjoy the improved language support firsthand!

Screenshot of HarmoniQ app showing accessibility and language options