简体   繁体   English

TYPO3 v6中的语言切换

[英]Language switching in TYPO3 v6

Switching the fontend-language does not work for me as expected. 切换fontend-language对我来说不符合预期。 What I have done so far: 到目前为止,我所做的是:

At the root page, I created two website-languages, german and english: 在根页面上,我创建了两种网站语言,德语和英语:

两种语言

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. 在页面上,我为页面创建了新的翻译并添加了一些内容。

翻译

On the left is the standard language (in this case german) filled with lorem ipsum. 左侧是填充有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. 现在,当我单击英文栏上方的小预览图标时,它将带我到index.php?id=3&L=2 ,这表明添加了L=2 But the content on the website is still the standard (german/lorem ipsum) content. 但是网站上的内容仍然是标准(德语/ lorem ipsum)内容。 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: 与realurl结合使用时,结果如下:

German: /startseite/ English: /2/home/ 德语: /startseite/英语: /2/home/

  1. Is it possible to use params like de and en instead of numbers for the languages? 是否可以使用deen类的参数代替语言的数字?
  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. /startseite/ ,相应的链接/startseite/ class="active" ,但在/2/home/ ,没有链接被标记为活动。 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. TYPO3和多语言似乎是一个令人困惑的话题,我希望你们中的一些人可以回答我的一些问题。 Thanks in advance! 提前致谢!

Edit: Found the solution thanks to Daniel. 编辑:感谢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: RealUrl conf:

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

1) + 2) Use valueMap in your realURL configuration: 1)+ 2)在您的realURL配置中使用valueMap:

   '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. 3)尝试使您的L参数与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]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM