emanueleminotto/twig-inflection-bundle

Symfony 2 Bundle for davedevelopment/twig-inflection

0.1.0 2015-08-22 23:20 UTC

This package is auto-updated.

Last update: 2024-08-28 06:32:58 UTC


README

Build Status SensioLabs Insight Coverage Status Scrutinizer Code Quality

Symfony 2 Bundle for davedevelopment/twig-inflection.

步骤 1:下载 Bundle

打开命令行控制台,进入您的项目目录并执行以下命令以下载此 Bundle 的最新稳定版本

$ composer require emanueleminotto/twig-inflection-bundle

此命令要求您全局安装Composer,如 Composer 文档中的安装章节中所述。

步骤 2:启用 Bundle

然后,通过在您的项目的 app/AppKernel.php 文件中添加以下行来启用该 Bundle

// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...

            new EmanueleMinotto\TwigInflectionBundle\TwigInflectionBundle(),
        );
    }
}

用法

pluralize

{{ "chicken"|pluralize }}

=> chickens

{{ rows.length }} {{ "row"|pluralize(rows.length) }}

=> 1 row
=> 2 rows

{{ users.length }} {{ "person"|pluralize(users.length, "users") }}

=> 1 person
=> 2 users

singularize

与 pluralize 相反的操作,以相同的方式工作

{{ "chickens"|singularize }}

=> chicken

许可协议

此 Bundle 采用 MIT 许可协议。请参阅 Bundle 中的完整许可协议。

Resources/meta/LICENSE