网站的基本语言不是英语时,TYPO3默认为locallang.xlf

时间:2018-11-30 00:16:37

标签: localization typo3 typoscript typo3-8.x

我有一个网站,其基本语言为希腊语。因此,在我的流体上,我有一个<f:translate key="more_button" />的viewhelper。

由于locallang.xlf必须始终为英语,并且我无法添加名称为en.locallang.xlf的文件,因此我不知道如何转换为希腊语。

我试图用TypoScript覆盖它,但失败了。

我尝试过类似的事情:

plugin.tx_akmyBasebase._LOCAL_LANG.gr.more_button = Value
plugin.tx_ak_myBase_base._LOCAL_LANG.gr.more_button = Value

尽管在我的TOB上我的插件没有显示,因为我还没有包含任何静态模板,所以我不知道这个想法有多有效。

接下来我要尝试的是: locallang.xlf

1。

<?xml version="1.0" encoding="UTF-8"?>
 <xliff version="1.0">
  <file source-language="en" datatype="plaintext" original="messages" date="2017-07-18T14:10:33Z" product-name="bw_apoKardias_base">
    <header/>
    <body>
        <trans-unit id="more_button" xml:space="preserve">
           <source>More</source>
        </trans-unit>
    </body>
  </file>
</xliff>

然后我创建了一个文件 gr.locallang.xlf

<?xml version="1.0" encoding="UTF-8"?>
  <xliff version="1.0">
   <file source-language="en" target-language="gr" datatype="plaintext" original="messages" date="2017-07-18T14:10:33Z" product-name="bw_apoKardias_base">
    <header/>
    <body>
        <trans-unit id="more_button" xml:space="preserve">
            <source>More</source>
            <target>Value</target>
        </trans-unit>
    </body>
  </file>
</xliff>

我希望TYPO3能够以某种方式理解(TypoScript配置)哪种语言是我的基本语言,并且它会自动读取 gr.locallang ,但这是行不通的。

我的TypoScript:

config {
  uniqueLinkVars = 1
  linkVars = L(int)
  sys_language_uid = 0
  sys_language_mode = content_fallback;2,1,0
  sys_language_overlay = 0
  language = gr
  locale_all = gr_GR.utf8
  htmlTag_langKey = el
  htmlTag_dir = ltr
  htmlTag_setParams = lang="el" dir="ltr" class="no-js"
}

AND

[globalVar = GP:L = 1]
  config {
     sys_language_uid = 1
     language = en
     locale_all = en_EN.UTF-8
     htmlTag_setParams = lang="en" dir="ltr" class="no-js"
    }
[global]

有什么想法吗?

编辑

在@Morgus Lethe回答之后,我的问题实际上是.。显然,此.是使多语言功能正常工作所必需的。走吧。

如果不是@Bernd Wilkeπφ指出我的语言前缀错误,我也找不到解决方案。因此,谢谢你们的帮助。

最诚挚的问候,

2 个答案:

答案 0 :(得分:2)

您需要正确的语言配置,以便TYPO3知道您当前使用的语言。

在TYPO3 9(您使用什么版本?)之前,这是一些拼写错误:

// no sys_language record: uid=0
config.sys_language_uid = 0
config.language = de
config.locale_all = de_DE.UTF-8
config.htmlTag_langKey = de

[globalVar = GP:L = 1]
// sys_langugage record with uid=1, does not need to match the L value!
config.sys_language_uid = 1
config.language = en
config.locale_all = en_US.UTF-8
config.htmlTag_langKey = en
[global]

从TYPO3 9开始,语言配置在站点配置中完成:

rootPageId: 2
base: 'https://www.beispiel.de/'
languages:
  -
    languageId: '0'
    title: Deutsch
    navigationTitle: ''
    base: /
    locale: de_DE.UTF-8
    iso-639-1: de
    hreflang: de-DE
    direction: ltr
    typo3Language: de
    flag: de
  -
    languageId: '1'
    title: English
    navigationTitle: ''
    # base: 'https://www.example.com/' 
    base: /en/
    locale: en_US.UTF-8
    iso-639-1: en
    hreflang: en-US
    direction: ltr
    typo3Language: default
    flag: us
    fallbackType: strickt
:    

TYPO3可以从URL中检测当前语言:URL参数L(TYPO3 <9)或域或路径段(自TYPO3 9起)具有TS条件,并使用正确的翻译文件。

答案 1 :(得分:2)

我只能肯定Typo3 v9.5,它具有强大的多语言功能,但我有一个非常相似的情况: 我的默认语言是斯洛文尼亚语,网址是http://example.com 并且英语在站点配置中被定义为一种额外的站点语言,然后通过“列表”模块添加到我的站点中。网址为http://example.com/en/

例如,为了翻译标签,我有locallang.xlf文件,其中包含以下内容:

  <trans-unit id="common.contact" xml:space="preserve">
    <source>Contact</source>
  </trans-unit>

然后,我有了sl.locallang.xlf文件(用于斯洛文尼亚语),其中包含以下内容:

  <trans-unit id="common.contact" xml:space="preserve">
    <source>Contact</source>
    <target>Kontakt</target>
  </trans-unit>

然后我可以在我的流体模板中使用它来翻译标签:

<p>
<f:translate key="LLL:EXT:myext/Resources/Private/Language/locallang.xlf:common.contact" />
</p>

Typo3然后自动检测它应该显示哪种语言并使用适当的翻译。

请注意,我认为您必须使用.字符来定义标签,并确保在语言配置中具有正确的语言标签,语言环境和iso代码。