How to make a Json in french and a json in english like a string resource.

Hi

I use a json data resource for english and one for french

In french

["Calme", "Très légère brise","Légère brise","Petite brise","Jolie brise","Bonne brise","Vent frais","Grand frais","Coup de vent","Fort coup de vent","Tempête","Violente tempête","Ouragan"]

and in english

["Calm", "Light air","Ligth breeze","Gentle breeze","Moderate breeze","Fresh breeze","Stronge breeze","Moderate gale","Fresh gale","Moderate gale","Severe gale","Whole gale","Moderate gale","Violent storm","Hurricane force"]

Each json is in default and in french directory

But when I cant use french or english when I change language.

It's in french even when I select english language.

Is it a bug and no option to use differents json ?

   <jsonData id="ArrayBeaufort" filename="Beaufort.json" />

Thanks

  • I can speculate that no one thought about JSON and maybe not even drawables. I can understand why properties, settings or fit contributors are not supposed to be translated. IMHO for those things the compiler should give an error, but JSON, drawables could be added to be recognized per language (though it might need firmware support as well ?)

  • I personally think it's a deliberate decision, not an oversight (although those two things are not necessarily 100% mutually exclusive), based on the following documentation:

    https://developer.garmin.com/connect-iq/core-topics/resources/#strings

    To me, the unstated implication is that localization (language) qualifiers (for resource folder names) are only for strings.

    Ofc:

    1) there's no reason the resource compiler shouldn't emit a warning or error if a dev tries to put non-string resources inside in resource folder with localization qualifiers

    2) Garmin could change this behaviour in the future to allow all resource types to be localized (it might run the slight chance of "breaking" existing apps, although if there's any apps which have *different* versions of the same resource for different localization qualifiers, one could suggest those apps are already "broken", as in probably not working as intended.)

    I can speculate that no one thought about JSON

    That's a possibility, as JSON resources didn't even exist in the earliest versions of CIQ

    maybe not even drawables

    Depends on whether anyone thought it would make sense to "localize" a drawable. (It could def make sense especially if a drawable contains text as an image.)

  • I also think that the original idea was that only the text resource should be translated, we agree on that.

    Except that if it were to work that way, it would have to take the JSON data from the default resources/ folder, but it would take it from the language folder regardless of the language choice. So it does pull the JSON "from the language", just in a wrong way. So either don't read from the language folder only the strings or if you do read, handle the language folders correctly. This is why I wrote that it is illogical and working wrong.

    But the best way is just simple read any resource and overwrite them in a simple order rule - like the string does.

  • Right. It reminds me the bug in Garmin Express when you see the settings in a random language

  • Except that if it were to work that way, it would have to take the JSON data from the default resources/ folder, but it would take it from the language folder regardless of the language choice. So it does pull the JSON "from the language", just in a wrong way. So either don't read from the language folder only the strings or if you do read, handle the language folders correctly. This is why I wrote that it is illogical and working wrong.

    Yeah, I agree. 

    - non-language resources should always come from the default folder (and not language-specific folders), or a resource folder specified in monkey.jungle via resourcePath

    - there should be an error or warning if you put non-language resources in a language folder

    I bet the current behaviour is a side effect of the fact that you can manually specify additional resource folders via resourcePath. (I forget what happens if you specify multiple versions of the same resource in different folders though, outside of language-specific folders. Does it just take version from the last resource in the configured list of resources folders?)