human_number 0.1.6 → 0.1.7
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/lib/human_number/locale_support.rb +8 -7
- data/lib/human_number/version.rb +1 -1
- 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: 3bc432b4b82fa70b18804f6db6080c10cf33c95e410c7ee9bb2335c99b053f8d
|
4
|
+
data.tar.gz: e2aa145ec5319d06c8ff98748ee8a696f6a0a999a571440931fc55e34681f78d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 123d58896c01e0297e7dde721df49e8036e4ced81185b508aa34750cf6b869487449b454fa9149d6816a05284f058bdf8ec6bf674ae52fbee6487ac880b8af42
|
7
|
+
data.tar.gz: e58469487228d201d424006a2d9a75aec5e8c73dedc3a7580c3e0ed716b20600d07f1055ec2993668aa38f422237b353e6f24091ba4a789c36ee4924e1546d35
|
@@ -40,7 +40,7 @@ module HumanNumber
|
|
40
40
|
}.freeze
|
41
41
|
|
42
42
|
# Keys supported for native currency formatting
|
43
|
-
SUPPORTED_NATIVE_CURRENCY_KEYS = %i[unit format
|
43
|
+
SUPPORTED_NATIVE_CURRENCY_KEYS = %i[unit format].freeze
|
44
44
|
|
45
45
|
module_function
|
46
46
|
|
@@ -113,16 +113,17 @@ module HumanNumber
|
|
113
113
|
# Return nil for unknown currencies so formatters can fall back appropriately
|
114
114
|
return nil if native_locales_for_currency(currency_code).empty?
|
115
115
|
|
116
|
-
# For native locales,
|
117
|
-
if
|
116
|
+
# For native locales and supported keys, try native formatting first
|
117
|
+
if native_locale?(currency_code, locale) && SUPPORTED_NATIVE_CURRENCY_KEYS.include?(key)
|
118
118
|
native_key = native_currency_key(key)
|
119
|
-
|
120
119
|
return I18n.t(native_key, locale:) if I18n.exists?(native_key, locale)
|
121
120
|
end
|
122
121
|
|
123
|
-
#
|
124
|
-
|
125
|
-
|
122
|
+
# Fallback to standard currency formatting using currency's primary locale
|
123
|
+
currency_locale = primary_locale_for_currency(currency_code, locale)
|
124
|
+
standard_key = currency_key(key)
|
125
|
+
|
126
|
+
I18n.t(standard_key, locale: currency_locale)
|
126
127
|
end
|
127
128
|
end
|
128
129
|
end
|
data/lib/human_number/version.rb
CHANGED