1

I've got two langagues enabled on a Drupal 7 test site, English (set to default in admin/config/regional/language) and Finnish. Under 'Detection and Selection' URL and Default are checked, and URL is set to look for a path prefix.

I've 'translated' (i.e. run through Google Translate) one content item and can switch between the two versions by adding or omitting 'fi' to the path. However, on the front page list of content items the Finnish version is displaying, when I'm expecting to see the English one.

Does anyone know what I'm likely to have messed up or overlooked?

Toby

  • How is your content displayed on the front page? Where does it come from? A view? A direct include of the node? – Matt Feb 24 '14 at 16:58
  • It's the default Drupal front page - is that what you mean? – toby1kenobi Feb 25 '14 at 9:20
0

You say this happens with "the default Drupal front page" (that content feed). Realizing it now. The below is for those who have this problem with the front page set to display a specific node instead (at /admin/config/system/site-information).

Possible cause: using a multilingual variable for setting the front page content, and forgetting to update it. In that case, when visiting example.com/en, the Finnish version of the front page's node is displaying. However, when accessing that same node via (say) example.com/en/node/1, the English version would show.

Explanation. Normally, one URL is configured as alias for the frontpage at /admin/config/system/site-information. If this points to a content item with translations, they are shown as selected by the path prefix. With the multilingual variables however, one URL is configured per language version of the front page, completely overriding Drupal's normal language negotiation mechanism. The path prefix then selects the node given in the corresponding language version of the configuration option, even if that node is in a language not matching the path prefix. (Which leads to the funny effect that in the code rendering that front page node, $language is "wrong": it is that node's language, here and only here potentially different from the language selected by the path prefix.)

Fix. To fix this condition and preventing it from recurring:

  1. Go through all translations of your frontpage node and set them to the same alias, let's say, home [source]. This should work, as each has a different language path prefix.

  2. Go through the language versions of /admin/config/system/site-information and update all "Default front page" fields to contain home.

  3. You probably have to repeat the last step for a new language after adding it. But I did not confirm this.

This whole multilingual variable thing is only to allow the front page being shown in different languages even when language is not selected by path prefix.

Or disable the multilingual versions of this variable altogether, by following this process in reverse.

0

The default Drupal front page that you use "does not filter by language in any way" [source]. When using content translation (aka "node translation": one node per language version), Drupal would list all language versions of all your nodes in the default Drupal front page's feed.

So perhaps you are simply not seeing the English nodes listed as they are omitted or paged to a second page?

If you want your single content item on the front page, shown in your English default language by default, you can simply put your content item's path into the "Default front page" field at /admin/config/system/site-information.

However, that will mean that the language switcher does not work for this content on the front page (except maybe when using entity translation). So instead, I recommend to follow this answer, which will make the language switcher work on the front page even with node translation.

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.