Repository navigation
Conversation
Use root-locale decimal symbols for decimal and scientific formats. Cover Spanish, German, and Arabic numeric locales with the supported floating-point conversions and precision settings. Fixes j256#41. Signed-off-by: Jaehong Park <105151063+PHJ2000@users.noreply.github.com>
|
Thanks for this @PHJ2000. What is the ramifications of forcing this locale on people that are running in those countries? Are the decimal output not going to match their expected restuls? Shouldn't just the tests set the locale to ROOT? |
|
You're right: the current patch changes user-visible output, not just the tests. For example, a Spanish or German decimal description changes from I chose ROOT on the assumption that magic descriptions should be stable across machines, but #41 reports locale-dependent test failures; it does not by itself establish that production output should be locale-independent. That assumption needs to be made explicit. Setting a known FORMAT locale in the affected formatter and file-recognition tests, then restoring it after each test, is the narrower fix for #41. It would preserve the existing locale-sensitive behavior for callers. I propose revising this PR to that test-only scope unless locale-independent descriptions are the intended library contract. Does that match your preference? |
Fixes #41.
Floating-point magic descriptions currently use the JVM's default numeric locale. For example,
%fformats1.25as1,25under Spanish or German and as١٫٢٥under Arabic. This also makes the existing formatter and file-recognition tests depend on the host locale.Use
Locale.ROOTdecimal symbols for both decimal and scientific formats, keeping the decimal separator, digits, and exponent notation consistent. Regression tests cover Spanish, German, and Arabic with%f,%e,%gand their uppercase variants, including default, zero, and explicit precision. Each test restores the previous format locale in afinallyblock.Validation:
mvn -B -ntp clean packagepassed (364 tests, 2 skipped, no failures or errors).mvn -B -ntp -Duser.language=es -Duser.country=ES testpassed with the same totals.git diff --check: passed.