Download the PHP package matecat/icu-intl without Composer

On this page you can find all versions of the php package matecat/icu-intl. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package icu-intl

matecat/icu-intl

Quality Gate Status Coverage Reliability Rating Maintainability Rating


A PHP port of ICU4J's MessagePattern parser with locale utilities. Parses ICU MessageFormat patterns into an inspectable AST and provides locale data support for internationalization in PHP.

This package focuses on:

This package does not provide locale-aware date/number formatting itself — it provides the pattern model and utilities so you can build formatters or validators that interoperate with PHP's intl extension or other formatting libraries.

Contents

Authors

Features

ICU MessagePattern Parser

Locale Utilities

Installation

Install via Composer

Requirements

Namespaces

Namespace Description
Matecat\ICU ICU MessagePattern parser, validator, and comparator
Matecat\ICU\Tokens Token/Part model and enums (Part, TokenType, ArgType)
Matecat\ICU\Parsing Core parsing infrastructure (parser, context, accessor)
Matecat\ICU\Parsing\Style Style-specific sub-parsers (choice, plural/select, numeric)
Matecat\ICU\Parsing\Utils Static character/string utility functions
Matecat\ICU\Plurals CLDR plural rules and compliance validation
Matecat\ICU\Comparator Comparison result model
Matecat\ICU\Exceptions Parser and validation exceptions
Matecat\Locales Language data, plural rules, and locale utilities

Quick Usage

ICU MessagePattern Parser

Basic parse and inspect

Simple placeholders

Plural example

Nested selects and plurals

Locale Utilities

Languages

Plural Rules

Plural Compliance Validation

The MessagePatternValidator validates that plural/selectordinal selectors comply with CLDR plural categories for a given locale. It provides per-argument warnings for detailed feedback.

Simplified API (recommended)

The validator can work directly with a pattern string, without needing to create a MessagePattern object first:

Factory Method (with pre-parsed MessagePattern)

Use the fromPattern() factory method when you have a pre-parsed MessagePattern or want to validate the same pattern against multiple locales:

Working with Warnings
Exception Handling
More Examples
Validation Behavior Summary
Selector Type Behavior
Non-existent CLDR category (e.g., 'some') Throws PluralComplianceException
Valid CLDR category wrong for locale (e.g., 'few' in English) Returns warning in wrongLocaleSelectors
Missing required category for locale Returns warning in missingCategories
Explicit numeric selector (=0, =1, etc.) Always valid, tracked in numericSelectors
'other' category Always valid (ICU requires it as fallback)

Pattern Comparison for Translations

The MessagePatternComparator validates that translated ICU patterns maintain the same complex forms (plural, select, choice, selectordinal) as the source pattern. This ensures translations don't accidentally lose required argument structures.

Basic Usage
Factory Methods

Use factory methods when you have pre-configured validators or pre-parsed patterns:

Exception Handling
Helper Methods
Validation Rules
Scenario Behavior
Source has no complex forms Validation passes (nothing to check)
Target has same complex forms for same arguments Validation passes
Target is missing a complex form argument Throws MissingComplexFormException
Target has different complex form type for same argument Throws MissingComplexFormException
PLURAL vs SELECTORDINAL Not interchangeable (different semantics)
Target has extra complex forms Allowed (no exception)
Plural compliance (validateSource/validateTarget) Off by default; when enabled, validates selectors against CLDR rules
Invalid CLDR category (e.g., foo) Throws PluralComplianceException (when compliance validation is enabled)
Wrong locale selector (e.g., few in English) Returns PluralComplianceWarning (when compliance validation is enabled)

Language Domains

Notes about formatting

This library focuses on parsing and structure. If you want to format values using parsed plural/select patterns:

High-level API

Quick reference for the public classes and the most-used methods.

Matecat\ICU\MessagePattern

Matecat\ICU\Parsing\PartAccessor

Accessed via $pattern->parts():

Matecat\ICU\Tokens\Part

Represents a parsed token/part with accessors:

Matecat\ICU\Tokens\TokenType (enum)

Token types used by the parser: MSG_START, MSG_LIMIT, ARG_START, ARG_NAME, ARG_NUMBER, ARG_INT, ARG_DOUBLE, ARG_TYPE, ARG_STYLE, ARG_SELECTOR, ARG_LIMIT, INSERT_CHAR, REPLACE_NUMBER, SKIP_SYNTAX, etc.

Matecat\ICU\Tokens\ArgType (enum)

Argument classifications: NONE, SIMPLE, CHOICE, PLURAL, SELECT, SELECTORDINAL.

Matecat\ICU\MessagePatternValidator

Matecat\ICU\MessagePatternComparator

Compares source and target ICU MessageFormat patterns for translation validation. Ensures target patterns maintain the same complex forms (plural, select, choice, selectordinal) as source patterns.

Matecat\ICU\Comparator\ComparisonResult (readonly)

Result object returned by MessagePatternComparator::validate(). Contains optional plural compliance warnings for source and target patterns.

Matecat\ICU\Plurals\PluralComplianceWarning (readonly)

Returned when plural selectors have compliance issues that don't warrant an exception.

Matecat\ICU\Plurals\PluralArgumentWarning (readonly)

Detailed warning information for a single plural/selectordinal argument.

Matecat\ICU\Plurals\PluralComplianceException

Thrown when a selector is not a valid CLDR category name (e.g., 'some', 'foo').

Matecat\ICU\Exceptions\MissingComplexFormException

Thrown when a target pattern is missing a complex form that exists in the source pattern, or when the complex form type doesn't match.

Matecat\Locales\Languages

Matecat\ICU\Plurals\PluralRules

Constants

Matecat\Locales\LanguageDomains

Exceptions

Development

Run tests

or

Run static analysis

Project Structure

License

This project is licensed under the GNU Lesser General Public License v3.0 or later.

Credits

This PHP port mirrors ideas from ICU4J MessagePattern.java.


All versions of icu-intl with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
ext-mbstring Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package matecat/icu-intl contains the following files

Loading the files please wait ...