wapmorgan/morphos-twig
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
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 (morfor null) and case (именительный, родительный, дательный, винительный, творительный, предложный).{{ 'Филимонов Игорь|name('m', 'дательный') }} -
{{ $number|numeral($gender) }}- Get numeral of a number. Just pass number and gender (morforn) 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 (morforn) to use correct form of gender-dependent words (один/одно/одна, два/две).{{ 'сообщение'|numeral(565, 'n') }} -
{{ $number|ordinal($gender) }}- Get ordinal of a number. Just pass number and gender (morforn) 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());
wapmorgan/morphos-twig 适用场景与选型建议
wapmorgan/morphos-twig 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 32.8k 次下载、GitHub Stars 达 10, 最近一次更新时间为 2017 年 02 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「twig」 「morphology」 「twig-extension」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 wapmorgan/morphos-twig 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 wapmorgan/morphos-twig 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 wapmorgan/morphos-twig 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A morphological solution for Russian and English language written completely in PHP. Provides classes to inflect personal names, geographical names, decline and pluralize nouns, generate cardinal and ordinal numerals, spell out money amounts and time.
Shoot aims to make providing data to your templates more manageable
Adds @plural, @name, @numeral, @ordinal and @money tags to Blade for Russian pluralization and declenation.
This Symfony bundle integrates PhpSpreadsheet into Symfony using Twig.
A Twig extension to insert css as inline styles with a tag
Adds exception handling to Twig
统计信息
- 总下载量: 32.8k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 10
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-02-03