Download the PHP package siilike/messageformat without Composer
On this page you can find all versions of the php package siilike/messageformat. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download siilike/messageformat
More information about siilike/messageformat
Files in siilike/messageformat
Package messageformat
Short Description ICU message formatting using keywords instead of positional integers
License MIT
Homepage https://github.com/magneds/php-messageformat
Informations about the package messageformat
siilike/messageformat
Forked from magneds/messageformat.
The PHP Intl MessageFormatter class works great, except for the positional variables syntax. This library solves that by providing a variable name based solution, making it easier for translators to translate content with more of an understanding of what variables represent.
As a positive side effect, it also makes the code more robust by allowing for change in variables without compromising the variable order.
Installation
Usage
As the MessageFormatter is a drop-in replacement to the PHP Intl MessageFormatter, the position based variables also still work. This should make migration pretty straight-forward.
API
Constructor
Create a new MessageFormatter instance rendering the provided pattern for the locale.
example
create
Create a new instance of MessageFormatter
example
formatMessage
Quickly format a message, without explicitly creating a new instance of MessageFormatter.
example
format
The format method is what actually does the rendering the pattern into a localized string.
example
getLocale
Obtain the locale from the MessageFormatter instance
example
getPattern
Obtain the pattern of the MessageFormatter instance. Optionally providing the PHP Intl MessageFormat compatible variant
example
parseMessage
Quick parse output string, extracting all the variables
example
parse
Extract the variables from a formatted string
example
setPattern
Sets a new pattern without changing the locale
example
Change log
Please see Changelog
Testing
Contributing
Please see Contributing
Credits
- All Contributors
License
The MIT License (MIT). Please see License File for more information.