DrorHarari / keypirinha-cvt

Cvt - A Keypirinha launcher plugin for conversion of units of measure for area, data size, distance, energy, force, fuel consuption, mass, power, pressure, speed, temperature and time
MIT License
23 stars 4 forks source link

Feature request: configure decimal marker for different locales #5

Closed bege10 closed 4 years ago

bege10 commented 4 years ago

Hi, thank you for this package. I need an option to configure

DrorHarari commented 4 years ago

Hi bege10. Do you just want it to be displayed that way so that, for example, the number 1234.56 would be displayed in the German locate as "1.234,56" but when actually copied to the clipboard it would be the regular number 1234.56? It is simple enough to change the display but to change the input parsing is another matter.

bege10 commented 4 years ago

Hi DrorHarari, it is more important to have it in the right format (German locale) in the clipboard so that it can be used in other apps without editing it first. The calc package that comes with Keypirinha does it that way.

DrorHarari commented 4 years ago

So in Germany, if you have the calculation result being 1000.5, do you want the clipboard to contain "1.000,5"? I mean including the thousands separator? And this is the default of the Calc plugin?

I ask because in a non-switched language where the decimal point is denoted with the point character '.' entering a number with thousands separator causes problem with many applications. I can understand why using the thousands separator for display help, less so with copying it back to the clipboard.

How about displaying in the local way but putting in the clipboard just the decimal point character?

DrorHarari commented 4 years ago

@bege10 I have pushed a pre-release version of Cvt to https://github.com/DrorHarari/keypirinha-cvt/releases/download/2.1.0/Cvt.keypirinha-package - it has a configuration item format under [main] that if you set to local, Cvt will work with the current locale.

Since I don't have a machine with strange locale that uses comma as decimal separator, I could not test it fully - please try and let me know if it works for you (if you use PackageControl you will have to comment the Cvt entry it its PackageControl.ini)

bege10 commented 4 years ago

So in Germany, if you have the calculation result being 1000.5, do you want the clipboard to contain "1.000,5"? I mean including the thousands separator? And this is the default of the Calc plugin?

I ask because in a non-switched language where the decimal point is denoted with the point character '.' entering a number with thousands separator causes problem with many applications. I can understand why using the thousands separator for display help, less so with copying it back to the clipboard.

How about displaying in the local way but putting in the clipboard just the decimal point character?

You are right that the thousands separator is only for easier reading, it is not necessary for clipboard. The local decimal separator should be used both in the KP input and in clipboard.

bege10 commented 4 years ago

@bege10 I have pushed a pre-release version of Cvt to https://github.com/DrorHarari/keypirinha-cvt/releases/download/2.1.0/Cvt.keypirinha-package - it has a configuration item format under [main] that if you set to local, Cvt will work with the current locale.

Since I don't have a machine with strange locale that uses comma as decimal separator, I could not test it fully - please try and let me know if it works for you (if you use PackageControl you will have to comment the Cvt entry it its PackageControl.ini)

Thank you very much. I installed/configured/refreshed the package and restarted KP several times, but the new package doesn't make any difference. The decimal separator remains a dot both in input and clipboard.

DrorHarari commented 4 years ago

Just to make sure, did you have

[main] format=local

In cvt.ini?

bege10 commented 4 years ago

Yes, local and common show a dot.

DrorHarari commented 4 years ago

Thanks. I was testing this by calling locale.setlocale(locale.LC_ALL, 'nl_NL.utf-8') assuming that on German and similar machines, that will be the default. Apparently in Keypirinha's environment that is not the case. When I do that explicit call, the screen shows comma as decimal separator and dot as thousands separator. I see that the Calc plugin does some stuff with Windows API calls to get the Windows definitions. I will take more work, I will get to it and let you know when I have a version that uses the Windows settings.

bege10 commented 4 years ago

Thank you very much for your work.

DrorHarari commented 4 years ago

I have put another version. Remove 'format' and now it is similar to Calc. You have decimal_separator item under [main] with values dot (default), comma and auto. Please try it out. If you can, tell me what difference you get between the comma and auto modes. 10x

bege10 commented 4 years ago

This is perfect! Both comma and auto show localized numbers. comma displays the result list and clipboard entry with comma as decimal separator and no thousands separator. auto displays the result list with comma as decimal separator and dot as thousands separator, the clipboard entry with comma as decimal separator and no thousands separator.

DrorHarari commented 4 years ago

Strange, comma was supposed to use spaces as thousand separators. Auto takes the thousand separator from Windows. Anyway, I will make this release official.

bege10 commented 4 years ago

As you said previously, thousands separators might cause problems in other apps. So this seems to be the perfect output.

DrorHarari commented 4 years ago

I mean in display, when you select comma, there is space as separator for display. For clipboard, no separator.

bege10 commented 4 years ago

Sorry, I mixed it up and was confused by the different outputs. The display is exactly as you expected with pace separators at comma