I’m developing the UI for an embedded (RPi) linux-based hardware appliance. I want to create Name Value pairs for each UI Control, Dialog, etc. that’s driven by the end-users language selection. The underlying OS will always be set to Default/English, but the UI will present a setup screen that allows setting for the end-users language choice. I don’t plan on changing any currency, 1000th’s, or other localization of numeric values - merely the text-captions of UI elements.
I’ve started down the road of using the Open event of each control to pull it’s caption value from a centralized module, which seems logical and scalable, but I’m sure this has it’s drawbacks.
Has anyone come up with a clever solution to this seemingly common requirement?
yes… use constants … each constant can have values in any of the rquired languages and will pick the right one at run time
That is driven by the user’s OS language setting, correct? That’s what I don’t want to do (drive it from OS’s localized lang).
The way we approached it in OpenSong (this is not my design; I inherited it) is to have an XML file for each language. The file is structured with a hierarchy that identifies each control or message. The control names correspond to XML elements, so the Open event of a window calls a utility routine that loops through all the controls and sets labels and such based on the selected language.
If I were doing it today and staying with a similar approach, I’d probably have all the languages in the same file as elements beneath the controls. I’ve had to write utilities to identify which strings are missing from the different translations in order to keep them in sync.
These are great tips, and the link to the xojo blog was ideal - exactly what I was looking for!