Skip to content
Browse files

locale based url support for non-routed controller actions. Closes #129

  • Loading branch information...
1 parent a6d30c9 commit c88448d9b0374bf97bc512eedef38625fb673a62 @fahad19 committed
Showing with 12 additions and 0 deletions.
  1. +1 −0 config/routes.php
  2. +11 −0 libs/croogo_router.php
View
1 config/routes.php
@@ -28,4 +28,5 @@
*/
App::import('Lib', 'CroogoRouter');
require_once CONFIGS.'croogo_routes.php';
+ CroogoRouter::localize();
?>
View
11 libs/croogo_router.php
@@ -37,6 +37,17 @@ public function connect($route, $default = array(), $params = array()) {
}
}
/**
+ * If you want your non-routed controler actions (like /users/add) to support locale based urls,
+ * this method must be called AFTER all the routes.
+ *
+ * @return void
+ */
+ public function localize() {
+ if (Configure::read('Translate')) {
+ Router::connect('/:locale/:controller/:action/*', array(), array('locale' => '[a-z]{3}'));
+ }
+ }
+/**
* Load plugin routes
*
* @return void

0 comments on commit c88448d

Please sign in to comment.
Something went wrong with that request. Please try again.