exs/silex-locale-detector 问题修复 & 功能扩展

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

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

exs/silex-locale-detector

Composer 安装命令:

composer require exs/silex-locale-detector

包简介

Locale detector bundle for Silex 2

README 文档

README

Locale detection with country and language breakdown

It will get the accepted language and country from $_SERVER['HTTP_ACCEPT_LANGUAGE'] and will check it against Db.

If it's not found in Db, it will insert it and return the new entry.

Results are cached with memcache.

Installation

Create a composer.json in your projects root-directory :

{
    "require": {
        "EXS/silex-locale-detector": "~1.0@dev"        
    }
}

and run :

$ curl -sS http://getcomposer.org/installer | php
$ php composer.phar install

or run this command:

    composer require exs/silex-locale-detector ~1.0@dev

Composer will now update all dependencies and you should see our bundle in the list:

  - Installing exs/silex-locale-detector (dev-master 463eb20)
    Cloning 463eb2081e7205e7556f6f65224c6ba9631e070a

Update your DB

CREATE TABLE `locales` (
  `id` smallint(6) NOT NULL AUTO_INCREMENT,
  `tag` varchar(10) COLLATE utf8_unicode_ci NOT NULL,
  `name` varchar(45) COLLATE utf8_unicode_ci NOT NULL,
  `created` datetime NOT NULL,
  `modified` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `tag` (`tag`)
) ENGINE=InnoDB AUTO_INCREMENT=134 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE `languages` (
  `id` smallint(6) NOT NULL AUTO_INCREMENT,
  `tag` varchar(10) COLLATE utf8_unicode_ci NOT NULL,
  `language` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `created` datetime NOT NULL,
  `modified` datetime NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_language` (`tag`)
) ENGINE=InnoDB AUTO_INCREMENT=142 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE `countries` (
  `id` smallint(6) NOT NULL AUTO_INCREMENT,
  `iso3166alpha2` varchar(2) COLLATE utf8_unicode_ci DEFAULT NULL,
  `iso3166alpha3` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL,
  `iso3166numeric` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL,
  `fips` varchar(2) COLLATE utf8_unicode_ci DEFAULT NULL,
  `country` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `continent` varchar(2) COLLATE utf8_unicode_ci DEFAULT NULL,
  `created` datetime NOT NULL,
  `modified` datetime NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_country` (`iso3166alpha2`)
) ENGINE=InnoDB AUTO_INCREMENT=259 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

Registering

    $app->register(new \EXS\LocaleProvider\Providers\ServiceProvider());

Example

    $app->register(new \EXS\LocaleProvider\Providers\ServiceProvider());
    // Simple use
    $language = $app['exs.serv.locale.detector']->getLanguage();
    $local = $app['exs.serv.locale.detector']->getLocale();
    $country = $app['exs.serv.locale.detector']->getCountry();

Dependencies

Silex 2.0

Doctrine\Dbal 2.2

kuikui/memcache-service-provider ~2.0

You need a memcache server up and running.

License

The LocaleDetectorPovider for Silex is licensed under the MIT license.

Contributing

Anyone and everyone is welcome to contribute.

If you have any questions or suggestions please let us know.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-07-15