【问题标题】:Translate Extbase Extension with locallang.xlf, but nothing happens?使用 locallang.xlf 翻译 Extbase 扩展,但没有任何反应?
【发布时间】:2014-11-12 21:22:02
【问题描述】:

我正在使用 TYPO3 CMS 6.2.6 和一个新的很棒的 Extbase 扩展,称为“jobfair”。 我已经像这样添加了我的新 templateRootPaths:

plugin.tx_jobfair {

  view {
        templateRootPaths {
          100 = EXT:jobfair/Resources/Private/Templates/
          101 = fileadmin/templates/ext/jobfair/Resources/Private/Templates/
        }

        partialRootPaths {
          100 = EXT:jobfair/Resources/Private/Partials/
          101 = fileadmin/templates/ext/jobfair/Resources/Private/Partials/
       }

       layoutRootPaths {
          100 = EXT:jobfair/Resources/Private/Layouts/
          101 = fileadmin/templates/ext/jobfair/Resources/Private/Layouts/
       }
  }

}
...

所以我可以为我的特定设计编辑模板和部分。所有其他模板将从 /typo3conf/ext/jobfair/Resources/...

加载

一切正常。我还将语言文件夹从扩展 (typo3conf) 复制到我的 fileadmn 文件夹 (fileadmin/.../jobfair/Resources/Private/Language/)。

我编辑“locallang.xlf”和“de.locallang.xlf”,例如:

部分:ContractType.html

<f:if condition="{job.contractType} == 0">
 <f:translate key="tx_jobfair_domain_model_job.contract_type.0" />
</f:if>

我将在 de.locallang.xlf 更改目标

<trans-unit id="tx_jobfair_domain_model_job.contract_type">
<source>Contract Type</source>
<target>Here's my german translation!!!</target>
</trans-unit>

但它不起作用!?

如何为我的分机翻译或重命名后端(flexform)标签? de.locallang.xlf 不是正确的文件吗?

感谢您的帮助。 p.s.我清除了 TYPO3 中的所有缓存.. 什么也没发生。

这是我的文件系统

我的 FLUIDTEMPLATE 使用相同的方式

【问题讨论】:

    标签: caching typo3 translate extbase


    【解决方案1】:

    模板和语言处理是 TYPO3 中的独立组件。因此,您覆盖原始文件的模板文件无法“知道”您将语言文件复制到其他地方。您有多种选择。

    为了记录,前端的覆盖标签可以使用 TypoScript 轻松完成:

    plugin.tx_yourext._LOCAL_LANG.[languageKey] {
        labelKey = New label text
    }
    

    (默认语言有 "default" als languageKey。)

    在后端,您可以使用 Page TSConfig 覆盖 TCA 和 FlexForm 标签:

    # TCA
    TCEFORM.tt_content.layout.label = New label
    
    # FlexForm field
    TCEFORM.tt_content.pi_flexform.[ext_key].[sheet_key].[field_key].label = New label
    
    # Example for Powermail
    TCEFORM.tt_content.pi_flexform.powermail_pi1 {
        main {
            settings\.flexform\.main\.optin.label = Require opt-in for mails
        }
    }
    

    请注意 Powermail 示例中的反斜杠。相应的字段称为settings.flexform.main.optin。由于点通常是“路径分隔符”,因此必须对其进行转义才能使其正常工作。

    除了这种配置方式之外,还有一种完全不同的方法。您可以覆盖整个翻译文件:

    # Override XLF for default language
    $GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['path/to/originalTranslationFile.xlf'][]
        = 'path/to/otherTranslationFile.xlf';
    # Override XLF for French language
    $GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['fr']
        ['path/to/originalTranslationFile.xlf'][] = 'other/path/to/fr.otherTranslationFile.xlf';
    

    有关此主题的更多信息可以找到here

    【讨论】:

      【解决方案2】:

      完美。 Lorenz,非常感谢您的详细解释。现在我明白了,'我会看到更大的图景'......

      我只需要那个项目中的后端翻译,比如:

      TCEFORM.tx_jobfair_domain_model_job {
         ## disable flexform/tca fields
         salary.disabled = 1
         discipline.disabled = 1
         education.disabled = 1
      
      
         # rename or translate
         job_title.label = Stelle
         employer.label = Arbeitgeber
         employer_description.label = Arbeitgeberbeschreibung
      
      }
      

      但我也为前端视图测试它:

      plugin.tx_jobfair._LOCAL_LANG.de {
          tx_jobfair_domain_model_job.contract_type = Vertragsart
      }
      

      完美运行! 非常感谢!

      【讨论】:

        猜你喜欢
        • 2016-07-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-12-29
        • 2017-05-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多