Search code examples
typo3-8.xtx-indexed-search

Translations in indexed-search with own templates


I'm using Typo3 8.7.11 and the extension indexedSearch 8.7.11 with Fluid-Templates

I created an extension with my own fluid-templates for the search and search-results form.

Now I also want to use my own translations for these templates. So I created the following files in myTemplateExt/Resources/Private/Language:

  • locallang.xlf (for the default - en - language)
  • de.locallang.xlf
  • fr.locallang.xlf
  • it.locallang.xlf

Alas, the translations are not loaded.

I found out that I can add the whole path to the translations like

<f:translate key="LLL:EXT:myTemplateExt/Resources/Private/Language/locallang.xlf:sform.submit" />

But then only the locallang.xlf file is loaded. All other languages are ignored.

I also tried to add my own variable to the indexed-search TS-setup:

plugin.tx_indexedsearch.settings.langfile = EXT:myTemplateExt/Resources/Private/Language/locallang.xlf

Which of course fails miserably (most likely because I can't define my own settings-var in TS for another extension?)

Any ideas how I can make the indexed-search extension use my own lang-files?

P.S. I found this suggestion on StackOverflow:

Typo3 Indexed Search Local_Lang path

But this is not what I want - I need more flexibility for my templates, as I need to add some more text than just the regular keys that indexed-search provides to them (yeah, customers, you know ;)


Solution

  • It might not be the best solution, but I solved the problem like this:

    I set a variable according to the current language:

    <v:variable.set name="currentLang" value="{v:page.language(languages: 'LLL:EXT:myExt/Resources/Private/Language/de.locallang.xlf,
    LLL:EXT:myExt/Resources/Private/Language/en.locallang.xlf,
    LLL:EXT:myExt/Resources/Private/Language/fr.locallang.xlf,
    LLL:EXT:myExt/Resources/Private/Language/it.locallang.xlf',
     normalWhenNoLanguage: 'LLL:EXT:myExt/Resources/Private/Language/de.locallang.xlf')}" />
    

    And then for the translation:

    <f:form.submit name="search[submitButton]" value="{f:translate(key: '{currentLang}:sform.submit')}" id="tx-indexedsearch-searchbox-button-submit" class="tx-indexedsearch-searchbox-button" />
    

    This isn't elegant, but it works...