Bugzilla – Bug 2136
GetInfo: localization creates invalid JSON
Last modified: 2019-07-23 07:55:02 UTC
If Audacity's language settings are for a language that uses a comma as the decimal separator, json.loads() fails because decimal values have commas, which JSON thinks are value separators. When running GetInfo: command in Nyquist, we get the correct output regardless of the locale. For example, run the following code in the Nyquist Prompt: ;version 4 (print (aud-do "GetInfo: Type=Tracks Format=JSON")) Example output: ("[ \n { "name":"Piste audio", "focused":1, "selected":1, "kind":"wave", "start":0, "end":27.9257, "pan":0, "gain":1, "channels":1, "solo":0, "mute":0, "VZoomMin":-1, "VZoomMax":1 } ]" . T) Note that "end" has a correct value of 27.9257. Run the same from the "Extra menu > Scripting II > GetInfo:" with language set to Français, and the output is: [ { "name":"Piste audio", "focused":1, "selected":1, "kind":"wave", "start":0, "end":27,9257, "pan":0, "gain":1, "channels":1, "solo":0, "mute":0, "VZoomMin":-1, "VZoomMax":1 } ] Note that "end" has an ilegal value of 27,9257.
Fix committed at 13ca42638d43b4ec36f76843555374e66c4c7601
(In reply to Steve Daulton from comment #1) > Fix committed at 13ca42638d43b4ec36f76843555374e66c4c7601 As initially posted on audacity-quality: I'm not sure if your fix is correct. It contains the line: std::locale nolocale(""); but the argument of an empty string will create a native locale: https://stackoverflow.com/questions/46364608/creating-an-stdlocale-with-an-empty-string I think it should be nolocale("C"). In CommandMessageTarget::AddItem, the double and the string are output using the same locale. I'm not familiar with the function, but obviously if the string isn't necessarily english then nolocale shouldn't be used for the string.
(In reply to David Bailes from comment #2) David wrote: > I think it should be nolocale("C"). I agree. Committed at 7485d88bcdcd
Testing on W10 with audacity-2.3.3-alpha-273-baf4648621892ee3936acd242463abd9a81e3129 This now looks to be fixed with a period now as the decimal separator for the end time. I also tested on 2.3.2 to see that back then the decimal separator was indeed a comma - so the change is noted.
Ideally, this fix should be tested on a system where the system language uses a comma as the decimal separator. It should be quite easy to test by anyone able to operate their computer in an appropriate language. The fix is good if Scripting commands still return decimal numbers with a dot as the decimal separator when the system language uses a comma.
Testing on macOS 10.14.5 Mojave with alpha 2.3.3 jc002 of 30Jun19 As with Windows: This now looks to be fixed with a period now as the decimal separator for the end time.
(In reply to Steve Daulton from comment #5) >Ideally, this fix should be tested on a system where the system language >uses a comma as the decimal separator. So ideally then we need to find a Fench tester ...
(In reply to Peter Sampson from comment #7) > (In reply to Steve Daulton from comment #5) > >Ideally, this fix should be tested on a system where the system language > >uses a comma as the decimal separator. > > So ideally then we need to find a Fench tester ... Or you could install a french language back, and then temporarily set it as your display language. See, for example: https://support.microsoft.com/en-gb/help/4496404/windows-10-manage-the-input-and-display-language
(In reply to David Bailes from comment #8) > Or you could install a french language pack Provided that you can read French well enough to find the setting again to change it back. It is not sufficient to only change the decimal separator in Windows "Region" settings, as doing so prevents Audacity from working correctly (bug 2147).
(In reply to Steve Daulton from comment #9) > (In reply to David Bailes from comment #8) > > Or you could install a french language pack > > Provided that you can read French well enough to find the setting again to > change it back. I can't see this being a problem. In Settings, both the main categories and their categories have associated icons, so getting back to the language category should be straight forward. Then you just change the top drop down list box to whatever its other setting is. You can even pin the language category to the start menu if you want to. > It is not sufficient to only change the decimal separator in Windows > "Region" settings, as doing so prevents Audacity from working correctly (bug > 2147).