PHP
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
MorphosBladeProvider.php
README.md
composer.json

README.md

MorphosBlade

Composer package Latest Stable Version License

Adds a @plural, @name, @numeral and @money tags to Laravel's Blade templating engine for Russian pluralization and declenation.

<div>
@plural(252, 'новость') от @name('Иванов Иван Иванович', 'родительный')
@numeral(565, 'сообщение', 'n') и @money(123.50, '') за Ваше отсутствие.
</div>

Will be compiled in

<div>
252 новости от Иванова Ивана Ивановича
пятьсот шестьдесят пять сообщений и 123 рубля 50 копеек за Ваше отсутствие
</div>

Most popular directives:

  • @plural(count, noun) - Get plural form of word. Just pass count of objects and noun.

    @plural(244, 'элемент')
  • @money(value, currency) - Get money formatted as text string. Just pass value and currency (₽ or $ or € or ₴ or £).

    @money(1000.10, '$')
  • @numeral(number) - Get numeral of a number. Just pass number.

    @numeral(344)
  • @name(name, case) - Get any case of fullname with gender detection. Just pass name and case (именительный, родительный, дательный, винительный, творительный, предложный)

    @name('Коленко Сергей Аркадьевич', 'dativus')

Additional directives:

  • @name(name, gender, case) - Get any case of fullname. Just pass name, gender (m or w or null) and case (именительный, родительный, дательный, винительный, творительный, предложный). Use this directive if middle name is unknown and gender detection can make wrong decision.

    @name('Филимонов Игорь', 'm', 'dativus')
  • @numeral(number, gender) - Get numeral of a number. Just pass number and gender (m or f or n) to use correct form of gender-dependent words (один/одно/одна, два/две).

    @numeral(121, 'n')
  • @numeral(number, noun) - Get numeral and a pluralized noun. Just pass number and noun. It's just a shortcut to @numeral(3) @plural(3, 'поле')

    @numeral(3, 'поле')
  • @numeral(number, noun, gender) - Get numeral and a pluralized noun. Just pass number, noun and gender (m or f or n) to use correct form of gender-dependent words (один/одно/одна, два/две).

    @numeral(101, 'сообщение', 'n')

Installation

Get the Package

composer require wapmorgan/morphos-blade

Register the Service Provider

Open up your app.php in your config folder, and add the following line to your providers list like:

'providers' => array(
    ...
    morphos\MorphosBladeProvider::class
)