View Issue Details

IDProjectCategoryView StatusLast Update
0002135FreeCADBugpublic2017-01-16 18:52
ReporterSanguinario_Joe 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
Platform64-bitOSLinux/KubuntuOS Version14.04.2 LTS
Product Version0.15 
Target VersionFixed in Version 
Summary0002135: Units module is not properly considering the QLocale::groupSeparator() character
DescriptionSome stupid languages, like Spanish, are not using the common dot decimal separator, but they have comma. That is well supported in FreeCAD, however some NaN stupid level languages, like Spanish, has a group separator (so called thousands separator), which seems is not well supported by FreeCAD.
Steps To Reproduce>>> q = Units.Quantity('1,2 m')
>>> q
1200 mm
>>> q = Units.Quantity('1.200 mm')
>>> q
1.2 mm
>>> q = Units.Quantity('1.200,0 mm')
Traceback (most recent call last):
  File "<input>", line 1, in <module>
ValueError: syntax error
Additional InformationIt is a problem because QLocale::toString cannot be used.
Tagsdocumentation, locale

Relationships

Activities

wmayer

2015-06-02 15:17

administrator   ~0006181

I strongly disagree. The units parser must NOT get any locale specific strings as input.

The input must always be plain C strings because otherwise you cannot force the same behaviour on all platforms.

As an example consider a Python script. If the units parser supported locales and you build a string from a number in Python (which results into a C string) then the script behaves differently on different systems.

The next big problem is that you always have to extend the units parser to support all kind of special characters for decimal point and separator. There are languages that have other characters than dot or comma for this.

Locale specific strings must only be taken into account for our special Qt widgets that support units which are InputField and QuantitySpinBox.

Sanguinario_Joe

2015-06-03 11:05

developer   ~0006185

"Locale specific strings must only be taken into account for our special Qt widgets that support units which are InputField and QuantitySpinBox."

I don't know if I'm wrong, but for the Python developers it is resulting in several inconsistencies that they should manually fix adding a lot of useless code.

Maybe I'm wrong, but there are not documentation about Gui::InputField or Gui::QuantitySpinBox either.

Kunda1

2017-01-11 22:34

manager   ~0007659

Reference:
http://www.freecadweb.org/api/da/dfa/classGui_1_1InputField.html
http://www.freecadweb.org/api/d6/d3e/classGui_1_1QuantitySpinBox.html

Issue History

Date Modified Username Field Change
2015-05-31 16:19 Sanguinario_Joe New Issue
2015-06-02 15:17 wmayer Note Added: 0006181
2015-06-03 11:05 Sanguinario_Joe Note Added: 0006185
2017-01-11 22:34 Kunda1 Note Added: 0007659
2017-01-11 22:34 Kunda1 Tag Attached: documentation
2017-01-16 18:52 Kunda1 Tag Attached: locale