human_number 0.1.8 → 0.1.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 42fe66194bf6870029efef196173647a511774b68b13faee24f237d665972722
4
- data.tar.gz: bceac8e6a9b6ff97f8737c72068b0e2e98f11c2525dc0572c42218376e0389dc
3
+ metadata.gz: b40f4d307a6d79e38dd1e45276c6df0334d28081dfb3cdddce89d943732e9aab
4
+ data.tar.gz: f25564f84991e593d68de48fd88b79e1ef64baaa473d962428b5008b61a25c93
5
5
  SHA512:
6
- metadata.gz: d39a9b87d7e0f1a8e7bcecbf7184931bfb35c48047992772a2635aeac8079cbaeb31a766e3443afa789b4fb9f45a1a69abe194ab0f309098c43e6860b384d052
7
- data.tar.gz: ea2765ffb9962d98ec8fcd52db74a877edf20cbaa0dae1903c6d8d6edc748016160695734f0f52ca4279a16e65aae3fa235bcce28ec776376440d736fda709cc
6
+ metadata.gz: 030e86e5855e634e6aafb8940834f58a290276a7c2096e1da12b44eb9bbd667803c1a2239822d091f69aa6fb1165c4eb4187268e0911ee6a78a407f80c1ba6c1
7
+ data.tar.gz: 612b2da8d6f9abbd5d06695701e5b2943879d4a8610885f717f2acfe28577fba1e082597a1dee03c07464e58e4996cf00a3c78e54b8def050cdfa1750a74395d
data/CHANGELOG.md CHANGED
@@ -5,6 +5,14 @@ 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.9] - 2025-08-05
9
+
10
+ ### Changed
11
+ - **East Asian separator formatting**: Japanese numbers now use culturally appropriate spacing
12
+ - Japanese: `'12億3456万7890円'` (no spaces between units)
13
+ - Korean/Chinese: `'12억 3456만 7890원'` (spaces maintained as default)
14
+ - **Locale-based separator configuration**: Added `number.human.decimal_units.separator` for customizable unit separators
15
+
8
16
  ## [0.1.8] - 2025-08-05
9
17
 
10
18
  ### Fixed
@@ -102,5 +110,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
102
110
  - **Formatters::Currency**: Currency symbol and format string application
103
111
  - **Clean separation**: Number formatting independent of currency concerns
104
112
 
113
+ [0.1.9]: https://github.com/ether-moon/human_number/releases/tag/v0.1.9
105
114
  [0.1.8]: https://github.com/ether-moon/human_number/releases/tag/v0.1.8
106
115
  [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)
@@ -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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HumanNumber
4
- VERSION = "0.1.8"
4
+ VERSION = "0.1.9"
5
5
  end
data/lib/locales/ja.yml CHANGED
@@ -8,6 +8,7 @@ ja:
8
8
  unit: "¥"
9
9
  human:
10
10
  decimal_units:
11
+ separator: ""
11
12
  abbr_units:
12
13
  thousand: "千"
13
14
  ten_thousand: "万"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: human_number
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ether Moon