Search code examples
localizationtypo3typoscripttypo3-8.x

TYPO3 default locallang.xlf when the website's base language is not English


I have a website which has as base language the Greek language. So on my fluid i have a <f:translate key="more_button" /> viewhelper.

Since the locallang.xlf has to be always in English and i can not add a file with the name en.locallang.xlf, i have no idea how to turn into Greek.

I tried to override it with TypoScript but i failed.

I tried something like that:

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

Though on my TOB my plugin does not show, since i havent included any static template, so i do not know how valid is the idea.

The next thing i tried is that: 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>

and the i created a file 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>

I hoped that TYPO3 somehow will understand (TypoScript Configuration) which language is my base language and it would automatically read the gr.locallang but it doesn't work.

My 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]

Any ideas?

EDIT

After the answer from @Morgus Lethe , my problem was actually the .. Apparently this . is necessary in order get the multi language function to work. Go figure.

I wouldn't find the solution to my problem if it wasnt for @Bernd Wilke πφ as well who pointed out that my language prefix was wrong. So thank you both for your help.

Best regards,


Solution

  • I only know for sure for Typo3 v9.5, which has great multilanguage functionality, but I have a very similiar situation: My default language is Slovenian, the url is http://example.com And English is defined as an extra site language in the Site configuration, then added to my site through the List module. The url is http://example.com/en/

    In order to translate a label (for example) I have my locallang.xlf file, that contains something like this:

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

    And then I have my sl.locallang.xlf file (for Slovenian), which contains something like this:

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

    I can then use this in my fluid template, to translate the label:

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

    Typo3 then automatically detects which language it should display and uses the appropriate translation.

    Be careful, I think you have to use the . character to define the label, and also make sure that you have the correct language tag, locale and iso code in the language configuration.