Permalink
Browse files

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

  • Loading branch information...
fahad19 committed Aug 24, 2010
1 parent a6d30c9 commit c88448d9b0374bf97bc512eedef38625fb673a62
Showing with 12 additions and 0 deletions.
  1. +1 −0 config/routes.php
  2. +11 −0 libs/croogo_router.php
View
@@ -28,4 +28,5 @@
*/
App::import('Lib', 'CroogoRouter');
require_once CONFIGS.'croogo_routes.php';
+ CroogoRouter::localize();
?>
View
@@ -36,6 +36,17 @@ public function connect($route, $default = array(), $params = array()) {
Router::connect('/:locale' . $route, $default, array_merge(array('locale' => '[a-z]{3}'), $params));
}
}
+/**
+ * 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
*

0 comments on commit c88448d

Please sign in to comment.