3

I have a site with 2 languages: English and Spanish and Path prefix: en and es respectively. Then Spanish language is set to default (see image 1) image 1

And the Language negotiation is set to: Path prefix with language fallback (see image 2) enter image description here

Everything works as expected but there is one problem: when the site is loaded it takes the English as default language. Then if I change language (with the Language Switcher) everything works fine.

To be clear, it the url is:

www.mysite.com (landing page is loaded in english) I need this to be in spanish

www.mysite.com/en/home (landing page is loaded in english)

www.mysite.com/es/home (landing page is loaded in spanish)

I can't fix this..Any help please?

  • In case this is for Drupal 6 and happens only for anonymous users, it could be this bug. Some people report the same for D7 though. – tanius Feb 22 '15 at 18:53
2

The description given in the settings page reports what exactly the option you selected means:

Path prefix with language fallback. The presentation language is determined by examining the path for a language code or other custom string that matches the path prefix (if any) specified for each language. If a suitable prefix is not identified, the display language is determined by the user's language preferences from the My Account page, or by the browser's language settings. If a presentation language cannot be determined, the default language is used.

You are accessing the page without any page prefix (the URL is just www.mysite.com); in that case, the language is set basing on what the logged in users have selected in their user profiles, or what the settings for their browsers are.

I would try setting the front page to www.mysite.com/es/home, but in that case, the front page would always be in Spanish. As alternative, one of the modules of the Internationalization project should correctly set the language for the front page.

  • 1
    I have the Internationalization module installed. How can I set the language for the front page? – chefnelone Aug 4 '11 at 16:23
5
  1. goto: Home » Administration » Configuration » Regional and language » Languages.
  2. select the 'DETECTION AND SELECTION' tab.
  3. Un-check all except 'URL' and 'default'. Keep 'URL' on top of 'default'
0

You can try the Language Selection Page module. (The module is a sandbox project: use it at your own risk.)

0

If you want to stick to the "Path prefix with language fallback" mechanism, you cannot use the "Path prefix and default language" mechanism proposed by @user392795, which otherwise is great.

However, there are also solutions for this:

First case: You don't need Drupal's default feed on the front page

This is the simpler case, as we can exploit the shortcoming that Drupal will not do language negotiation when setting the "Default front page" field at /admin/config/system/site-information. So just set it to a URL of a node or view etc. that is in Spanish. This solution is also dealt with in this question.

Just make sure the "Default front page" does not say "This is a multilingual variable." below it, because that adds language dependent front pages which are not available in Drupal out of the box. If this is the case, you can get rid of it by following this process in reverse.

Second case: You also want to keep the Drupal default feed on the front page

In this case, Drupal's language selection mechanisms govern the front page, so you have to make sure that users arrive at the frontpage always with the path prefix for Spanish. Else, the language fallback mechanism would kick in and determine the language from the profile preference or browser language, as explained by @kiamlaluno already..

So, set up a URL forwarder that will do this redirect. For example with the Apache mod_alias mechanism in .htaccess:

Redirect 301 / /es/home

This one should also work, bit nicer:

Redirect 301 / /es

(If this does not work in your case, see some details.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.