NumbersReader
class NumbersReader (View source)
A reader for data placed in "numbers" tag in CLDR.
The most important functionality of this class is formatting numbers. This is an implementation of Number Format Patterns as defined in Unicode Technical Standard #35. However, it's not complete implementation as for now.
Following features are missing (in brackets - chapter from specification):
- support for escaping of special characters in format string [part of G.2]
- formatting numbers to scientific notation [G.4]
- support for significant digits [G.5]
- support for padding [G.6]
- formatting numbers in other number systems than "latn"
- currency symbol substitution is simplified
Constants
PATTERN_MATCH_SUBFORMAT |
An expression to catch one subformat. One format string can have
one or two subformats (positive and negative, separated by semicolon). |
PATTERN_MATCH_ROUNDING |
An expression to catch float or decimal number embedded in the format
string, which sets a rounding used during formatting. For example, when
format string looks like '#,##0.05', it means that formatted number
should be rounded to the nearest 0.05. |
FORMAT_TYPE_DECIMAL |
Constants for available format types. |
FORMAT_TYPE_PERCENT |
|
FORMAT_TYPE_CURRENCY |
|
FORMAT_LENGTH_DEFAULT |
Constants for available format lengths. |
FORMAT_LENGTH_FULL |
|
FORMAT_LENGTH_LONG |
|
FORMAT_LENGTH_MEDIUM |
|
FORMAT_LENGTH_SHORT |
|
Properties
protected CldrRepository | $cldrRepository | ||
protected VariableFrontend | $cache | ||
protected array | $parsedFormats | An array of parsed formats, indexed by format strings. |
|
protected array | $parsedFormatsIndices | An array which stores references to formats used by particular locales. |
|
protected array | $localizedSymbols | Associative array of symbols used in particular locales. |
Methods
Constructs the reader, loading parsed data from cache if available.
Shutdowns the object, saving parsed format strings to the cache.
Returns parsed number format basing on locale and desired format length if provided.
Returns parsed date or time format string provided as parameter.
Validates provided format type and throws exception if value is not allowed.
Validates provided format length and throws exception if value is not allowed.
Parses a number format (with syntax defined in CLDR).
Details
void
injectCldrRepository(CldrRepository $repository)
No description
void
injectCache(VariableFrontend $cache)
Injects the Flow_I18n_CDLR_Reader_NumbersReader cache
void
initializeObject()
Constructs the reader, loading parsed data from cache if available.
void
shutdownObject()
Shutdowns the object, saving parsed format strings to the cache.
array
parseFormatFromCldr(Locale $locale, string $formatType, string $formatLength = self::FORMAT_LENGTH_DEFAULT)
Returns parsed number format basing on locale and desired format length if provided.
When third parameter ($formatLength) equals 'default', default format for a locale will be used.
array
parseCustomFormat(string $format)
Returns parsed date or time format string provided as parameter.
array
getLocalizedSymbolsForLocale(Locale $locale)
Returns symbols array for provided locale.
Symbols are elements defined in tag symbols from CLDR. They define localized versions of various number-related elements, like decimal separator, group separator or minus sign.
Symbols arrays for every requested locale are cached.
static void
validateFormatType(string $formatType)
Validates provided format type and throws exception if value is not allowed.
static void
validateFormatLength(string $formatLength)
Validates provided format length and throws exception if value is not allowed.
protected array
parseFormat(string $format)
Parses a number format (with syntax defined in CLDR).
Not all features from CLDR specification are implemented. Please see the documentation for this class for details what is missing.