human_number 0.1.8 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/README.md +6 -1
- data/lib/human_number/formatters/number.rb +18 -1
- data/lib/human_number/version.rb +1 -1
- data/lib/locales/ja.yml +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25a997b6244948ebded5aa57455a54c930b8ea0f6255e17f620a315e578d0b58
|
4
|
+
data.tar.gz: 5ee0a391c1875a6cde5843535949a7995d87ccbc179ffd7734f315e0292f5c98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d566ce576fbf747a5db5263a4ed8fbe84e20ea11d96d51da4217e80ba9c0046eaa1f4e5b4a0e87494be49444e57ed1f5823354050a28edae15c25403ffbc889a
|
7
|
+
data.tar.gz: 0e2e0b57bba47bcd184990bd3988b4121abc8297246bd8f8a21fb53c32dbb17a3d39d2547c0dd4f7ea202c543265878698e39b918f4e84c1b2465a98089e1bb5
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,25 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
+
## [0.1.10] - 2025-08-19
|
9
|
+
|
10
|
+
### Changed
|
11
|
+
|
12
|
+
- **BREAKING CHANGE: Default number formatting behavior**: Changed `max_digits` default value from `2` to `nil`
|
13
|
+
- Numbers now display complete breakdown by default (e.g., `"1M 234K 567"` instead of `"1.2M"`)
|
14
|
+
- Previous abbreviated behavior still available by explicitly setting `max_digits: 2`
|
15
|
+
- Affects all methods: `HumanNumber.human_number()`, `HumanNumber.human_currency()`, and Rails helpers
|
16
|
+
- Provides safer default behavior with no information loss
|
17
|
+
- Maintains backward compatibility for explicit `max_digits` parameter usage
|
18
|
+
|
19
|
+
## [0.1.9] - 2025-08-05
|
20
|
+
|
21
|
+
### Changed
|
22
|
+
- **East Asian separator formatting**: Japanese numbers now use culturally appropriate spacing
|
23
|
+
- Japanese: `'12億3456万7890円'` (no spaces between units)
|
24
|
+
- Korean/Chinese: `'12억 3456만 7890원'` (spaces maintained as default)
|
25
|
+
- **Locale-based separator configuration**: Added `number.human.decimal_units.separator` for customizable unit separators
|
26
|
+
|
8
27
|
## [0.1.8] - 2025-08-05
|
9
28
|
|
10
29
|
### Fixed
|
@@ -102,5 +121,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
102
121
|
- **Formatters::Currency**: Currency symbol and format string application
|
103
122
|
- **Clean separation**: Number formatting independent of currency concerns
|
104
123
|
|
124
|
+
[0.1.10]: https://github.com/ether-moon/human_number/releases/tag/v0.1.10
|
125
|
+
[0.1.9]: https://github.com/ether-moon/human_number/releases/tag/v0.1.9
|
105
126
|
[0.1.8]: https://github.com/ether-moon/human_number/releases/tag/v0.1.8
|
106
127
|
[0.1.0]: https://github.com/ether-moon/human_number/releases/tag/v0.1.0
|
data/README.md
CHANGED
@@ -158,9 +158,14 @@ HumanNumber.human_number(1_000_000_000, locale: :en) #=> "1B"
|
|
158
158
|
HumanNumber.human_number(1_234_567, locale: :ko) #=> "120만"
|
159
159
|
HumanNumber.human_number(1_234_567, locale: :ja) #=> "120万"
|
160
160
|
HumanNumber.human_number(100_000_000, locale: :ko) #=> "1억"
|
161
|
+
|
162
|
+
# Complete mode shows cultural spacing differences
|
163
|
+
HumanNumber.human_number(12_345_678, locale: :ko, max_digits: nil) #=> "1234만 5678" # Korean: spaces
|
164
|
+
HumanNumber.human_number(12_345_678, locale: :ja, max_digits: nil) #=> "1234万5678" # Japanese: no spaces
|
161
165
|
```
|
162
166
|
|
163
|
-
**Units:** 만/万 (ten thousand), 억/億 (hundred million), 조/兆 (trillion)
|
167
|
+
**Units:** 만/万 (ten thousand), 억/億 (hundred million), 조/兆 (trillion)
|
168
|
+
**Cultural spacing:** Japanese uses no spaces between units, Korean/Chinese use spaces (configurable via locale files)
|
164
169
|
|
165
170
|
### Indian System (lakh/crore)
|
166
171
|
**Used by:** Hindi (hi), Urdu (ur), Bengali (bn), Indian English (en-IN)
|
@@ -74,7 +74,7 @@ module HumanNumber
|
|
74
74
|
def default_options
|
75
75
|
{
|
76
76
|
abbr_units: true,
|
77
|
-
max_digits:
|
77
|
+
max_digits: nil,
|
78
78
|
min_unit: nil,
|
79
79
|
trim_zeros: true,
|
80
80
|
}.freeze
|
@@ -419,6 +419,11 @@ module HumanNumber
|
|
419
419
|
].freeze
|
420
420
|
|
421
421
|
class << self
|
422
|
+
def format_number(number, locale:, abbr_units: true, min_unit: nil, max_digits: 2, trim_zeros: true)
|
423
|
+
@current_locale = locale.to_sym
|
424
|
+
super
|
425
|
+
end
|
426
|
+
|
422
427
|
private
|
423
428
|
|
424
429
|
def unit_definitions
|
@@ -437,6 +442,18 @@ module HumanNumber
|
|
437
442
|
def apply_symbol_formatting_rules(symbol, _abbr_units)
|
438
443
|
symbol
|
439
444
|
end
|
445
|
+
|
446
|
+
# Apply culturally appropriate separators for East Asian languages
|
447
|
+
def finalize_result(number, formatted_parts)
|
448
|
+
separator = lookup_decimal_separator(@current_locale)
|
449
|
+
combined_result = formatted_parts.join(separator)
|
450
|
+
number.negative? ? "-#{combined_result}" : combined_result
|
451
|
+
end
|
452
|
+
|
453
|
+
# Look up separator from locale file, default to space
|
454
|
+
def lookup_decimal_separator(locale)
|
455
|
+
I18n.t("#{I18N_DECIMAL_UNITS_KEY}.separator", locale: locale, default: SPACE_SEPARATOR)
|
456
|
+
end
|
440
457
|
end
|
441
458
|
end
|
442
459
|
|
data/lib/human_number/version.rb
CHANGED
data/lib/locales/ja.yml
CHANGED