There are currently some problems with the issue of accessing the front page. When you access the site's root URL (i.e. $_GET['q'] is empty), you should be redirected to $lang. When you access $lang directly, no redirection needs to take place.

Attached patch fixes i18n.module and makes the front page access behave as it should.

Comments

g10’s picture

so, original behaviour of the redirects is:
mysite.com > mysite.com :: default language (en) - no redirect
mysite.com > mysite.com/fr :: non-default language (fr) - redirect

with this patch it changes in:
mysite.com > mysite.com/en :: default language (en) - redirect
mysite.com > mysite.com/fr :: non-default language (fr) - redirect

in case you wish for (no redirections):
mysite.com > mysite.com :: default language (en) - no redirect - en frontpage
mysite.com > mysite.com :: non-default language (fr) - no redirect - fr frontpage

so basicly, first time visitor gets site in default language, but when they have been browsing in other language and go back to the base_path (root URL of site), then they get the frontpage in the other language without redirect

when you want to redirect eg. mysite.com/fr/home to mysite.com/#/fr/home — and don't want to have mysite.com/fr#/fr/home from the i18n module
(use case: Flash/Flex + SWFAddress)


function i18n_init(){
  global $i18n_langpath;
  $lang = i18n_get_lang();
  $path = _i18n_get_original_path();
  // Init selection mode
  i18n_selection_mode(variable_get('i18n_selection_mode', 'simple'));
  // Multi tables, for backwards compatibility and experimentation
  _i18n_set_db_prefix($lang);

  if ($path == '') { // Main page
    // Check for update or cron scripts to disable rewriting and redirection
    if(preg_match('|/(?!index\.php)\w+\.php|', request_uri())){
      i18n_selection_mode('off');
//    } elseif ($lang != i18n_default_language()) {
      // Redirect to main page in $lang when it's not default language.
//      _i18n_goto($lang);
    } else {
      $_GET['q'] = i18n_frontpage($lang);
    } 
  } elseif ($lang == $path) { // When path is only language code
    $_GET['q'] = i18n_frontpage($lang);
  }
  elseif ($i18n_langpath) {
    //search alias with and without lang and remove lang.
    $_GET['q'] = i18n_get_normal_path($path);
  }
  // If not in bootstrap, variable init
//  if(!_i18n_is_bootstrap()){
    //include drupal_get_path('module', 'i18n').'/i18n.inc';
//    i18n_variable_init();    
//  }  
}

g10’s picture

StatusFileSize
new1.11 KB

and the patch for convenience

in fact, this should be turned into an option, so people can choose the preferred behaviour
either add language prefix for every language, or no language prefix at all

TBarregren’s picture

I have added this to the #227550: Patch bundle.

jose reyero’s picture

Status: Needs review » Closed (won't fix)

Only critical issues for 5.x