cirtool/laravel-pluralize

编写复数翻译的简洁方式

v0.1.1 2023-08-31 23:58 UTC

This package is auto-updated.

Last update: 2024-09-30 01:54:45 UTC


README

编写复数翻译的简洁方式。

使用方法

在您的任何翻译文件中,您可以使用辅助方法 trans_pluralize

return [
    'apples' => trans_pluralize('There is one apple')->as('There are many apples'),
    
    'oranges' => trans_pluralize()
                    ->case([0], 'There are none')
                    ->range([1, 19], 'There are some')
                    ->range([20, '*'], 'There are many')
                    ->build(),
                    
    'time' => trans_pluralize()
                    ->case([0], ':value minute ago')
                    ->range([20, '*'], ':value minutes ago')
                    ->build()
];

许可证

此软件包是开源软件,许可协议为MIT许可证