Class: ICU4X::DataProvider

Inherits:
Object
  • Object
show all
Defined in:
lib/icu4x/yard_docs.rb

Overview

Provides locale data for ICU4X formatters and other components.

DataProvider loads precompiled locale data from a binary blob file. The blob can be generated using ICU4X::DataGenerator.export.

Examples:

Load a data provider

provider = ICU4X::DataProvider.from_blob(Pathname.new("data.postcard"))

Use with a formatter

provider = ICU4X::DataProvider.from_blob(Pathname.new("data.postcard"))
formatter = ICU4X::NumberFormat.new(locale, provider: provider)

Class Method Summary collapse

Class Method Details

.from_blob(path, priority: :language) ⇒ DataProvider

Creates a DataProvider from a binary blob file.

Examples:

provider = ICU4X::DataProvider.from_blob(Pathname.new("data.postcard"))
provider = ICU4X::DataProvider.from_blob(Pathname.new("data.postcard"), priority: :region)

Parameters:

  • path (Pathname)

    path to the .postcard blob file

  • priority (Symbol) (defaults to: :language)

    collation fallback priority, either ‘:language` or `:region`

Returns:

Raises:

  • (DataError)

    if the file cannot be read or is invalid



89
# File 'lib/icu4x/yard_docs.rb', line 89

def self.from_blob(path, priority: :language); end