Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Toybox.Complications;
- import Toybox.Lang;
- import Toybox.System;
- // add ComplicationSubscriber permission to manifest
- function getComplicationLongLabel(type as Complications.Type, defaultText as String) as String {
- var text = defaultText;
- if (Complications has :getComplication) {
- var id = new Complications.Id(type);
- var complication = Complications.getComplication(id);
- if (complication != null) {
- text = complication.longLabel;
- }
- }
- return text;
- }
- function testLabels() {
- var bodyBatteryLabel = getComplicationLongLabel(Complications.COMPLICATION_TYPE_BODY_BATTERY, "Body Battery");
- var heartRateLabel = getComplicationLongLabel(Complications.COMPLICATION_TYPE_HEART_RATE, "Heart Rate");
- // english: "Heart Rate", french: "Fréquence cardiaque" (the "é" is just a bug in the console output)
- System.println(heartRateLabel);
- // enlish: "Body Battery", french: "Body Battery"
- // (Garmin doesn't seem to translate body battery anywhere
- // e.g. https://www.garmin.com/fr-CA/garmin-technology/health-science/body-battery/)
- // "SUIVI DE L'ÉNERGIE DU CORPS BODY BATTERY™"
- System.println(bodyBatteryLabel);
- }
Advertisement
Add Comment
Please, Sign In to add comment