Beispiel #1
0
function change_locale_url($locale)
{
    $url = LP_BASE_URL;
    $config = \LandingPages\Mvc::getConfig();
    if (in_array('url', explode(',', $config->getData('locale.detect_methods')))) {
        $locale_map = array_search($locale, get_locale_url_map());
        if (!$locale_map) {
            $locale_map = $locale;
        }
        $url .= $locale_map . '/';
    }
    list($controller, $action, $params) = \LandingPages\Mvc::getDispatcher()->getCurrentToken();
    if (!LP_IS_HOME && $controller == 'landing' && $action == 'view') {
        $i18n = new \LandingPages\Mvc\I18n();
        $url .= $i18n->translateUrl($params['template'], $locale) . '.html';
    }
    return $url;
}
Beispiel #2
0
 protected function _needToRedirect($when, $locale)
 {
     $config = Mvc::getConfig();
     $detect_methods = explode(',', $config->getData('locale.detect_methods'));
     if (in_array('url', $detect_methods) && $config->getData('locale.url_redirect_after.' . $when)) {
         $url_key = array_search($locale, get_locale_url_map());
         if ($url_key) {
             header('Location: ' . LP_BASE_URL . $url_key . '/');
             exit;
         }
     }
 }