定制 laasti/symfony-translation-provider 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

laasti/symfony-translation-provider

最新稳定版本:v2.0.1

Composer 安装命令:

composer require laasti/symfony-translation-provider

包简介

A league/container v2 service provider for Symfony's translation component.

README 文档

README

A league/container v2 service provider for Symfony's translation component.

Installation

composer require laasti/symfony-translation-provider

Usage

$container = new League\Container\Container;
$container->addServiceProvider('Laasti\SymfonyTranslationProvider\SymfonyTranslationProvider');

$container->add('config.translation', [
    //Two-letter or four-letter locales are accepted
    'locale' => 'en',
    //When a message is not found in the locale, look in those too
    'fallback_locales' => ['en'],
    'message_selector_class' => 'Symfony\Component\Translation\MessageSelector',
    //Symfony's package offers many different loaders
    'loaders' => [
        'array' => 'Symfony\Component\Translation\Loader\ArrayLoader',
        'json' => 'Symfony\Component\Translation\Loader\JsonFileLoader'
    ],
    'resources' => [
        'en' => [
            //The first item is the loader to use, the second the resource the loader will use
            ['array', ['hello_world' => 'Hello']]
            //The third item in array is the resource's domain
            //Sseful to namespace messages, defaults to messages
            ['json', 'my-json-file.json', 'forms']
        ]
    ],
]);

$translator = $container->get('Symfony\Component\Translation\Translator');

$translator->trans('hello_world); //returns "Hello"

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

History

See Github's releases, or tags

Credits

Author: Sonia Marquette (@nebulousGirl)

License

Released under the MIT License. See LICENSE.txt file.

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-08-30