2017 © Pedro Peláez
 

library silex-locale-detector

Locale detector bundle for Silex 2

image

exs/silex-locale-detector

Locale detector bundle for Silex 2

  • Friday, July 17, 2015
  • by rumpranger
  • Repository
  • 8 Watchers
  • 0 Stars
  • 430 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

EXS-silex-locale-detector

Locale detection with country and language breakdown, (*1)

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

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

Results are cached with memcache., (*4)

Installation

Create a composer.json in your projects root-directory :, (*5)

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

and run :, (*6)

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

or run this command: ``` shell composer require exs/silex-locale-detector ~1.0@dev, (*7)


Composer will now update all dependencies and you should see our bundle in the list: ``` shell - 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, (*8)

Doctrine\Dbal 2.2, (*9)

kuikui/memcache-service-provider ~2.0, (*10)

You need a memcache server up and running., (*11)

License

The LocaleDetectorPovider for Silex is licensed under the MIT license., (*12)

Contributing

Anyone and everyone is welcome to contribute., (*13)

If you have any questions or suggestions please [let us know][1]., (*14)

The Versions

17/07 2015

dev-master

9999999-dev https://github.com/ExSituMarketing/EXS-silex-locale-detector

Locale detector bundle for Silex 2

  Sources   Download

MIT

The Requires

 

language silex locale provider detector