Download the PHP package datingvip/cldr without Composer
On this page you can find all versions of the php package datingvip/cldr. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package cldr
CLDR
The CLDR package provides means to internationalize your application by leveraging the data and conventions defined by the Unicode Common Locale Data Repository (CLDR). It offers many helpful locale information and data (such as locale names for territories, languages, days…) as well as formatters for numbers, currencies, dates and times, units, sequences, lists…
Note
The package targets CLDR version 36.
Example usage
Installation
Repository
The CLDR is represented by a Repository instance, from which data is accessed. When required, data is retrieved through a provider. The web provider fetches data from the JSON distribution hosted on GitHub. In order to avoid hitting the web with every request, a collection of caches is used, each with its own strategy.
The following example demonstrates how a repository can be instantiated:
Accessing the repository
The repository can be accessed like a big array, but it also provides interfaces to the most important data such as locales, territories, numbers, currencies…
The following example demonstrates how the repository can be used to access locales and supplemental data:
Locales
The data and conventions of a locale are represented by a Locale instance, which can be used as an array to access various raw data such as calendars, characters, currencies, delimiters, languages, territories and more.
Locales provide a collection of calendars, and the calendar
property is often used to
obtain the default calendar of a locale.
Localized objects
Locales are also often used to localize instances such as Territory, or even
Locale. The method localize
is used to localize instances. The method
tries its best to find a suitable localizer, and it helps if the instance to localize implements
Localizable, or if a ICanBoogie\CLDR\Localized<class_base_name>
class is defined.
Instances that can be localized usually implement the localize()
method.
Localized locales
A localized locale can be obtained with the localize()
method, or the localize()
method
of the desired locale.
Context transforms
Several capitalization contexts can be distinguished for which different languages use different
capitalization behavior for dates, date elements, names of languages/regions/currencies. The
context_transform()
method helps capitalizing these elements:
Calendars
Calendars are represented by a Calendar instance, they can be accessed as arrays, and also provide magic properties to rapidly access days, eras, months and quarters:
This works with days, eras, months, quarters and the following widths: abbreviated
, narrow
,
short
, and wide
. Here are some examples:
Dates and times formatters
From a calendar you can obtain formatters for dates and times.
The following example demonstrates how the dates and times formatters can be accessed and used.
Dates and Times
Calendars provide a formatter for dates and times. A width, a skeleton or a pattern can be
used for the formatting. The datetime can be specified as an Unix timestamp, a string or a
DateTime
instance.
Date formatter
Calendars provide a formatter for dates. A width or a pattern is used for the formatting.
Time formatter
Calendars provide a formatter for times. A width or a pattern is used for the formatting.
Localized DateTime
DateTime
can be localized by wrapping them inside a LocalizedDateTime instance, or by using
the localize
method of the desired locale:
Number formatting
NumberFormatter can be used to format numbers.
Note: You can also obtain a number formatter, or format a number from the repository.
Localized number formatting
A localized number formatter can be obtained with the localize()
method (if the instance was
created with a repository), or the localize()
method of the desired locale. By default, the
list is formatted with the standard type, but you can also provide your own pattern.
Note: You can also obtain a localized number formatter, or format a number from a locale.
List formatting
ListFormatter can be used to format variable-length lists of things such as "Monday, Tuesday, Friday, and Saturday".
Note: You can also obtain a list formatter, or format a list from the repository.
Localized list formatting
A localized list formatter can be obtained with the localize()
method (if the instance was
created with a repository), or the localize()
method of the desired locale. By default, the
list is formatted with the "standard" type, but more types are available, and you can also
provide your own list patterns.
Note: You can also obtain a localized list formatter, or format a list from a locale.
Units
Quantities of units such as years, months, days, hours, minutes and seconds can be formatted— for example, in English, "1 day" or "3 days". It's easy to make use of this functionality via a locale's units:
Per unit
Combination of units, such as miles per hour or liters per second, can be created. Some units
already have 'precomputed' forms, such as kilometer_per_hour
; where such units exist, they should
be used in preference.
Units in composed sequence
Units may be used in composed sequences, such as 5° 30m for 5 degrees 30 minutes, or 3 ft, 2 in. For that purpose, the appropriate width can be used to compose the units in a sequence.
Plurals
Languages have different pluralization rules for numbers that represent zero, one, tow, few, many or other. ICanBoogie's CLDR makes it easy to find the plural rules for any numeric value:
Territories
The information about a territory is represented by a Territory instance, which aggregates information that is actually scattered across the CLDR.
Localized territories
A localized territory can be obtained with the localize()
method, or the localize()
method of
the desired locale.
Currencies
Currencies are represented by instances of Currency. You can create the instance yourself or get one through the currency collection.
Localized currencies
A localized currency can be obtained with the localize()
method, or the localize()
method
of the desired locale, it is often used to format a currency using the convention of a locale.
Continuous Integration
The project is continuously tested by GitHub actions.
Code of Conduct
This project adheres to a Contributor Code of Conduct. By participating in this project and its community, you are expected to uphold this code.
Contributing
Please see CONTRIBUTING for details.
License
icanboogie/cldr is released under the BSD-3-Clause.
All versions of cldr with dependencies
ext-curl Version *
ext-json Version *
ext-mbstring Version *
icanboogie/common Version ^1.3|^2.0|^6.0
icanboogie/accessor Version ^3.0|^4.0