Audacity Bug Summary
••• Introduction •••
••• Keywords •••
    Audacity 3.0.3 development began 19th April 2021

Audacity Bugzilla



Bug 2136 - GetInfo: localization creates invalid JSON
GetInfo: localization creates invalid JSON
Status: RESOLVED FIXED
Product: Audacity
Classification: Unclassified
Component: Other
2.3.3
Per OS All
: P4 RepeatableAll
Assigned To: Default Assignee for New Bugs
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2019-06-20 11:54 UTC by Steve Daulton
Modified: 2019-07-23 07:55 UTC (History)
7 users (show)

See Also:
Steps To Reproduce:
1) Create a project with an audio track that ends at a fraction second position. 2) Set the interface language to French (any language that uses a comma as the decimal separator). 3) "Extra menu > Scripting II > Get Info > Tracks" Note that the end time has a comma as a decimal separator.
Release Note:
First Git SHA:
Group: ---
Workaround:
Closed: 2019-07-23 00:00:00
petersampsonaudacity: Test‑OK‑Win+
petersampsonaudacity: Test‑OK‑Mac+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Steve Daulton 2019-06-20 11:54:28 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.
Comment 1 Steve Daulton 2019-06-20 18:21:44 UTC
Fix committed at 13ca42638d43b4ec36f76843555374e66c4c7601
Comment 2 David Bailes 2019-06-21 13:06:56 UTC
(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.
Comment 3 Steve Daulton 2019-06-24 15:36:16 UTC
(In reply to David Bailes from comment #2)
David wrote:
> I think it should be nolocale("C").

I agree. Committed at 7485d88bcdcd
Comment 4 Peter Sampson 2019-06-25 05:11:39 UTC
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.
Comment 5 Steve Daulton 2019-06-25 06:04:49 UTC
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.
Comment 6 Peter Sampson 2019-06-30 11:52:41 UTC
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.
Comment 7 Peter Sampson 2019-06-30 11:53:43 UTC
(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 ...
Comment 8 David Bailes 2019-07-02 05:41:00 UTC
(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
Comment 9 Steve Daulton 2019-07-02 06:23:09 UTC
(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).
Comment 10 David Bailes 2019-07-02 07:59:50 UTC
(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).