Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- App::import('Core', 'L10n');
- class LocaleRoute extends CakeRoute {
- public function parse($url) {
- $params = parent::parse($url);
- $l10n = new L10n();
- $defaultLang = $l10n->default;
- $defaultLoc = $l10n->map($defaultLang);
- $language = $defaultLang;
- if (isset($params['locale'])) {
- $locale = $params['locale'];
- if(in_array($locale, Configure::read('SupportedLocales'))) {
- $language = ($l10n->map($locale)) ? $l10n->map($locale) : $defaultLang;
- } else {
- // $params['locale'] = $defaultLoc;
- }
- } else {
- // $params['locale'] = $defaultLoc;
- }
- Configure::write('Config.language', $language);
- setlocale(LC_ALL, $language .'UTF8', $language .'UTF-8', $language, $defaultLang . '.UTF8', $defaultLang . '.UTF-8', $defaultLang, 'en_US');
- return $params;
- }
- }
- ?>
Add Comment
Please, Sign In to add comment