2
votes

Switching the fontend-language does not work for me as expected. What I have done so far:

At the root page, I created two website-languages, german and english:

two languages

In the typoscript template I added the following setup, I found most of this scattered around the web:

config {
  tx_realurl_enable = 1
  simulateStaticDocuments = 0
  sys_language_uid = 0
  language = de
  locale_all = de_DE
  htmlTag_langKey = de
  linkVars := addToList(L)
  uniqueLinkVars = 1
  sys_language_mode = content_fallback
  sys_language_overlay = 1
}

[globalVar = GP:L = 0]
config.sys_language_uid = 0
config.language = de
config.locale_all = de_DE
config.htmlTag_langKey = de
[global]

[globalVar = GP:L = 2]
config.sys_language_uid = 1
config.language = en
config.locale_all = en_EN
config.htmlTag_langKey = en
[global]

At a page, I created a new translation for the page and added some content.

translation

On the left is the standard language (in this case german) filled with lorem ipsum. On the right is the new language (english) filled with some different content just to see some effect.

Now, when I click the little preview icon above the english column, it takes me to index.php?id=3&L=2, which indicates that L=2 is added. But the content on the website is still the standard (german/lorem ipsum) content. Where did I do wrong?

Also: I added a menu to the frontend to let the user switch between languages:

  languageMenu = HMENU
  languageMenu {
    special = language
    special.value = 0,2
    1 = TMENU
    1 {
      wrap = <ul id="language"> | </ul>
      NO = 1
      NO {
        wrapItemAndSub = <li> | </li>
        stdWrap.override = deutsch || english
      }
      ACT < .NO
      ACT {
        ATagParams = class="active"
      }
    }
  }

In combination with realurl, this results in urls like so:

German: /startseite/ English: /2/home/

  1. Is it possible to use params like de and en instead of numbers for the languages?
  2. How can I ensure that the url always contains either the german or the english language parameter?
  3. When on /startseite/, the corresponding link gets class="active", but on /2/home/, no link is marked as active. How could that be fixed?

TYPO3 and multilanguage seems to be a confusing topic, I hope some of you can answer some of my questions. Thanks in advance!

Edit: Found the solution thanks to Daniel.

Here it is in case anyone else has the same problem:

Setup:

config {
  tx_realurl_enable = 1
  simulateStaticDocuments = 0
  sys_language_uid = 0
  language = de
  locale_all = de_DE
  htmlTag_langKey = de
  linkVars := addToList(L)
  uniqueLinkVars = 1
  sys_language_mode = content_fallback
  sys_language_overlay = 1
}

[globalVar = GP:L = 0]
config.sys_language_uid = 0
config.language = de
config.locale_all = de_DE
config.htmlTag_langKey = de
[global]

[globalVar = GP:L = 2]
config.sys_language_uid = 2
config.language = en
config.locale_all = en_EN
config.htmlTag_langKey = en
[global]

[...]

  languageMenu = HMENU
  languageMenu {
    special = language
    special.value = 0,2
    1 = TMENU
    1 {
      wrap = <ul id="language"> | </ul>
      NO = 1
      NO {
        wrapItemAndSub = <li> | </li>
        stdWrap.override = deutsch || english
      }
      ACT < .NO
      ACT {
        ATagParams = class="active"
      }
    }
  }

RealUrl conf:

    'preVars' => 
    array(
      0 => 
      array(
        'GETvar' => 'L',
        'valueMap' => 
        array(
          'de' => '0',
          'en' => '2',
        ),
        'valueDefault' => 'de'
      ),
    ),
1
Thanks for the qus. I have the same issue. But still Ihave no idea about "realURL" were to add those codes. because am new to typo3. Please tell me about adding it. thank you.Vishnu Prasad

1 Answers

3
votes

1) + 2) Use valueMap in your realURL configuration:

   'preVars' =>
      array(
       0 =>
          array(
            'GETvar' => 'L',
            'valueMap' =>
              array(
                'de' => '0',                    
                'en' => '2'
              ),
          )
      )

3) Try to keep your L param in sync with the sys_language_uid. So for englisch use:

[globalVar = GP:L = 1]
    config.sys_language_uid = 1
    config.language = en
    config.locale_all = en_EN
    config.htmlTag_langKey = en
[global]