Skip to content

Calculator widget - localization - decimal separator #3686

@zz912

Description

@zz912

Hello,

I would like to summarize my view on the localization of "Calculator Widget" #3500

At this moment, there is a rule for how the localization of decimal separators should look like:

  1. Localization of float numbers in GUIs

Different locales use different decimal separators and thousands separators. Locale-specific string-to-float functions should be avoided as they may give unexpected results. (For example the text string "1.58" in de_DE will be converted to 158 by atof()). The following guidelines (based on avoiding ambiguity rather than on "correctness" in any specific locale) are suggested if parsing float to string and vice-versa:

In the case of input allow either comma (,) or point(.) as a decimal separator, but reject any input that has more than one of either. Space should be accepted but not required as a thousands separator.

In the case of display either use point (.) consistently or use the current localisation format consistently. The emphasis here being on "consistently".

Source:
https://linuxcnc.org/docs/devel/html/gui/gui-dev-reference.html#_localization_of_float_numbers_in_guis

I think we shouldn't discuss how to localize decimal separators at this moment.
We should only discuss whether some localization complies with the rules.

I know that every rule can be changed. But please don't suggest changes to the rules, because we will never agree. It took a lot of work to make the rules quoted above.

Sigma did a localization of decimal separator for Calculator widget:
Image

I was happy with the functionality, but two problems arose:

  1. I disagreed that this behavior is not default, but optional by value self.allow_dot_and_comma = True/False
  2. At the time Sigma was doing this localization, there were no rules for localization of decimal separator. So there was a long debate about how it should work. This debate had no conclusion for Sigma. That's why this Issue was created.

My conclusion for Sigma:

  1. Leave the Calculator widget - localization - decimal separator functionality as Sigma did it. Ideally, double-check that the functionality matches the rules above (mainly in DE localization).
  2. Remove the value self.allow_dot_and_comma
  3. The rules allow creating a GUI with decimal commas, but under the condition of format consistently. Therefore, displaying decimal comma in Gmoccapy is not allowed for consistency. Maybe someday some GUI will be created where the author will want to display the current localization format. Then it will be necessary to make the widgets variable. However, this situation has not yet occurred.

I would like ask the developers to accept or disagree with my conclusion. So that Sigma knows how to proceed further.

I would like "Calculator widget - localization - decimal separator" to be a model for how to do localization for all GUIs or widgets in LCNC. I made two widgets for LCNC (Little probe, Mesa screen) and I didn't know how to do localization correctly.

Maybe Sigma coding is not ideal, maybe it wouldn't be bad to have some common library/function:
/lib/python/common/
I can't judge that because I'm a hobby programmer. I'd be interested in the opinion of someone more experienced.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions