How to set localized texts for Label programmatically?

952 views Asked by At

is there a way to set the text of a Label (Toybox.WatchUi.Text) with a localized string programmatically at runtime? I know how to set a localized string for a label from within the user interface XML files and was wondering if this is also possible from within a Monkey C file, e.g. label.setText("@Strings.localization_key")?

1

There are 1 answers

1
cmdaltent On BEST ANSWER

I discovered the Github Account of Garmin where they also provide some example code of Applications and I found the solution in one of the projects.

It's simply Rez.Strings.<string_id> with the ID and the respective translation in one of the string resource files.

However, it does not seem to work to concatenate the localized String with another string and put the concatenation as text in the label. Obviously, the internal String-ID is then displayed rather than the actual string. This behavior occurred for me with the Connect IQ SDK 1.2.5.