Revisions
-
Jurian Sluiman revised this gist
Jul 11, 2012 . 1 changed file with 3 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,7 @@ class Module implements public function onBootstrap(Event $e) { $default = 'nl'; $supported = array('en', 'en-GB'); $app = $e->getApplication(); $headers = $app->getRequest()->getHeaders(); @@ -20,14 +20,13 @@ public function onBootstrap(Event $e) // Loop through all locales, highest priority first foreach ($locales as $locale) { if (!!($match = Locale::lookup($supported, $locale))) { // The locale is one of our supported list Locale::setDefault($match); break; } } if (!$match) { // Nothing from the supported list is a match Locale::setDefault($default); } -
Jurian Sluiman revised this gist
Jul 11, 2012 . 1 changed file with 17 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,15 +10,27 @@ class Module implements { public function onBootstrap(Event $e) { $default = 'nl'; $supported = array('de', 'de-DE'); $app = $e->getApplication(); $headers = $app->getRequest()->getHeaders(); if ($headers->has('Accept-Language')) { $locales = $headers->get('Accept-Language')->getPrioritized(); // Loop through all locales, highest priority first foreach ($locales as $locale) { $match = Locale::lookup($supported, $locale); if ($match !== "") { // The locale is one of our supported list Locale::setDefault($match); break; } } if ($match === "") { // Nothing from the supported list is a match Locale::setDefault($default); } } else { Locale::setDefault($default); } -
Jurian Sluiman revised this gist
Jul 11, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,7 +17,7 @@ public function onBootstrap(Event $e) if ($headers->has('Accept-Language')) { $header = $headers->get('Accept-Language')->getFieldValue(); $locale = Locale::lookup($supported, $header, false, $default); Locale::setDefault($locale); } else { Locale::setDefault($default); -
Jurian Sluiman revised this gist
Jul 11, 2012 . No changes.There are no files selected for viewing
-
Jurian Sluiman revised this gist
Jul 11, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ namespace Application; use Locale; use Zend\EventManager\Event; use Zend\ModuleManager\Feature; class Module implements -
Jurian Sluiman revised this gist
Jul 11, 2012 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,8 @@ <?php namespace Application; use Locale; use Zend\EventManager\EventInterface; use Zend\ModuleManager\Feature; class Module implements -
Jurian Sluiman revised this gist
Jul 11, 2012 . 1 changed file with 2 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,8 +8,8 @@ class Module implements { public function onBootstrap(Event $e) { $default = 'en'; $supported = array('en', 'nl'); $app = $e->getApplication(); $headers = $app->getRequest()->getHeaders(); @@ -19,7 +19,6 @@ public function onBootstrap(Event $e) Locale::setDefault($locale); } else { Locale::setDefault($default); } } } -
Jurian Sluiman revised this gist
Jul 11, 2012 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,11 +14,12 @@ public function onBootstrap(Event $e) $headers = $app->getRequest()->getHeaders(); if ($headers->has('Accept-Language')) { $header = $headers->get('Accept-Language')->getFieldValue(); $locale = Locale::lookup($supported, $header, $default); Locale::setDefault($locale); } else { Locale::setDefault($default); } } } -
Jurian Sluiman revised this gist
Jul 11, 2012 . 1 changed file with 2 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,11 +10,8 @@ public function onBootstrap(Event $e) { $default = 'en_US'; $supported = array('en_US', 'de_DE', 'nl_NL'); $app = $e->getApplication(); $headers = $app->getRequest()->getHeaders(); if ($headers->has('Accept-Language')) { Locale::setDefault($default); -
Jurian Sluiman revised this gist
Jul 11, 2012 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ <?php namespace Application; use Zend\ModuleManager\Feature; -
Jurian Sluiman created this gist
Jul 11, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ namespace Application; use Zend\ModuleManager\Feature; class Module implements Feature\BootstrapListenerInterface { public function onBootstrap(Event $e) { $default = 'en_US'; $supported = array('en_US', 'de_DE', 'nl_NL'); $app = $e->getApplication(); $sm = $app->getServiceManager(); $headers = $app->getRequest()->getHeaders(); if ($headers->has('Accept-Language')) { Locale::setDefault($default); } else { $header = $headers->get('Accept-Language')->getFieldValue(); $locale = Locale::lookup($supported, $header, $default); Locale::setDefault($locale); } } }