icu4x 0.8.1-aarch64-linux → 0.10.0-aarch64-linux

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: ddb9c7009cead25dc009af0795c1691a94e166ac2316bf9e97c572d3f8adfeda
4
- data.tar.gz: a9c34bac38211fa0ce86642ca946fefa0694a0c4289a0b614d8825cad8ad3442
3
+ metadata.gz: 24bf478b25c54b01341a45b7941cd65a15e87f70b50973d2f85739a89cbb546c
4
+ data.tar.gz: e7b72eed598b92fcc461f9f15725ed72550075832528d054f2eb4e3ce89a41ac
5
5
  SHA512:
6
- metadata.gz: d19bce9e844f6779ea57b12688a06ba35741f7f8bf6d917c99b30b5060e48f21a484c1c88850dee79a1d542260e1c717f6ce74b1bafa82c3d6249fe89cb56815
7
- data.tar.gz: d2a0ebc57246e4b9e2459f9ce8e4c9cae08b073bb8c796b054db7c9850fba22a9fec70d525e56c05c6af507f90bac5349dffb8f57e68baf3f79df90743a5fd4d
6
+ metadata.gz: 64ec6939951a9bea0462e2afc7bc3b1723a261c4dfb840f996062786434032f6d97b054727d3c462526cd2d3737de4480530c734c70aa54b173b3d8b514ca369
7
+ data.tar.gz: 5059082988fc87b109a9fa2f0047f69d377a1a1d654bbd016d20fce44f10f88d7f3abc2af5df28aabbee7274109b074dc7c56e9dcf5ed6739ecfabcd0d073e87
data/CHANGELOG.md CHANGED
@@ -1,5 +1,40 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.10.0] - 2026-05-08
4
+
5
+ ### Added
6
+
7
+ - `era:` option for `ICU4X::DateTimeFormat` to control era display (`:auto`, `:full`, `:with_era`, `:never`) (#144)
8
+ - Locale variant APIs: `ICU4X::Locale#variants`, `#add_variant!`, `#add_variant`, `#remove_variant!`, `#remove_variant` (#143)
9
+
10
+ ### Fixed
11
+
12
+ - `hour12: true/false` now maps to `Clock12`/`Clock24` for locale-aware hour cycle preference, not fixed `H12`/`H23` (#145)
13
+ - Declare `bigdecimal` as an explicit runtime dependency (#149)
14
+ - Remove deprecated `AnyCalendarKind::JapaneseExtended` (#141)
15
+
16
+ ### Changed
17
+
18
+ - Update ICU4X crates from 2.1 to 2.2 (CLDR 48.2, TZDB 2026a) (#138)
19
+
20
+ ## [0.9.0] - 2026-02-01
21
+
22
+ ### Added
23
+
24
+ - `hour12` option for `ICU4X::DateTimeFormat` as a simpler alternative to `hour_cycle` (#132)
25
+ - Default behavior for `ICU4X::DateTimeFormat` when no options specified, matching JavaScript Intl.DateTimeFormat (#130)
26
+ - Component options for `ICU4X::DateTimeFormat` (`year`, `month`, `day`, `weekday`, `hour`, `minute`, `second`) as an alternative to style options (#129)
27
+ - Document numbering system support via BCP 47 locale extensions (`-u-nu-xxx`) for `NumberFormat`, `DateTimeFormat`, and `RelativeTimeFormat` (#127)
28
+ - `hour_cycle` option for `ICU4X::DateTimeFormat` to control 12/24-hour time display (#112)
29
+ - `ICU4X::RelativeTimeFormat#format_to_parts` method for breaking down formatted output into typed parts (#117)
30
+ - `ICU4X::ListFormat#format_to_parts` method for breaking down formatted output into typed parts (#116)
31
+ - `ICU4X::NumberFormat#format_to_parts` method for breaking down formatted output into typed parts (#115)
32
+ - `ICU4X::DateTimeFormat#format_to_parts` method for breaking down formatted output into typed parts (#114)
33
+ - `ICU4X::FormattedPart` data class for representing formatted parts (#113)
34
+ - `ICU4X::PluralRules#select_range` method for plural category selection on number ranges (#106)
35
+ - Allow data gems to be required by gem name (#104)
36
+ - `ICU4X::Locale.parse_bcp47` method for explicit BCP 47 parsing; `parse` is now an alias (#108)
37
+
3
38
  ## [0.8.1] - 2026-01-12
4
39
 
5
40
  ### Added
data/README.md CHANGED
@@ -41,16 +41,11 @@ Prebuilt binary gems are available for x86_64-linux, aarch64-linux, x86_64-darwi
41
41
 
42
42
  #### Option 1: Use Pre-built Data Gem (Quick Start)
43
43
 
44
- Add a companion data gem for instant setup:
44
+ Add a companion data gem to your Gemfile:
45
45
 
46
46
  ```ruby
47
47
  gem "icu4x"
48
- gem "icu4x-data-recommended" # 164 locales, ~24MB
49
- ```
50
-
51
- ```ruby
52
- require "icu4x"
53
- require "icu4x/data/recommended" # Auto-configures default provider
48
+ gem "icu4x-data-recommended" # 164 locales, ~24MB, auto-configures default provider
54
49
  ```
55
50
 
56
51
  Available data gems:
@@ -119,7 +114,7 @@ lf.format(%w[Apple Banana Cherry])
119
114
  # Relative time formatting
120
115
  rtf = ICU4X::RelativeTimeFormat.new(locale, provider:)
121
116
  rtf.format(-3, :day)
122
- # => "3日前"
117
+ # => "3 日前"
123
118
 
124
119
  # Display names
125
120
  dn = ICU4X::DisplayNames.new(locale, provider:, type: :language)
Binary file
Binary file
Binary file
@@ -84,13 +84,19 @@ module ICU4X
84
84
  config:
85
85
  )
86
86
 
87
- lib_data_dir = gem_dir / "lib" / "icu4x" / "data"
87
+ lib_dir = gem_dir / "lib"
88
+ lib_data_dir = lib_dir / "icu4x" / "data"
88
89
  lib_data_dir.mkpath
89
90
  render_template(
90
91
  "lib/icu4x/data/variant.rb.erb",
91
92
  lib_data_dir / "#{variant}.rb",
92
93
  variant:
93
94
  )
95
+ render_template(
96
+ "lib/icu4x-data-variant.rb.erb",
97
+ lib_dir / "icu4x-data-#{variant}.rb",
98
+ variant:
99
+ )
94
100
 
95
101
  # Copy LICENSE
96
102
  FileUtils.cp("LICENSE.txt", gem_dir / "LICENSE.txt")
data/lib/icu4x/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ICU4X
4
- VERSION = "0.8.1"
4
+ VERSION = "0.10.0"
5
5
  public_constant :VERSION
6
6
  end
@@ -390,6 +390,27 @@
390
390
  # #
391
391
  # def select(number); end
392
392
  #
393
+ # # Selects the plural category for a range of numbers.
394
+ # #
395
+ # # This is equivalent to JavaScript's `Intl.PluralRules.selectRange()`.
396
+ # # The result depends on both the start and end values according to
397
+ # # locale-specific range plural rules.
398
+ # #
399
+ # # @param start_value [Integer, Float] the start of the range
400
+ # # @param end_value [Integer, Float] the end of the range
401
+ # # @return [Symbol] one of `:zero`, `:one`, `:two`, `:few`, `:many`, or `:other`
402
+ # #
403
+ # # @example
404
+ # # rules.select_range(1, 5) #=> :other (in English, "1-5 items")
405
+ # # rules.select_range(0, 1) #=> :other (in English)
406
+ # #
407
+ # # @example Russian plural ranges
408
+ # # ru_rules = ICU4X::PluralRules.new(ICU4X::Locale.parse("ru"), provider: provider)
409
+ # # ru_rules.select_range(1, 2) #=> :few
410
+ # # ru_rules.select_range(1, 5) #=> :many
411
+ # #
412
+ # def select_range(start_value, end_value); end
413
+ #
393
414
  # # Returns all plural categories available for this locale.
394
415
  # #
395
416
  # # @return [Array<Symbol>] array of category symbols
@@ -425,6 +446,11 @@
425
446
  # # formatter = ICU4X::NumberFormat.new(locale, style: :percent)
426
447
  # # formatter.format(0.42) #=> "42%"
427
448
  # #
449
+ # # @example Han decimal numerals via locale extension
450
+ # # locale = ICU4X::Locale.parse("ja-JP-u-nu-hanidec")
451
+ # # formatter = ICU4X::NumberFormat.new(locale, provider: provider)
452
+ # # formatter.format(1234) #=> "一,二三四"
453
+ # #
428
454
  # class NumberFormat
429
455
  # # Creates a new NumberFormat instance.
430
456
  # #
@@ -458,6 +484,32 @@
458
484
  # #
459
485
  # def format(number); end
460
486
  #
487
+ # # Formats a number and returns an array of parts.
488
+ # #
489
+ # # Each part contains a type and value, allowing for custom styling
490
+ # # or processing of individual components.
491
+ # #
492
+ # # @param number [Integer, Float, BigDecimal] the number to format
493
+ # # @return [Array<FormattedPart>] array of formatted parts
494
+ # #
495
+ # # @note For `style: :percent` and `style: :currency`, the current ICU4X
496
+ # # experimental formatters do not provide part annotations. These styles
497
+ # # return a single `:literal` part containing the entire formatted string.
498
+ # #
499
+ # # @example
500
+ # # parts = formatter.format_to_parts(-1234.56)
501
+ # # # => [
502
+ # # # #<ICU4X::FormattedPart type=:minus_sign value="-">,
503
+ # # # #<ICU4X::FormattedPart type=:integer value="1,234">,
504
+ # # # #<ICU4X::FormattedPart type=:decimal value=".">,
505
+ # # # #<ICU4X::FormattedPart type=:fraction value="56">
506
+ # # # ]
507
+ # #
508
+ # # @example Reconstruct the formatted string
509
+ # # parts.map(&:value).join #=> "-1,234.56"
510
+ # #
511
+ # def format_to_parts(number); end
512
+ #
461
513
  # # Returns the resolved options for this instance.
462
514
  # #
463
515
  # # @return [Hash] options hash with keys:
@@ -476,36 +528,73 @@
476
528
  # # Formats dates and times according to locale-specific conventions.
477
529
  # #
478
530
  # # DateTimeFormat supports various date and time styles and calendar systems.
531
+ # # You can use either style options (date_style, time_style) or component options
532
+ # # (year, month, day, weekday, hour, minute, second), but not both.
479
533
  # #
480
- # # @example Format a date
534
+ # # @example Format a date with style
481
535
  # # formatter = ICU4X::DateTimeFormat.new(locale, date_style: :long)
482
536
  # # formatter.format(Time.now) #=> "January 1, 2026"
483
537
  # #
484
- # # @example Format date and time
538
+ # # @example Format date and time with styles
485
539
  # # formatter = ICU4X::DateTimeFormat.new(locale, date_style: :short, time_style: :short)
486
540
  # # formatter.format(Time.now) #=> "1/1/26, 12:00 PM"
487
541
  # #
542
+ # # @example Format with component options
543
+ # # formatter = ICU4X::DateTimeFormat.new(locale, year: :numeric, month: :numeric, day: :numeric)
544
+ # # formatter.format(Time.now) #=> "Dec 28, 2025"
545
+ # #
488
546
  # # @example Use Japanese calendar
489
547
  # # formatter = ICU4X::DateTimeFormat.new(locale, date_style: :long, calendar: :japanese)
490
548
  # # formatter.format(Time.now) #=> "令和8年1月1日"
491
549
  # #
550
+ # # @example Han decimal numerals via locale extension
551
+ # # locale = ICU4X::Locale.parse("ja-JP-u-nu-hanidec")
552
+ # # formatter = ICU4X::DateTimeFormat.new(locale, provider: provider, date_style: :long)
553
+ # # formatter.format(Time.utc(2025, 12, 28)) #=> "二〇二五年一二月二八日"
554
+ # #
492
555
  # class DateTimeFormat
493
556
  # # Creates a new DateTimeFormat instance.
494
557
  # #
558
+ # # You must specify either style options (date_style/time_style) or component options
559
+ # # (year, month, day, weekday, hour, minute, second). These are mutually exclusive.
560
+ # #
495
561
  # # @param locale [Locale] the locale for formatting
496
562
  # # @param provider [DataProvider, nil] data provider (uses default if nil)
497
563
  # # @param date_style [Symbol, nil] date format style: `:full`, `:long`, `:medium`, or `:short`
498
564
  # # @param time_style [Symbol, nil] time format style: `:full`, `:long`, `:medium`, or `:short`
565
+ # # @param year [Symbol, nil] year component: `:numeric` or `:two_digit`
566
+ # # @param month [Symbol, nil] month component: `:numeric`, `:two_digit`, `:long`, `:short`, or `:narrow`
567
+ # # @param day [Symbol, nil] day component: `:numeric` or `:two_digit`
568
+ # # @param weekday [Symbol, nil] weekday component: `:long`, `:short`, or `:narrow`
569
+ # # @param hour [Symbol, nil] hour component: `:numeric` or `:two_digit`
570
+ # # @param minute [Symbol, nil] minute component: `:numeric` or `:two_digit`
571
+ # # @param second [Symbol, nil] second component: `:numeric` or `:two_digit`
499
572
  # # @param time_zone [String, nil] IANA time zone identifier (e.g., "America/New_York")
500
573
  # # @param calendar [Symbol] calendar system to use
574
+ # # @param hour_cycle [Symbol, nil] hour cycle: `:h11` (0-11), `:h12` (1-12), or `:h23` (0-23)
575
+ # # @param hour12 [Boolean, nil] `true` for 12-hour format, `false` for 24-hour format
501
576
  # # @return [DateTimeFormat] a new instance
577
+ # # @raise [ArgumentError] if both style and component options are specified
502
578
  # # @raise [DataError] if data for the locale is unavailable
503
579
  # #
504
- # # @example
580
+ # # @example With style options
505
581
  # # formatter = ICU4X::DateTimeFormat.new(locale, date_style: :long, time_style: :short)
506
582
  # #
583
+ # # @example With component options
584
+ # # formatter = ICU4X::DateTimeFormat.new(locale, year: :numeric, month: :long, day: :numeric)
585
+ # #
586
+ # # @example With 24-hour format using hour_cycle
587
+ # # formatter = ICU4X::DateTimeFormat.new(locale, time_style: :short, hour_cycle: :h23)
588
+ # # formatter.format(Time.utc(2025, 1, 1, 0, 30)) #=> "00:30:00"
589
+ # #
590
+ # # @example With 12-hour format using hour12
591
+ # # formatter = ICU4X::DateTimeFormat.new(locale, time_style: :short, hour12: true)
592
+ # # formatter.format(Time.utc(2025, 1, 1, 14, 30)) #=> "2:30:00 PM"
593
+ # #
507
594
  # def initialize(locale, provider: nil, date_style: nil, time_style: nil,
508
- # time_zone: nil, calendar: :gregory); end
595
+ # year: nil, month: nil, day: nil, weekday: nil,
596
+ # hour: nil, minute: nil, second: nil,
597
+ # time_zone: nil, calendar: :gregory, hour_cycle: nil, hour12: nil); end
509
598
  #
510
599
  # # Formats a time value according to the configured options.
511
600
  # #
@@ -514,14 +603,51 @@
514
603
  # #
515
604
  # def format(time); end
516
605
  #
606
+ # # Formats a time value and returns an array of parts.
607
+ # #
608
+ # # Each part contains a type and value, allowing for custom styling
609
+ # # or processing of individual components.
610
+ # #
611
+ # # @param time [Time, #to_time] the time to format (or any object responding to #to_time)
612
+ # # @return [Array<FormattedPart>] array of formatted parts
613
+ # #
614
+ # # @example
615
+ # # parts = formatter.format_to_parts(Time.utc(2025, 1, 31))
616
+ # # # => [
617
+ # # # #<ICU4X::FormattedPart type=:month value="January">,
618
+ # # # #<ICU4X::FormattedPart type=:literal value=" ">,
619
+ # # # #<ICU4X::FormattedPart type=:day value="31">,
620
+ # # # #<ICU4X::FormattedPart type=:literal value=", ">,
621
+ # # # #<ICU4X::FormattedPart type=:year value="2025">
622
+ # # # ]
623
+ # #
624
+ # # @example Reconstruct the formatted string
625
+ # # parts.map(&:value).join #=> "January 31, 2025"
626
+ # #
627
+ # # @example Japanese calendar with era
628
+ # # formatter = ICU4X::DateTimeFormat.new(locale, date_style: :long, calendar: :japanese)
629
+ # # parts = formatter.format_to_parts(Time.utc(2025, 1, 31))
630
+ # # era_part = parts.find { |p| p.type == :era }
631
+ # # era_part.value #=> "令和"
632
+ # #
633
+ # def format_to_parts(time); end
634
+ #
517
635
  # # Returns the resolved options for this instance.
518
636
  # #
519
637
  # # @return [Hash] options hash with keys:
520
638
  # # - `:locale` [String] the resolved locale identifier
521
639
  # # - `:calendar` [Symbol] the calendar system
522
- # # - `:date_style` [Symbol] the date style (if set)
523
- # # - `:time_style` [Symbol] the time style (if set)
640
+ # # - `:date_style` [Symbol] the date style (if style options used)
641
+ # # - `:time_style` [Symbol] the time style (if style options used)
642
+ # # - `:year` [Symbol] the year component (if component options used)
643
+ # # - `:month` [Symbol] the month component (if component options used)
644
+ # # - `:day` [Symbol] the day component (if component options used)
645
+ # # - `:weekday` [Symbol] the weekday component (if component options used)
646
+ # # - `:hour` [Symbol] the hour component (if component options used)
647
+ # # - `:minute` [Symbol] the minute component (if component options used)
648
+ # # - `:second` [Symbol] the second component (if component options used)
524
649
  # # - `:time_zone` [String] the time zone (if set)
650
+ # # - `:hour_cycle` [Symbol] the hour cycle (if set)
525
651
  # #
526
652
  # def resolved_options; end
527
653
  # end
@@ -538,6 +664,11 @@
538
664
  # # formatter.format(-1, :day) #=> "yesterday"
539
665
  # # formatter.format(0, :day) #=> "today"
540
666
  # #
667
+ # # @example Han decimal numerals via locale extension
668
+ # # locale = ICU4X::Locale.parse("ja-u-nu-hanidec")
669
+ # # formatter = ICU4X::RelativeTimeFormat.new(locale, provider: provider)
670
+ # # formatter.format(-3, :day) #=> "三 日前"
671
+ # #
541
672
  # class RelativeTimeFormat
542
673
  # # Creates a new RelativeTimeFormat instance.
543
674
  # #
@@ -563,6 +694,26 @@
563
694
  # #
564
695
  # def format(value, unit); end
565
696
  #
697
+ # # Formats a relative time value and returns an array of parts.
698
+ # #
699
+ # # @param value [Integer] the relative time value (negative for past, positive for future)
700
+ # # @param unit [Symbol] time unit: `:second`, `:minute`, `:hour`, `:day`,
701
+ # # `:week`, `:month`, `:quarter`, or `:year`
702
+ # # @return [Array<FormattedPart>] array of formatted parts
703
+ # #
704
+ # # @note The current ICU4X experimental RelativeTimeFormatter does not
705
+ # # provide separate part annotations for the numeric value. The entire
706
+ # # formatted string is returned as a single `:literal` part.
707
+ # #
708
+ # # @example
709
+ # # parts = formatter.format_to_parts(-3, :day)
710
+ # # # => [#<ICU4X::FormattedPart type=:literal value="3 days ago">]
711
+ # #
712
+ # # @example Reconstruct the formatted string
713
+ # # parts.map(&:value).join #=> "3 days ago"
714
+ # #
715
+ # def format_to_parts(value, unit); end
716
+ #
566
717
  # # Returns the resolved options for this instance.
567
718
  # #
568
719
  # # @return [Hash] options hash with keys:
@@ -606,6 +757,29 @@
606
757
  # #
607
758
  # def format(list); end
608
759
  #
760
+ # # Formats a list of strings and returns an array of parts.
761
+ # #
762
+ # # Each part contains a type and value, allowing for custom styling
763
+ # # or processing of individual components.
764
+ # #
765
+ # # @param list [Array<String>] the list items to format
766
+ # # @return [Array<FormattedPart>] array of formatted parts
767
+ # #
768
+ # # @example
769
+ # # parts = formatter.format_to_parts(["Apple", "Banana", "Cherry"])
770
+ # # # => [
771
+ # # # #<ICU4X::FormattedPart type=:element value="Apple">,
772
+ # # # #<ICU4X::FormattedPart type=:literal value=", ">,
773
+ # # # #<ICU4X::FormattedPart type=:element value="Banana">,
774
+ # # # #<ICU4X::FormattedPart type=:literal value=", and ">,
775
+ # # # #<ICU4X::FormattedPart type=:element value="Cherry">
776
+ # # # ]
777
+ # #
778
+ # # @example Reconstruct the formatted string
779
+ # # parts.map(&:value).join #=> "Apple, Banana, and Cherry"
780
+ # #
781
+ # def format_to_parts(list); end
782
+ #
609
783
  # # Returns the resolved options for this instance.
610
784
  # #
611
785
  # # @return [Hash] options hash with keys:
data/lib/icu4x.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "bigdecimal"
3
4
  require "dry-configurable"
4
5
  require "pathname"
5
6
 
@@ -52,18 +53,26 @@ module ICU4X
52
53
 
53
54
  # Error raised when data generation fails
54
55
  class DataGeneratorError < Error; end
55
- end
56
56
 
57
- # Define Segment data class for Segmenter
58
- module ICU4X
59
- class Segmenter
60
- Segment = Data.define(:segment, :index, :word_like)
57
+ FormattedPart = Data.define(:type, :value)
58
+
59
+ # Represents a part of a formatted string.
60
+ #
61
+ # Used by format_to_parts methods in DateTimeFormat, NumberFormat,
62
+ # ListFormat, and RelativeTimeFormat.
63
+ #
64
+ # @!attribute [r] type
65
+ # @return [Symbol] The part type (e.g., :integer, :literal, :year)
66
+ # @!attribute [r] value
67
+ # @return [String] The formatted value
68
+ class FormattedPart
69
+ # @return [String] Human-readable representation
70
+ def inspect = "#<ICU4X::FormattedPart type=#{type.inspect} value=#{value.inspect}>"
61
71
  end
62
- end
63
72
 
64
- # Enhance the Segment data class
65
- module ICU4X
66
73
  class Segmenter
74
+ Segment = Data.define(:segment, :index, :word_like)
75
+
67
76
  # Represents a segment of text.
68
77
  #
69
78
  # @!attribute [r] segment
@@ -78,12 +87,36 @@ module ICU4X
78
87
  private :word_like
79
88
  end
80
89
  end
81
- end
82
90
 
83
- # Enhance the native Locale class
84
- module ICU4X
85
91
  # Represents a BCP 47 locale identifier.
86
92
  class Locale
93
+ POSIX_CATEGORIES = %i[collate ctype messages monetary numeric time].freeze
94
+ private_constant :POSIX_CATEGORIES
95
+
96
+ # Creates a Locale from environment variables.
97
+ #
98
+ # Checks LC_ALL, LC_{category}, and LANG in order,
99
+ # parsing each as a POSIX locale. Falls back to "C" if none are valid.
100
+ #
101
+ # @param category [Symbol] POSIX locale category (default: :messages)
102
+ # @return [Locale]
103
+ # @raise [ArgumentError] if category is not a valid POSIX category
104
+ def self.from_env(category: :messages)
105
+ unless POSIX_CATEGORIES.include?(category)
106
+ raise ArgumentError, "unknown locale category: #{category.inspect}"
107
+ end
108
+
109
+ env_name = "LC_#{category.to_s.upcase}"
110
+ [ENV["LC_ALL"], ENV[env_name], ENV["LANG"]].each do |value|
111
+ next if value.nil? || value.empty?
112
+
113
+ return parse_posix(value)
114
+ rescue LocaleError
115
+ next
116
+ end
117
+ parse_posix("C")
118
+ end
119
+
87
120
  # @return [String] Human-readable representation
88
121
  def inspect = "#<ICU4X::Locale:#{self}>"
89
122
 
data/sig/icu4x.rbs CHANGED
@@ -18,6 +18,14 @@ module ICU4X
18
18
  class DataGeneratorError < Error
19
19
  end
20
20
 
21
+ class FormattedPart
22
+ attr_reader type: Symbol
23
+ attr_reader value: String
24
+
25
+ def self.[]: (Symbol type, String value) -> FormattedPart
26
+ def self.new: (type: Symbol, value: String) -> FormattedPart
27
+ end
28
+
21
29
  class DataProvider
22
30
  def self.from_blob: (Pathname path, ?priority: :language | :region) -> DataProvider
23
31
  end
@@ -27,8 +35,12 @@ module ICU4X
27
35
  def self.available_markers: () -> Array[String]
28
36
  end
29
37
 
38
+ type locale_category = :collate | :ctype | :messages | :monetary | :numeric | :time
39
+
30
40
  class Locale
31
- def self.parse: (String locale_str) -> Locale
41
+ def self.from_env: (?category: locale_category) -> Locale
42
+ def self.parse_bcp47: (String locale_str) -> Locale
43
+ alias self.parse self.parse_bcp47
32
44
  def self.parse_posix: (String posix_str) -> Locale
33
45
 
34
46
  def language: () -> String?
@@ -49,6 +61,7 @@ module ICU4X
49
61
  def self.new: (Locale locale, ?provider: DataProvider, ?type: plural_rule_type) -> PluralRules
50
62
 
51
63
  def select: (Integer | Float number) -> plural_category
64
+ def select_range: (Integer | Float start_value, Integer | Float end_value) -> plural_category
52
65
  def categories: () -> Array[plural_category]
53
66
  def resolved_options: () -> { locale: String, type: plural_rule_type }
54
67
  end
@@ -59,6 +72,14 @@ module ICU4X
59
72
  type date_style = :full | :long | :medium | :short
60
73
  type time_style = :full | :long | :medium | :short
61
74
  type datetime_calendar = :gregory | :japanese | :buddhist | :chinese | :hebrew | :islamic | :persian | :indian | :ethiopian | :coptic | :roc | :dangi
75
+ type hour_cycle = :h11 | :h12 | :h23
76
+ type year_style = :numeric | :two_digit
77
+ type month_style = :numeric | :two_digit | :long | :short | :narrow
78
+ type day_style = :numeric | :two_digit
79
+ type weekday_style = :long | :short | :narrow
80
+ type hour_style = :numeric | :two_digit
81
+ type minute_style = :numeric | :two_digit
82
+ type second_style = :numeric | :two_digit
62
83
 
63
84
  class NumberFormat
64
85
  def self.new: (
@@ -74,6 +95,7 @@ module ICU4X
74
95
  ) -> NumberFormat
75
96
 
76
97
  def format: (Integer | Float | BigDecimal number) -> String
98
+ def format_to_parts: (Integer | Float | BigDecimal number) -> Array[FormattedPart]
77
99
  def resolved_options: () -> {
78
100
  locale: String,
79
101
  style: number_format_style,
@@ -92,17 +114,35 @@ module ICU4X
92
114
  ?provider: DataProvider,
93
115
  ?date_style: date_style,
94
116
  ?time_style: time_style,
117
+ ?year: year_style,
118
+ ?month: month_style,
119
+ ?day: day_style,
120
+ ?weekday: weekday_style,
121
+ ?hour: hour_style,
122
+ ?minute: minute_style,
123
+ ?second: second_style,
95
124
  ?time_zone: String,
96
- ?calendar: datetime_calendar
125
+ ?calendar: datetime_calendar,
126
+ ?hour_cycle: hour_cycle,
127
+ ?hour12: bool
97
128
  ) -> DateTimeFormat
98
129
 
99
130
  def format: (Time time) -> String
131
+ def format_to_parts: (Time time) -> Array[FormattedPart]
100
132
  def resolved_options: () -> {
101
133
  locale: String,
102
134
  calendar: datetime_calendar,
103
135
  ?date_style: date_style,
104
136
  ?time_style: time_style,
105
- ?time_zone: String
137
+ ?year: year_style,
138
+ ?month: month_style,
139
+ ?day: day_style,
140
+ ?weekday: weekday_style,
141
+ ?hour: hour_style,
142
+ ?minute: minute_style,
143
+ ?second: second_style,
144
+ ?time_zone: String,
145
+ ?hour_cycle: hour_cycle
106
146
  }
107
147
  end
108
148
 
@@ -119,6 +159,7 @@ module ICU4X
119
159
  ) -> RelativeTimeFormat
120
160
 
121
161
  def format: (Integer value, relative_time_unit unit) -> String
162
+ def format_to_parts: (Integer value, relative_time_unit unit) -> Array[FormattedPart]
122
163
  def resolved_options: () -> {
123
164
  locale: String,
124
165
  style: relative_time_format_style,
@@ -141,6 +182,7 @@ module ICU4X
141
182
  ) -> ListFormat
142
183
 
143
184
  def format: (Array[String] list) -> String
185
+ def format_to_parts: (Array[String] list) -> Array[FormattedPart]
144
186
  def resolved_options: () -> {
145
187
  locale: String,
146
188
  type: list_format_type,
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: icu4x
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.10.0
5
5
  platform: aarch64-linux
6
6
  authors:
7
7
  - OZAWA Sakuro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-01-12 00:00:00.000000000 Z
11
+ date: 2026-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bigdecimal
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: dry-configurable
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,7 +52,6 @@ files:
38
52
  - LICENSE.txt
39
53
  - README.md
40
54
  - lib/icu4x.rb
41
- - lib/icu4x/3.2/icu4x.so
42
55
  - lib/icu4x/3.3/icu4x.so
43
56
  - lib/icu4x/3.4/icu4x.so
44
57
  - lib/icu4x/4.0/icu4x.so
@@ -63,7 +76,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
63
76
  requirements:
64
77
  - - ">="
65
78
  - !ruby/object:Gem::Version
66
- version: '3.2'
79
+ version: '3.3'
67
80
  - - "<"
68
81
  - !ruby/object:Gem::Version
69
82
  version: 4.1.dev
Binary file