Skip to content

Latest commit

 

History

History
55 lines (38 loc) · 2.19 KB

File metadata and controls

55 lines (38 loc) · 2.19 KB

Utility Classes

The Intl package makes localization easier by extending the static Utility classes and automatically loading the correct format patterns, inflection rules, and validation patterns. With this awesome feature, no manual implementation is required.

Format

The Titon\Intl\Utility\Format class extends Titon\Utility\Format and provides automatic localization of format patterns for the following methods:

  • date() - Loads the date pattern.
  • datetime() - Loads the datetime pattern.
  • phone() - Loads the phone pattern.
  • relativeTime() - Loads message strings from the "common" domain, "format" catalog.
  • ssn() - Loads the ssn pattern.
  • time() - Loads the time pattern.
Titon\Intl\Utility\Format::relativeTime($date); // 1 week ago

Inflect

The Titon\Intl\Utility\Inflect class extends Titon\Utility\Inflect and provides automatic localization and enforcement of inflection rules for the following methods:

  • ordinal() - Loads the ordinal rule.
  • plural() - Loads the plural, irregular, and uninflected rules.
  • singular() - Loads the singular, irregular, and uninflected rules.
  • transliterate() - Loads the transliteration rule.
Titon\Intl\Utility\Inflect::plural('quiz'); // quizzes

Number

The Titon\Intl\Utility\Number class extends Titon\Utility\Number and provides automatic localization of number configurations for the following methods:

  • currency() - Loads the number and currency format patterns.
  • percentage() - Loads the number format pattern.
Titon\Intl\Utility\Number::currency(-1000); // ($1,000)

Validate

The Titon\Intl\Utility\Validate class extends Titon\Utility\Validate and provides automatic localization of validation patterns for the following methods:

  • currency() - Loads the currency pattern.
  • phone() - Loads the phone pattern.
  • postalCode() - Loads the postal_code pattern.
  • ssn() - Loads the ssn pattern.
Titon\Intl\Utility\Validate::postalCode('abc123'); // false