INCOMPLETE DRAFT. I’ve done this process, just haven’t written it up yet.
How to tell Xcode to localize strings in native dialogs of a Qt app.
This is also discussed in many posts on Stack Overflow and in the Qt documentation.
This is about using the Xcode GUI. If you are using the command line to invoke Xcode tools, or using Qt Creator to bundle your Mac app, the details may not apply.
Checklist of product components to localize
- user-facing strings in your Qt code (in the GUI of your app that you wrote.)
- user-facing strings in the Qt library (in GUI that the Qt library implements)
- strings in platform native dialogs (in the GUI of your app that the platform provides.)
- your help files (typically html)
- your marketing materials (uploaded to stores)
This blog is most specific about 3.
PyQt and Qt’s user facing strings
The user-facing strings 1 and 2 are embedded resources of your app. While you could package them as Mac resources, it is more general to package them as Qt and PyQt resources. This doesn’t discuss how to do that, except:
- you use the tools pylupdate, Qt Linguist, lrelease, pyrcc
- the translation resources end up as a foo_rc.py file in your project
- PyQt provides the mechanism for finding those resources as needed
The difference between native dialog strings and strings in your Qt code
Qt provides mechanisms to localize strings in the code that it knows about. But your app, via Qt, can invoke native dialogs, such as the Print dialog. Qt doesn’t know about the strings in that dialog.
(Qt does know about conventions for naming standard buttons and menu items on certain platforms. These are in the MAC_APP??? context in Qt .ts files, etc.)
How to tell Xcode to localize native dialogs
- Add a localizable string to your project
- Add a language to your project
- Arrange that .lproj files are in your project and bundled
Add a localizable string
In the Navigator pane, click on the + icon at the lower right (or press RMB on your project and choose “Add New