Hardcoded Translation

hi everyone,

as mentionned in the title I would like to hardcode tranlsation, not for the settings but on the screen,

let's say I have this function:

function Title(w){
    var T=["STEPS","FLOOR"];
    return T[w];
}

in order to save resources, I would to have this function by language, (of course the array will be much longer)

I had a look here: https://developer.garmin.com/connect-iq/reference-guides/jungle-reference/#junglereferenceguide (like for settings)

but the lang qualifer only seems to work for resources not sources.

Do you think it is possibel?

  • As long as you don't have to support CIQ 1 devices, you could put your hardcoded string arrays in JSON resources. That way all of your strings would consume a single resource ID.

    Of course, the huge downside is the massive hit to your free memory when you load the resources. Then again, if your strings were purely in code, you'd have double the penalty (once for the data, and once for the code that initializes the data.)

  • Do you think it is possibel?

    If your question is whether you can have excludeAnnotations on a per language basis in your jungle, I don't think that's possible (at build time you can't know which language your user is going to select on his device)

  • I think he's saying he wants to have multiple sets of strings (one for each language) and he doesn't want each string to consume a resource ID (since you can only have 255 IIRC)

    So my approach of placing each resource array in a JSON resource (qualified by language) would work, but of course it would consume a lot more memory than having each string as a normal individual string resource, since you have to load all of the strings at once. I think it could save memory over the scheme of hardcoding a list (or multiple lists) of strings in the code itself, though. It might cause a higher memory peak though, depending on how the deserialization process works.

  • Maybe it would help if you could share why would you want to do this.

  • hi, so stupid I am... here is my answer: . 

    at build time you can't know which language your user is going to select on his device

  • Ah, I thought that you have a better use case :) 

    For example I could imagine you want to support languages not supported by the watch, and let the user switch between languages in the settings. (Settings would be in English but the texts on the device could be translated)

  • hi, for that it would be very easy to do. ;)