application/modules/g/views/helpers/I18n.php
public function getAlternateUrl(
        $language, array $routeParams = array(), $route = null, $defaultToHome = true
    ) {
        if (!$route) {
            $router = Zend_Controller_Front::getInstance()->getRouter();
            $route  = $router->getCurrentRouteName();
        }
        if (empty($this->view->config()->resources->router->routesFile->{$language})) {
            return null;
        }
        $routes = $this->_getRoutesWithFallback($language);
        $localizedRoutes = Garp_I18n::getLocalizedRoutes($routes, array($language));

        $router = new Zend_Controller_Router_Rewrite();
        $router->addConfig(new Zend_Config($localizedRoutes));
        $routeParams['locale'] = $language;

        // @todo Also add existing GET params in the form of ?foo=bar
        try {
            $alternateRoute = $router->assemble($routeParams, $route);
        } catch (Exception $e) {
            // try to default to 'home'
            if (!$defaultToHome) {
                throw $e;
            }
            return $this->_constructHomeFallbackUrl($language);
        }
        // Remove the baseURl because it contains the current language
        $alternateRoute = $this->view->string()->strReplaceOnce(
            $this->view->baseUrl(), '', $alternateRoute
        );

        // Always use explicit localization
        if ($alternateRoute == '/') {
            $alternateRoute = '/' . $language;
        }
        return $alternateRoute;
    }
public function getAlternateUrl(
        $language, array $routeParams = array(), $route = null, $defaultToHome = true
    ) {
        if (!$route) {
            $router = Zend_Controller_Front::getInstance()->getRouter();
            $route  = $router->getCurrentRouteName();
        }
        if (empty($this->view->config()->resources->router->routesFile->{$language})) {
            return null;
        }
        $routes = $this->_getRoutesWithFallback($language);
        $localizedRoutes = Garp_I18n::getLocalizedRoutes($routes, array($language));

        $router = new Zend_Controller_Router_Rewrite();
        $router->addConfig(new Zend_Config($localizedRoutes));
        $routeParams['locale'] = $language;

        // @todo Also add existing GET params in the form of ?foo=bar
        try {
            $alternateRoute = $router->assemble($routeParams, $route);
        } catch (Exception $e) {
            // try to default to 'home'
            if (!$defaultToHome) {
                throw $e;
            }
            return $this->_constructHomeFallbackUrl($language);
        }
        // Remove the baseURl because it contains the current language
        $alternateRoute = $this->view->string()->strReplaceOnce(
            $this->view->baseUrl(), '', $alternateRoute
        );

        // Always use explicit localization
        if ($alternateRoute == '/') {
            $alternateRoute = '/' . $language;
        }
        return $alternateRoute;
    }
public function getAlternateUrl ( $ language , array $ routeParams = array ( ) , $ route = null , $ defaultToHome = true ) { if ( ! $ route ) { $ router = Zend_Controller_Front :: getInstance ( ) -> getRouter ( ) ; $ route = $ router -> getCurrentRouteName ( ) ; } if ( empty ( $ this -> view -> config ( ) -> resources -> router -> routesFile -> { $ language } ) ) { return null ; } $ routes = $ this -> _getRoutesWithFallback ( $ language ) ; $ localizedRoutes = Garp_I18n :: getLocalizedRoutes ( $ routes , array ( $ language ) ) ; $ router = new Zend_Controller_Router_Rewrite ( ) ; $ router -> addConfig ( new Zend_Config ( $ localizedRoutes ) ) ; $ routeParams [ 'locale' ] = $ language ; // @todo Also add existing GET params in the form of ?foo=bar try { $ alternateRoute = $ router -> assemble ( $ routeParams , $ route ) ; } catch ( Exception $ e ) { // try to default to 'home' if ( ! $ defaultToHome ) { throw $ e ; } return $ this -> _constructHomeFallbackUrl ( $ language ) ; } // Remove the baseURl because it contains the current language $ alternateRoute = $ this -> view -> string ( ) -> strReplaceOnce ( $ this -> view -> baseUrl ( ) , '' , $ alternateRoute ) ; // Always use explicit localization if ( $ alternateRoute == '/' ) { $ alternateRoute = '/' . $ language ; } return $ alternateRoute ; }
Get a route in a different language.

@param string $language
@param array $routeParams  Parameters used in assembling the alternate route
@param string $route       Which route to use. Defaults to current route.
@param bool $defaultToHome Wether to use home as a fallback alt route
@return string
Get a route in a different language .