wapmorgan/morphos-twig 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

wapmorgan/morphos-twig

最新稳定版本:1.6.0

Composer 安装命令:

composer require wapmorgan/morphos-twig

包简介

Adds a {{ plural }}, {{ name }}, {{ numeral }}, {{ ordinal }} and {{ money }} filters to Twig templating engine for Russian pluralization and declenation.

README 文档

README

Latest Stable Version License

Adds {{ plural }}, {{ name }}, {{ numeral }}, {{ ordinal }} and {{ money }} filters to Twig templating engine for Russian pluralization and declenation.

<div>
{{ 'новость'|plural(252) }} от {{ 'Иванов Иван Иванович'|name('родительный') }}
{{ 'сообщение'|numeral(565, 'n') }} и {{ 123.50|money('') }} за Ваше отсутствие
Это Ваше {{ 351|ordinal('n') }} посещение нашего сайта за сегодня!
</div>

Will be compiled in

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

Most popular filters:

  • {{ $word|plural($count) }} - Get plural form of word. Just pass count of objects and noun.

    {{ 'новость'|plural(251) }}
  • {{ $value|money($currency) }} - Get money formatted as text string. Just pass value and currency (₽ or $ or € or ₴ or £).

    {{ 123.50|money('р') }}
  • {{ $number|numeral }} - Get cardinal of a number. Just pass number.

    {{ 565|numeral }}
  • {{ $number|ordinal }} - Get ordinal of a number. Just pass number.

    {{ 132|ordinal }}
  • {{ $name|name($case) }} - Get any case of fullname with gender detection.

    {{ 'Иванов Иван Иванович'|name('родительный') }}

Additional filters:

  • {{ $name|name($gender, $case) }} - Get any case of fullname. Just pass name, gender (m or f or null) and case (именительный, родительный, дательный, винительный, творительный, предложный).

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

    {{ 565|numeral('n') }}
  • {{ $word|numeral($number) }} - Get numeral with a pluralized word. Just pass number and noun.

    {{ 'дом'|numeral(221) }}
  • {{ $word|numeral($number, $gender) }} - Get numeral with a pluralized word. Just pass number, noun and gender (m or f or n) to use correct form of gender-dependent words (один/одно/одна, два/две).

    {{ 'сообщение'|numeral(565, 'n') }}
  • {{ $number|ordinal($gender) }} - Get ordinal of a number. Just pass number and gender (m or f or n) to use correct form of gender-dependent words (первый/первое/первая, второй/второе/вторая, etc).

    {{ 'сообщение'|ordinal('n') }}

Installation

Get the Package

composer require wapmorgan/morphos-twig

Register the Service

Open up your services.php in your app/config folder, and add the following lines:

$container
    ->register('morphos.twig_extension', morphos\MorphosTwigExtension::class)
    ->setPublic(false)
    ->addTag('twig.extension');

or if you using Twig separately from Symfony

$twig = new Twig_Environment($loader);
$twig->addExtension(new morphos\MorphosTwigExtension());

统计信息

  • 总下载量: 31.32k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 10
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 10
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-02-03